diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-01-09 04:09:59 -0800 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-01-09 04:09:59 -0800 |
commit | 5eb0dbf136a9ad582192e003b7573a080514f063 (patch) | |
tree | 84d3a44749b1b2db50b39504ab7690a15b699e8d /dateft |
init from config_local_arch personal shell scripts
git log history see https://git.flylightning.xyz/config_local_arch/tree/home/xyz/.local/bin?id=d266c511cffb7eeb20bf1e4610d9d32557b7d0e6
Diffstat (limited to 'dateft')
-rwxr-xr-x | dateft | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#!/bin/sh +# DATE From To + +while getopts cfF:t:T: opt; do + case $opt in + c) tz_from="Asia/Shanghai";; + f) tz_from="$(tzselect)";; + F) tz_from="$OPTARG";; + # one extra ',' at the end will not let `for tz in ...` loop one extra time? + t) for i in $(seq "$OPTARG"); do + tz_to="$(tzselect),$tz_to" + done;; + T) tz_to="$OPTARG,$tz_to";; + \?) exit 1;; + esac +done +shift $((OPTIND-1)) + +time_from="TZ=\"${tz_from:-$(readlink /etc/localtime | sed 's#.*/\(.*/.*\)$#\1#')}\" ${1:-now}" + +date -d "$time_from" +TZ="Asia/Shanghai" date -d "$time_from" +date -d "$time_from" -u +date -d "$time_from" +%s +[ "$tz_from" ] && [ "$tz_from" != "Asia/Shanghai" ] && TZ="$tz_from" date -d "$time_from" +IFS=',' +for tz in $tz_to; do + TZ="$tz" date -d "$time_from" +done |