diff options
| author | Benjamin <benjamin@cometsong.net> | 2021-06-25 11:44:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-25 16:44:49 +0100 |
| commit | 7e3618c5140f24ce3c3842b5e3efcf7012e536e0 (patch) | |
| tree | d8fe5a9e425cbf79b678368f8592fb0099961195 /rsync_tmbackup.sh | |
| parent | 30339af32bc6b9e8cf31ed856f4d4f389c8ac044 (diff) | |
mod `fn_parse_date`, mismatch version/syntax of `date` (#240)
* mod fn_parse_date
combine identical cases, rm oft-failing darwin, subproc syntax
* repair my default spaces to not expand tabs
Diffstat (limited to 'rsync_tmbackup.sh')
| -rwxr-xr-x | rsync_tmbackup.sh | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 0eb269b..b8fe0c0 100755 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -60,19 +60,20 @@ fn_display_usage() { fn_parse_date() { # Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch. case "$OSTYPE" in - linux*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; - cygwin*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; - netbsd*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; - darwin8*) yy=`expr ${1:0:4}` - mm=`expr ${1:5:2} - 1` - dd=`expr ${1:8:2}` - hh=`expr ${1:11:2}` - mi=`expr ${1:13:2}` - ss=`expr ${1:15:2}` - # Because under MacOS X Tiger 'date -j' doesn't work, we do this: - perl -e 'use Time::Local; print timelocal('$ss','$mi','$hh','$dd','$mm','$yy'),"\n";' ;; - darwin*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; + linux*|cygwin*|netbsd*) + date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;; FreeBSD*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; + darwin*) + # Under MacOS X Tiger + # Or with GNU 'coreutils' installed (by homebrew) + # 'date -j' doesn't work, so we do this: + yy=$(expr ${1:0:4}) + mm=$(expr ${1:5:2} - 1) + dd=$(expr ${1:8:2}) + hh=$(expr ${1:11:2}) + mi=$(expr ${1:13:2}) + ss=$(expr ${1:15:2}) + perl -e 'use Time::Local; print timelocal('$ss','$mi','$hh','$dd','$mm','$yy'),"\n";' ;; esac } |
