Created
June 27, 2016 21:03
-
-
Save tst2005/aeef2d0bad6ef1904c06fb1a8b4589b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://en.wikipedia.org/wiki/ISO_8601 | |
date_to_iso8601() { | |
date ${1:+-d "$1"} -u +'%Y%m%dT%H%M%SZ' | |
} | |
iso8601_to_date() { | |
local yyyymmdd="${1%%T*}" | |
local hhmmss="${1#*T}" | |
hhmmss="${hhmmss%Z*}" | |
local mmss="${hhmmss#??}" | |
shift | |
date -d "${yyyymmdd} ${hhmmss%%????}:${mmss%??}:${mmss#??} +0000" "$@" | |
} | |
iso8601_to_date "$(date_to_iso8601 "$(iso8601_to_date "$(date_to_iso8601)")")" -u | |
date -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment