]> zdv2.bktei.com Git - BK-2020-03.git/blobdiff - user/bkdatev
fix(user/bkdatev):Fix --date='' functionality for right/UTC
[BK-2020-03.git] / user / bkdatev
index 3ab8c3bf1e47f91e3e67e1307cd716cb95a41e5e..fb0b96c2588d98aafbcdc7ec66eec25962e01454 100755 (executable)
@@ -2,8 +2,8 @@
 # Desc: Baltakatei's verbose date command
 # Usage: bkdatev [args]
 # Example: bkdatev --date="2001-09-11T09:02:59-04"
 # Desc: Baltakatei's verbose date command
 # Usage: bkdatev [args]
 # Example: bkdatev --date="2001-09-11T09:02:59-04"
-# Version: 1.0.2
-# Depends: GNU Coreutils 8.32, Bash 3.2.57
+# Version: 1.0.4
+# Depends: GNU Coreutils 8.32, Bash 3.2.57, tzdata-legacy
 # Ref/Attrib: [1] "ISO 8601". Wikipedia. https://en.wikipedia.org/wiki/ISO_8601
 #             [2] "Changing the Locale in Wine" https://stackoverflow.com/a/16428951
 #             [3] "Shanghai vs Beijing" https://bugs.launchpad.net/ubuntu/+source/libgweather/+bug/228554
 # Ref/Attrib: [1] "ISO 8601". Wikipedia. https://en.wikipedia.org/wiki/ISO_8601
 #             [2] "Changing the Locale in Wine" https://stackoverflow.com/a/16428951
 #             [3] "Shanghai vs Beijing" https://bugs.launchpad.net/ubuntu/+source/libgweather/+bug/228554
@@ -146,9 +146,14 @@ main() {
     (
         export TZ=UTC;
         id="UTC";
     (
         export TZ=UTC;
         id="UTC";
-        date_string="$(date -Is)";
-        right_epoch="$(TZ=right/UTC date --date="$date_string" +%s;)"; # see [4]
-        fs_3="+%s seconds (${right_epoch} with leap seconds) since 1970-01-01T00:00+00";
+        path_right_tz="/usr/share/zoneinfo/right/UTC";
+        if [[ -f "$path_right_tz" ]]; then
+            date_string="$(date -Is "$@"; )";
+            right_epoch="$(TZ=right/UTC date --date="$date_string" +%s;)"; # see [4]
+            fs_3="+%s POSIX seconds (${right_epoch} real) since 1970-01-01T00:00+00";
+        else
+            fs_3="+%s POSIX seconds since 1970-01-01T00:00+00";
+        fi;
         print_dateline "$@";
     ); line_sep;
 
         print_dateline "$@";
     ); line_sep;