Skip to content

Instantly share code, notes, and snippets.

@craigforr
Last active August 31, 2021 15:55
Show Gist options
  • Select an option

  • Save craigforr/d2c6fbee1e5c2a6f8bf82ea00cdaac96 to your computer and use it in GitHub Desktop.

Select an option

Save craigforr/d2c6fbee1e5c2a6f8bf82ea00cdaac96 to your computer and use it in GitHub Desktop.

Revisions

  1. craigforr revised this gist Aug 31, 2021. 1 changed file with 16 additions and 10 deletions.
    26 changes: 16 additions & 10 deletions world-date.sh
    Original file line number Diff line number Diff line change
    @@ -4,17 +4,23 @@
    # Source: python - command-line world clock? - Stack Overflow
    # https://stackoverflow.com/questions/370075/command-line-world-clock

    search=$1
    function world_date(){
    if [ "$1"x != 'x' ]; then
    search=$1
    else
    echo "Please provide a time zone."
    fi
    zoneinfo=/usr/share/zoneinfo/posix/
    format='%a %F %T'

    zoneinfo=/usr/share/zoneinfo/posix/
    format='%a %F %T'
    find -L $zoneinfo -type f \
    | grep -i "$search" \
    | while read z; do
    d=$(TZ=$z date +"$format")
    printf "%-34s %23s\n" ${z#$zoneinfo} "$d"
    done
    }

    find -L $zoneinfo -type f \
    | grep -i "$search" \
    | while read z
    do
    d=$(TZ=$z date +"$format")
    printf "%-34s %23s\n" ${z#$zoneinfo} "$d"
    done
    world_date $1

    # EOF
  2. craigforr revised this gist Aug 31, 2021. No changes.
  3. craigforr revised this gist Aug 31, 2021. No changes.
  4. craigforr created this gist Mar 10, 2021.
    20 changes: 20 additions & 0 deletions world-date.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/bin/sh

    # Show date and time in other time zones
    # Source: python - command-line world clock? - Stack Overflow
    # https://stackoverflow.com/questions/370075/command-line-world-clock

    search=$1

    zoneinfo=/usr/share/zoneinfo/posix/
    format='%a %F %T'

    find -L $zoneinfo -type f \
    | grep -i "$search" \
    | while read z
    do
    d=$(TZ=$z date +"$format")
    printf "%-34s %23s\n" ${z#$zoneinfo} "$d"
    done

    # EOF