mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-09 14:06:58 +02:00
Merge pull request #552 from crawford/core_date
core_date: add help message
This commit is contained in:
commit
05c491d333
31
core_date
31
core_date
@ -7,7 +7,29 @@
|
||||
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
|
||||
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
||||
|
||||
if [[ "$1" == "-v" ]]; then
|
||||
USAGE="USAGE: $0 [-v] [date flags]
|
||||
|
||||
This script calculates the date given the CoreOS major version or calculates
|
||||
the version given a date.
|
||||
|
||||
Examples:
|
||||
|
||||
$0 -v 1000
|
||||
Sun Mar 27 00:00:00 UTC 2016
|
||||
|
||||
$0 -v 1000 --iso-8601
|
||||
2016-03-27
|
||||
|
||||
$0 --date 'Jun 1, 2016'
|
||||
1066
|
||||
"
|
||||
|
||||
case "$1" in
|
||||
"-h")
|
||||
echo "$USAGE"
|
||||
;;
|
||||
|
||||
"-v")
|
||||
shift
|
||||
if [[ $# -ge 1 ]] && [[ "$1" != [-+]* ]]; then
|
||||
v="$1"
|
||||
@ -22,7 +44,10 @@ if [[ "$1" == "-v" ]]; then
|
||||
|
||||
export TZ=${TZ:=UTC}
|
||||
date -d @$(( (v * 86400) + COREOS_EPOCH )) "$@"
|
||||
else
|
||||
;;
|
||||
|
||||
*)
|
||||
t=$(date +%s "$@")
|
||||
echo $(( (t - COREOS_EPOCH) / 86400 ))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user