pax_global_header00006660000000000000000000000064144557170760014532gustar00rootroot0000000000000052 comment=a272530debb09aaae25d3121f3b40f1c31b4ea10 tzdiff-1.2/000077500000000000000000000000001445571707600126625ustar00rootroot00000000000000tzdiff-1.2/.gitignore000066400000000000000000000000171445571707600146500ustar00rootroot00000000000000CVS .cvsignore tzdiff-1.2/README.md000066400000000000000000000144731445571707600141520ustar00rootroot00000000000000# tzdiff Displays Timezone differences with localtime in CLI (shell script) This command was originally "timediff". Now, it's "tzdiff" because of naming conflict. ## Usage tzdiff [-0lvHN] [-n count] [-f format] [-t start] timezone [timezone ...] [count] [0] Tzdiff with no arguments will display list of timezones. Tzdiff with timezone will display the time differences of remote time with local time. ### Options * -h: show usage * -0: round down to hour * -l: display full timezone name (region/city), only city in default. * -n count: max hours (default: 10) * -f format: output format (using '+output_fmt' of date(1)) * -t start: set the start time instead of current time. (see below) * -v: show version of tzdiff. * -H: became the scripting mode. Fields are explicitly separated by single tab instead of an arbitrary space. * -HH: became the scripting mode without timzone name. * -N: display without local timezone. ### Format of "-t start" option If your system has the GNU date, you can use the flexible format. Otherwise, specify as 'YYYY-mm-ddTHH:MM', 'YYYYmmddTHHMM' or 'YYYYmmddTHHMM' and adding 'Z' at the end makes it UTC. ## Install ### FreeBSD If you are pkg user, you can easy to install tzdiff like this. ``` $ sudo pkg install tzdiff ``` Of course, it is already in ports. You can easy to play with ports. ### NetBSD and pkgsrs Tzdiff is registered in pkgsrc. If you use pkgsrc, you can easily install it. ### macOS If you are MacPorts user, you can easy to install tzdiff. ``` $ sudo port install tzdiff ``` If you are Homebrew user, you can install with personal tap. ``` $ brew tap belgianbeer/minmin $ brew install tzdiff ``` (as of 2023-07): Tzdiff is applying for registration with HomeBrew. If this application goes through, you might be better off with just "brew install tzdiff". ### Debian / Ubuntu Tzdiff is registerd in debian pkg, you can easy to install by apt command. ``` $ sudo apt update $ sudo apt install tzdiff ``` ## Examples In these examples, author's timezone is JST. ``` $ tzdiff America/Los_Angeles Los_Angeles 2023-06-13 21:08 PDT 2023-06-14 13:08 JST 2023-06-13 22:08 PDT 2023-06-14 14:08 JST 2023-06-13 23:08 PDT 2023-06-14 15:08 JST 2023-06-14 00:08 PDT 2023-06-14 16:08 JST 2023-06-14 01:08 PDT 2023-06-14 17:08 JST 2023-06-14 02:08 PDT 2023-06-14 18:08 JST 2023-06-14 03:08 PDT 2023-06-14 19:08 JST 2023-06-14 04:08 PDT 2023-06-14 20:08 JST 2023-06-14 05:08 PDT 2023-06-14 21:08 JST 2023-06-14 06:08 PDT 2023-06-14 22:08 JST ``` Tzdiff supports TIMEZONE's completion. tzdiff looks for timezone information in "/usr/share/zoneinfo". For example, ``` $ tzdiff Lon # enter RETURN instead of TAB Arctic/Longyearbyen Europe/London $ tzdiff Lond London 2023-06-14 05:13 BST 2023-06-14 13:13 JST 2023-06-14 06:13 BST 2023-06-14 14:13 JST 2023-06-14 07:13 BST 2023-06-14 15:13 JST 2023-06-14 08:13 BST 2023-06-14 16:13 JST 2023-06-14 09:13 BST 2023-06-14 17:13 JST 2023-06-14 10:13 BST 2023-06-14 18:13 JST 2023-06-14 11:13 BST 2023-06-14 19:13 JST 2023-06-14 12:13 BST 2023-06-14 20:13 JST 2023-06-14 13:13 BST 2023-06-14 21:13 JST 2023-06-14 14:13 BST 2023-06-14 22:13 JST $ tzdiff New_ 0 5 New_York 2023-06-14 00:00 EDT 2023-06-14 13:00 JST 2023-06-14 01:00 EDT 2023-06-14 14:00 JST 2023-06-14 02:00 EDT 2023-06-14 15:00 JST 2023-06-14 03:00 EDT 2023-06-14 16:00 JST 2023-06-14 04:00 EDT 2023-06-14 17:00 JST ``` It is easy to check changes from daylight saving time to standard time. ``` $ tzdiff -N -t 2023-11-05T03:00Z Tok Brus New_ Los Tokyo Brussels New_York Los_Angeles 2023-11-05 12:00 JST 2023-11-05 04:00 CET 2023-11-04 23:00 EDT 2023-11-04 20:00 PDT 2023-11-05 13:00 JST 2023-11-05 05:00 CET 2023-11-05 00:00 EDT 2023-11-04 21:00 PDT 2023-11-05 14:00 JST 2023-11-05 06:00 CET 2023-11-05 01:00 EDT 2023-11-04 22:00 PDT 2023-11-05 15:00 JST 2023-11-05 07:00 CET 2023-11-05 01:00 EST 2023-11-04 23:00 PDT 2023-11-05 16:00 JST 2023-11-05 08:00 CET 2023-11-05 02:00 EST 2023-11-05 00:00 PDT 2023-11-05 17:00 JST 2023-11-05 09:00 CET 2023-11-05 03:00 EST 2023-11-05 01:00 PDT 2023-11-05 18:00 JST 2023-11-05 10:00 CET 2023-11-05 04:00 EST 2023-11-05 01:00 PST 2023-11-05 19:00 JST 2023-11-05 11:00 CET 2023-11-05 05:00 EST 2023-11-05 02:00 PST 2023-11-05 20:00 JST 2023-11-05 12:00 CET 2023-11-05 06:00 EST 2023-11-05 03:00 PST 2023-11-05 21:00 JST 2023-11-05 13:00 CET 2023-11-05 07:00 EST 2023-11-05 04:00 PST ``` Specifying "0" and "24" at the end is convenient when you want to know what time 19:00 is your time in a foreign country. It is quicker to display 24 hours than to think. ``` $ tzdiff Brus 24 0 Brussels 2023-06-14 06:00 CEST 2023-06-14 13:00 JST 2023-06-14 07:00 CEST 2023-06-14 14:00 JST 2023-06-14 08:00 CEST 2023-06-14 15:00 JST 2023-06-14 09:00 CEST 2023-06-14 16:00 JST 2023-06-14 10:00 CEST 2023-06-14 17:00 JST 2023-06-14 11:00 CEST 2023-06-14 18:00 JST 2023-06-14 12:00 CEST 2023-06-14 19:00 JST 2023-06-14 13:00 CEST 2023-06-14 20:00 JST 2023-06-14 14:00 CEST 2023-06-14 21:00 JST 2023-06-14 15:00 CEST 2023-06-14 22:00 JST 2023-06-14 16:00 CEST 2023-06-14 23:00 JST 2023-06-14 17:00 CEST 2023-06-15 00:00 JST 2023-06-14 18:00 CEST 2023-06-15 01:00 JST 2023-06-14 19:00 CEST 2023-06-15 02:00 JST <= This line is the result you want. 2023-06-14 20:00 CEST 2023-06-15 03:00 JST 2023-06-14 21:00 CEST 2023-06-15 04:00 JST 2023-06-14 22:00 CEST 2023-06-15 05:00 JST 2023-06-14 23:00 CEST 2023-06-15 06:00 JST 2023-06-15 00:00 CEST 2023-06-15 07:00 JST 2023-06-15 01:00 CEST 2023-06-15 08:00 JST 2023-06-15 02:00 CEST 2023-06-15 09:00 JST 2023-06-15 03:00 CEST 2023-06-15 10:00 JST 2023-06-15 04:00 CEST 2023-06-15 11:00 JST 2023-06-15 05:00 CEST 2023-06-15 12:00 JST ``` ## Platform Tzdiff works with the following operating systems. * macOS / FreeBSD / NetBSD / OpenBSD (It may work on DragonFly BSD.) * Debian / Ubuntu / CentOS and many Linux distros * Windows subsystem for Linux ## Change Log * 2023-07-17 1.2 Name changed to city only. Start time can set in UTC. * 2019-03-05 1.1 Scripting mode has been added. * 2018-12-20 1.0 Manual of tzdiff(1) has been added. * 2018-09-04 0.9 Command name changed from 'timediff' to 'tzdiff'. * 2018-08-17 0.8 more useful. * 2015-08-29 0.1 Initial release. tzdiff-1.2/tzdiff000077500000000000000000000141321445571707600140770ustar00rootroot00000000000000#!/bin/sh # # tzdiff - displays timezone differences with localtime. # # Copyright (c) 2016 - 2023 Masato Minda # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $Id: tzdiff,v 1.53 2023/07/17 08:00:07 minmin Exp $ version=1.2 format='%F %R %Z' max=10 __check_match () { if [ `echo ${1} | wc -w` -eq 1 ]; then return 0 fi ls -dF ${1} exit 1 } __set_zoneinfo () { case "${1}" in *\**) __check_match "${1}*" zi=`echo ${1}*` ;; *) zi=${1} ;; esac while [ ! -f ${zi} ]; do if [ -d ${zi} ]; then ls -dF ${zi}/* exit 1 fi __check_match "${zi}*" zi=`echo ${zi}*` if [ ! -e ${zi} ]; then __check_match "*/${zi}" zi=`echo */${zi}` if [ ! -e ${zi} ]; then __check_match "*/${zi}" zi=`echo */${zi}` if [ ! -e ${zi} ]; then ls -F exit 2 fi fi fi done case ${zi} in */*) city=${zi##*/} ;; *) city=${zi} ;; esac } __make_column () { if [ ${H_flag} -ne 0 ]; then echo "%s" return fi _ltd="$(__date_with_format ${tis} ${1})" if [ -n "${2}" ]; then if [ ${#2} -gt ${#_ltd} ]; then echo "%-${#2}s" else echo "%-${#_ltd}s" fi else if [ ${#1} -gt ${#_ltd} ]; then echo "%-${#1}s" else echo "%-${#_ltd}s" fi fi } __usage () { cat <<- EOT >&2 Usage: ${0##*/} [-0lvHN] [-n count] [-f format] [-t start] timezone [timezone ...] [count] [0] -0: round down to hour -n: max hours (default: 10) -l: display full timezone name, only city in default -f: output format (using '+output_fmt' of 'date' command) -t: specify the start time (YYYY-mm-ddTHH:MM[Z], etc...) -v: show version. -H: scripting mode (with timezone name) -HH: scripting mode (without timezone name) -N: without localtime EOT exit 2 } __version () { echo "${0##*/} ${version}" exit 0 } __setup () { if date --version >/dev/null 2>&1; then # for GNU date g_date=YES __date_with_format () { if [ $# -eq 2 ]; then TZ=:${2} date --date=@${1} +"${format}" else date --date=@${1} +"${format}" fi } else # for traditional date __date_with_format () { if [ $# -eq 2 ]; then TZ=:${2} date -j -r ${1} +"${format}" else date -j -r ${1} +"${format}" fi } fi } __set_time () { if [ -n "${st}" ]; then if [ -n "${g_date}" ]; then tis=`date --date="${st}" +%s` || exit else case "${st}" in [0-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]T[012][0-9]:[0-5][0-9] | \ [0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]T[012][0-9][0-5][0-9] | \ [0-9][0-9][0-9][0-9][01][0-9][0-3][0-9][012][0-9][0-5][0-9] ) # COMMAND_MODE is a macOS-specific environment variable. # See compat(5) on macOS. tis=`COMMAND_MODE=legacy date -j +%s $(echo ${st} | tr -d 'T:-')` || exit ;; [0-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]T[012][0-9]:[0-5][0-9]Z | \ [0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]T[012][0-9][0-5][0-9]Z | \ [0-9][0-9][0-9][0-9][01][0-9][0-3][0-9][012][0-9][0-5][0-9]Z ) tis=`COMMAND_MODE=legacy TZ=UTC date -j +%s $(echo ${st} | tr -d 'TZ:-')` || exit ;; *) __usage ;; esac fi else tis=`date +%s` fi if [ x${zero_flag} = x"YES" ]; then tis=$(( (${tis} / 3600) * 3600)) # round down to hour fi } # ----- begin tzdiff ----- cd /usr/share/zoneinfo || exit __setup H_flag=0 while getopts '0hlvHNn:f:t:' cmd_arg; do case "${cmd_arg}" in 0) zero_flag=YES ;; l) l_flag=YES ;; n) max=${OPTARG} ;; f) format="${OPTARG}" ;; t) st=${OPTARG} ;; v) __version ;; H) H_flag=$((H_flag + 1)) ;; N) N_flag=YES ;; h|*) __usage ;; esac done shift $((OPTIND - 1)) fs=' ' # 3 spaces [ ${H_flag} -ne 0 ] && fs=' ' # TAB if [ $# -eq 0 ]; then ls -F exit fi id=0 while [ $# -gt 0 ]; do case $1 in [0-9]*) if [ ${1} -eq 0 ]; then zero_flag=YES else max=${1} fi ;; *) __set_zoneinfo "${1}" eval tz${id}=${zi} eval city${id}=${city} id=$((id + 1)) ;; esac shift done if [ ${id} -eq 0 ]; then __usage fi __set_time # make format i=0 while [ ${i} -lt ${id} ]; do eval tz=\$tz${i} if [ -n "${l_flag}" ]; then eval fmt${i}=$(__make_column ${tz}) else eval city=\$city${i} eval fmt${i}=$(__make_column ${tz} ${city}) fi i=$((i + 1)) done # print location if [ ${H_flag} -lt 2 ]; then i=0 while [ ${i} -lt ${id} ]; do eval tz=\$tz${i} eval city=\$city${i} eval fmt=\$fmt${i} i=$((i + 1)) if [ ${i} -eq ${id} ]; then if [ -n "${l_flag}" ]; then printf "%s\n" "${tz}" else printf "%s\n" "${city}" fi else if [ -n "${l_flag}" ]; then printf "${fmt}${fs}" "${tz}" else printf "${fmt}${fs}" "${city}" fi fi done fi # print time j=0 while [ ${j} -lt ${max} ]; do i=0 while [ ${i} -lt ${id} ]; do eval tz=\$tz${i} eval fmt=\$fmt${i} printf "${fmt}" "$(__date_with_format ${tis} ${tz})" i=$((i + 1)) [ -n "${N_flag}" -a ${i} -eq ${id} ] || printf "${fs}" done if [ -z "${N_flag}" ]; then __date_with_format ${tis} else echo fi tis=$((tis + 3600)) j=$((j + 1)) done tzdiff-1.2/tzdiff.1000066400000000000000000000106611445571707600142360ustar00rootroot00000000000000.\" .\" Copyright (c) 2016 - 2023 Masato Minda .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd Jul 17, 2023 .Dt TZDIFF 1 .Os .Sh NAME .Nm tzdiff .Nd displays timezone differences with localtime. .Sh SYNOPSIS .Nm .Op Fl 0lvHN .Op Fl n Ar count .Op Fl f Ar format .Op Fl t Ar start timzone .Op timezone ... .Op count .Op 0 .Sh DESCRIPTION The .Nm utility displays the localtime of the designated timezone and yours. .Pp The .Nm utility needs at least one of timezone name, such as .Dq Asia/Tokyo . If the argument is .Dq Asia then .Nm displays the timezones of Asia. You can easy to choose it from the result. .Pp The .Nm supports the complition with name of timezone for useful. For example, .Dq Tok means .Dq Asia/Tokyo . .Pp The options are as follows: .Bl -tag -width Ds .It Fl h Show usage. .It Fl 0 Round down to hour. 0(zero) may be specified as the last argument. .It Fl l Display full timezone name (region/city), only city in default. .It Fl n Ar count Number of hours. Default is 10. It may be specified as the last argument. .It Fl f Ar format Output format of time. It uses output format of .Xr date 1 .It Fl t Ar start Specify the start time. For the GNU date command, you can specify a flexible format. Otherwise, it supports one of "YYYY-mm-ddTHH:HH[Z]", "YYYYmmddTHHMM[Z]" or "YYYYmmddHHMM[Z]", adding "Z" means UTC. .It Fl v Show version of tzdiff. .It Fl H Scripting mode with timezone name. In scripting mode, field separator is TAB instead of space. .It Fl HH Scripting mode without timezone name. .It Fl N Display without local timezone. .El .Sh EXAMPLES These exsamples are in JST. .Pp The command: .Pp .Dl tzdiff .Pp will display the result of .Dq "ls -F /usr/share/zoneinfo" : .Bd -literal -offset indent Africa/ Australia/ Etc/ MST WET America/ CET Europe/ MST7MDT posixrules --- snip --- snip --- snip --- Asia/ EST Indian/ SystemV/ Atlantic/ EST5EDT MET UTC .Ed .Pp The command: .Pp .Dl "tzdiff Eu" .Pp will display the result of .Dq "ls -F /usr/share/zoneinfo/Europe" : .Bd -literal -offset indent Europe/Amsterdam Europe/Kiev Europe/Sarajevo Europe/Andorra Europe/Kirov Europe/Saratov --- snip --- snip --- snip --- Europe/Jersey Europe/Samara Europe/Kaliningrad Europe/San_Marino .Ed .Pp The command: .Pp .Dl "tzdiff Europe/Amsterdam" .Pp will display the time of CET and localtime.: .Pp .Bd -literal -offset indent Amsterdam 2018-12-19 14:52 CET 2018-12-19 22:52 JST 2018-12-19 15:52 CET 2018-12-19 23:52 JST --- snip --- snip --- snip --- 2018-12-19 22:52 CET 2018-12-20 06:52 JST 2018-12-19 23:52 CET 2018-12-20 07:52 JST .Ed .Pp The command: .Pp .Dl "tzdiff Lond New_ 0 3" .Pp will display: .Bd -literal -offset indent London New_York 2018-12-20 01:00 GMT 2018-12-19 20:00 EST 2018-12-20 10:00 JST 2018-12-20 02:00 GMT 2018-12-19 21:00 EST 2018-12-20 11:00 JST 2018-12-20 03:00 GMT 2018-12-19 22:00 EST 2018-12-20 12:00 JST .Ed .Sh SEE ALSO .Xr date 1 , .Xr strftime 3 , .Xr strptime 3 .Pp .Nm on Github: https://github.com/belgianbeer/tzdiff .Sh AUTHOR Written by .An Masato Minda