Skip to content

Instantly share code, notes, and snippets.

@Goles
Created April 5, 2012 20:37

Revisions

  1. Goles revised this gist Apr 5, 2012. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions cliclock.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,11 @@
    # Command-line world clock
    # Taken from http://stackoverflow.com/questions/370075/command-line-world-clock

    # .worldclock.zones file looks like:
    # US/Pacific
    # Europe/Berlin
    # Chile/Continental

    : ${WORLDCLOCK_ZONES:=$HOME/.worldclock.zones}
    : ${WORLDCLOCK_FORMAT:='+%Y-%m-%d %H:%M:%S %Z'}

  2. Goles created this gist Apr 5, 2012.
    16 changes: 16 additions & 0 deletions cliclock.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/sh
    # Command-line world clock
    # Taken from http://stackoverflow.com/questions/370075/command-line-world-clock

    : ${WORLDCLOCK_ZONES:=$HOME/.worldclock.zones}
    : ${WORLDCLOCK_FORMAT:='+%Y-%m-%d %H:%M:%S %Z'}

    while true
    do
    clear
    while read zone
    do echo $zone '!' $(TZ=$zone date "$WORLDCLOCK_FORMAT")
    done < $WORLDCLOCK_ZONES |
    awk -F '!' '{ printf "%-20s %s\n", $1, $2;}'
    sleep 1
    done