X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/79cb35dcab82101c36b5035f242d39d0e1593767..dcd9d7e32a746f882a2b46fb57c27e29dca9b932:/user/bkdatev diff --git a/user/bkdatev b/user/bkdatev old mode 100644 new mode 100755 index 1b80477..cea6883 --- a/user/bkdatev +++ b/user/bkdatev @@ -2,7 +2,7 @@ # Desc: Baltakatei's verbose date command # Usage: bkdatev [args] # Example: bkdatev --date="2001-09-11T09:02:59-04" -# Version: 0.3.2 +# Version: 1.0.0 # Depends: GNU Coreutils 8.32, Bash 3.2.57 # Ref/Attrib: [1] "ISO 8601". Wikipedia. https://en.wikipedia.org/wiki/ISO_8601 # [2] "Changing the Locale in Wine" https://stackoverflow.com/a/16428951 @@ -75,12 +75,13 @@ get_tz_offset() { # Desc: Get from 'date' the timezone UTC offset in a way # compatible with both GNU Coreutils and BSD versions. # Input: env var: TZ (time zone for date; e.g. 'America/Denver') + # args: $@ # passed onto `date` # Depends: date (GNU Coreutils 8.32 or BSD), rev local ntz ntz ntz_out; local last2; # Get numeric time zone string in way compatible with GNU Coreutils and BSD - ntz="$(date "+%z")"; # e.g. "+0530" + ntz="$(date "+%z" "$@")"; # e.g. "+0530" # Check if last two characters are trailing zeros that can be removed. last2="${ntz:3:2}"; # assumes $ntz is 5 characters (i.e. "±HHMM") @@ -103,7 +104,7 @@ print_dateline() { # var: $fs_1 # var: $fs_2 # var: $fs_3 - # args: $@ + # args: $@ # passed on to `date` # env var: TZ (time zone for date; e.g. 'America/Denver') # Output: stdout # Depends: printf, date @@ -115,10 +116,10 @@ print_dateline() { s_2="$(date "$@" "$fs_1")"; # ISO-8601 without numeric timezone s_3="$(date "$@" "$fs_2")"; # Alternate ISO-8601 expressions s_4="$(date "$@" "$fs_3")"; # locale-specific date strings - + # Append numeric timezone to $s_2 with appropriate format # (e.g. '-07' for 'Arizona', '+05:45' for 'Asia/Kathmandu') - s_2_tz="$(get_tz_offset)"; + s_2_tz="$(get_tz_offset "$@")"; s_2="$( printf "%s%s" "$s_2" "$s_2_tz" )"; printf "%-10.10s %-25.25s (%-20.20s) (%s)" "$s_1" "$s_2" "$s_3" "$s_4"; @@ -260,6 +261,14 @@ main() { print_dateline "$@"; ); line_sep; + # Helsinki, Finland + ( + export TZ=Europe/Helsinki; + export LANG="fi_FI.UTF8"; + id="HELSINKI"; + print_dateline "$@"; + ); line_sep; + # Cairo, Egypt ( export TZ=Africa/Cairo; @@ -268,6 +277,22 @@ main() { print_dateline "$@"; ); line_sep; + # Gaza City, Palestine (pop. (2017): 590,481) + ( + export TZ=Asia/Gaza; + export LANG="ar_JO.UTF-8"; # ar_PS is missing as of 2023-10-18, using ar_JO as closest substitute. + id="GAZA"; + print_dateline "$@"; + ); line_sep; + + # Tel Aviv, Israel (pop. (2021): 467,875) + ( + export TZ=Asia/Tel_Aviv; + export LANG="he_IL.UTF-8"; + id="TEL AVIV"; + print_dateline "$@"; + ); line_sep; + # Athens (pop. (2020): 3,526,887) ( export TZ=Europe/Athens;