pax_global_header00006660000000000000000000000064134667463010014524gustar00rootroot0000000000000052 comment=c02e1fd71a0c99d4e0df4ca668f75a7d1923edab tzdiff-1.1.1/000077500000000000000000000000001346674630100130125ustar00rootroot00000000000000tzdiff-1.1.1/README.md000066400000000000000000000114471346674630100143000ustar00rootroot00000000000000# tzdiff Displays Timezone differences with localtime in CLI (shell script) ## Tzdiff or Timediff ? This command was originally "timediff". Now, it's "tzdiff" because of naming conflict. ## Usage tzdiff [-0] [-n count] [-f format] [-t time] 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 * -n count: max hours (default: 10) * -f format: output format (using '+output_fmt' of date(1)) * -t time: set the start time instead of current time. 'YYYY-mm-ddTHH:MM' or 'YYYYmmddTHHMM' is ok. * -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. ## 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. ### macOS If you are MacPorts user, you can easy to install tzdiff. $ sudo port install tzdiff If you are Homebrew user, you can install by personal tap. $ brew tap belgianbeer/minmin $ brew install tzdiff ### Debian / Ubuntu Currently, tzdiff become a debian pkg in progress. ( [tzdiff in Debin pkg](https://tracker.debian.org/pkg/tzdiff) ) In near future, it can easy to install by apt command. $ sudo apt update $ sudo apt install tzdiff ## Examples In these examples, author's timezone is JST. $ tzdiff Africa/ Australia/ Etc/ MST WET America/ CET Europe/ MST7MDT posixrules Antarctica/ CST6CDT Factory PST8PDT zone.tab Arctic/ EET HST Pacific/ Asia/ EST Indian/ SystemV/ Atlantic/ EST5EDT MET UTC $ tzdiff America/Los_Angeles America/Los_Angeles 2017-05-12 05:55 PDT 2017-05-12 21:55 JST 2017-05-12 06:55 PDT 2017-05-12 22:55 JST 2017-05-12 07:55 PDT 2017-05-12 23:55 JST 2017-05-12 08:55 PDT 2017-05-13 00:55 JST 2017-05-12 09:55 PDT 2017-05-13 01:55 JST 2017-05-12 10:55 PDT 2017-05-13 02:55 JST 2017-05-12 11:55 PDT 2017-05-13 03:55 JST 2017-05-12 12:55 PDT 2017-05-13 04:55 JST 2017-05-12 13:55 PDT 2017-05-13 05:55 JST 2017-05-12 14:55 PDT 2017-05-13 06:55 JST Tzdiff supports TIMEZONE's completion. For example, $ tzdiff Lon # enter RETURN instead of TAB Arctic/Longyearbyen Europe/London $ tzdiff Lond Europe/London 2017-05-31 07:10 BST 2017-05-31 15:10 JST 2017-05-31 08:10 BST 2017-05-31 16:10 JST 2017-05-31 09:10 BST 2017-05-31 17:10 JST 2017-05-31 10:10 BST 2017-05-31 18:10 JST 2017-05-31 11:10 BST 2017-05-31 19:10 JST 2017-05-31 12:10 BST 2017-05-31 20:10 JST 2017-05-31 13:10 BST 2017-05-31 21:10 JST 2017-05-31 14:10 BST 2017-05-31 22:10 JST 2017-05-31 15:10 BST 2017-05-31 23:10 JST 2017-05-31 16:10 BST 2017-06-01 00:10 JST $ tzdiff New_ 0 5 America/New_York 2017-05-12 08:00 EDT 2017-05-12 21:00 JST 2017-05-12 09:00 EDT 2017-05-12 22:00 JST 2017-05-12 10:00 EDT 2017-05-12 23:00 JST 2017-05-12 11:00 EDT 2017-05-13 00:00 JST 2017-05-12 12:00 EDT 2017-05-13 01:00 JST It is easy to check changes from daylight saving time to standard time $ tzdiff -t 2017-11-05T11:00 Los New_ Brus America/Los_Angeles America/New_York Europe/Brussels 2017-11-04 19:00 PDT 2017-11-04 22:00 EDT 2017-11-05 03:00 CET 2017-11-05 11:00 JST 2017-11-04 20:00 PDT 2017-11-04 23:00 EDT 2017-11-05 04:00 CET 2017-11-05 12:00 JST 2017-11-04 21:00 PDT 2017-11-05 00:00 EDT 2017-11-05 05:00 CET 2017-11-05 13:00 JST 2017-11-04 22:00 PDT 2017-11-05 01:00 EDT 2017-11-05 06:00 CET 2017-11-05 14:00 JST 2017-11-04 23:00 PDT 2017-11-05 01:00 EST 2017-11-05 07:00 CET 2017-11-05 15:00 JST 2017-11-05 00:00 PDT 2017-11-05 02:00 EST 2017-11-05 08:00 CET 2017-11-05 16:00 JST 2017-11-05 01:00 PDT 2017-11-05 03:00 EST 2017-11-05 09:00 CET 2017-11-05 17:00 JST 2017-11-05 01:00 PST 2017-11-05 04:00 EST 2017-11-05 10:00 CET 2017-11-05 18:00 JST 2017-11-05 02:00 PST 2017-11-05 05:00 EST 2017-11-05 11:00 CET 2017-11-05 19:00 JST 2017-11-05 03:00 PST 2017-11-05 06:00 EST 2017-11-05 12:00 CET 2017-11-05 20:00 JST 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 tzdiff-1.1.1/tzdiff000077500000000000000000000117341346674630100142340ustar00rootroot00000000000000#!/bin/sh # # tzdiff - displays timezone differences with localtime. # # Copyright (c) 2016 - 2018 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.51 2019/05/15 02:49:35 minmin Exp $ 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 } __make_column () { if [ ${H_flag} -ne 0 ]; then echo "%s" return fi local _ltz="${1}" local _ltd="$(__date_with_format ${ut} ${_ltz})" if [ ${#_ltz} -gt ${#_ltd} ]; then echo "%-${#_ltz}s" else echo "%-${#_ltd}s" fi } __usage () { cat <<- EOT >&2 Usage: ${0##*/} [-0] [-n count] [-f format] [-t time] timezone [timezone ...] [count] [0] -0: round down to hour -n: max hours (default: 10) -f: output format (using '+output_fmt' of 'date' command) -t: start time (YYYY-mm-ddThh:mm or YYYYmmddThhmm) -H: scripting mode (with timezone name) -HH: scripting mode (without timezone name) -N: without localtime EOT exit 2 } if date --version >/dev/null 2>&1; then # for GNU date __date_with_format () { if [ $# -eq 2 ]; then TZ=:${2} date --date=@${1} +"${format}" else date --date=@${1} +"${format}" fi } __date_parse () { date --date="${1}" +%s } else # for BSD date __date_with_format () { if [ $# -eq 2 ]; then TZ=:${2} date -j -r ${1} +"${format}" else date -j -r ${1} +"${format}" fi } case `uname -s` in FreeBSD|Darwin) __date_parse () { date -j -f %Y%m%dT%H%M $(echo ${1}| tr -d :-) +%s } ;; *) __date_parse () { # NetBSD / OpenBSD date -j +%s $(echo ${1} | tr -d 'T:-') } ;; esac fi cd /usr/share/zoneinfo || exit H_flag=0 while getopts '0hHNn:f:t:' cmd_arg do case "${cmd_arg}" in 0) zero_flag=YES ;; n) max=${OPTARG} ;; f) format="${OPTARG}" ;; t) nt=${OPTARG} ;; H) H_flag=$((H_flag + 1)) ;; N) N_flag=YES ;; h|*) __usage ;; esac done >&2 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} id=$((id + 1)) ;; esac shift done if [ ${id} -eq 0 ]; then __usage fi case "x${nt}" in x[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9] | x[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9]) ut=`__date_parse "${nt}"` || exit ;; x) ut=`date +%s`;; *) __usage;; esac if [ x${zero_flag} = x"YES" ]; then ut=$(( ( ${ut} / 3600 ) * 3600 )) # round down fi # make format i=0 while [ ${i} -lt ${id} ]; do eval tz=\$tz${i} eval fmt${i}=$(__make_column ${tz}) i=$((i + 1)) done # print timezone name if [ ${H_flag} -lt 2 ]; then i=0 while [ ${i} -lt ${id} ]; do eval tz=\$tz${i} eval fmt=\$fmt${i} i=$((i + 1)) if [ ${i} -eq ${id} ]; then printf "%s\n" "${tz}" else printf "${fmt}${fs}" "${tz}" 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 ${ut} ${tz})" i=$((i + 1)) [ ! -z "${N_flag}" -a ${i} -eq ${id} ] || printf "${fs}" done if [ -z "${N_flag}" ]; then __date_with_format ${ut} else echo fi ut=$((ut + 3600)) j=$((j + 1)) done tzdiff-1.1.1/tzdiff.1000066400000000000000000000103321346674630100143610ustar00rootroot00000000000000.\" .\" Copyright (c) 2016 - 2018 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 Dec 21, 2018 .Dt TZDIFF 1 .Os .Sh NAME .Nm tzdiff .Nd displays timezone differences with localtime. .Sh SYNOPSIS .Nm .Op Fl 0 .Op Fl n Ar count .Op Fl f Ar format .Op Fl t Ar time 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 0 Round down to hour. 0(zero) may be specified as the last argument. .It Fl n Ar count Number of hours. Default is 10. It may be specified as the last argument. .It Fl h Show usage. .It Fl f Ar fmt Output format of time. It uses output format of .Xr date 1 .It Fl t Ar arg Specify the start time. It supports one of .Dq YYYY-mm-ddThh:mm or .Dq YYYYmmddThhmm . .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 Europe/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 Europe/London America/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