add script to calculate the snaplock time
This commit is contained in:
parent
5acad8f30d
commit
8d6fd3f388
30
gp-scripts/snaplock-time.sh
Normal file
30
gp-scripts/snaplock-time.sh
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# 1970-01-01 00:00:00 equals to 2038-01-19 03:14:08
|
||||||
|
# snaplock ends 2002-12-31 23:59:59 which is 2071-01-19 03:14:07
|
||||||
|
SNAPLOCK_UPPER="2038-01-19 03:14:08"
|
||||||
|
SNAPLOCK_UPPER_EPOCH=$(date --utc --date="${SNAPLOCK_UPPER}" +%s)
|
||||||
|
SNAPLOCK_LOWER="2002-12-31 23:59:59"
|
||||||
|
SNAPLOCK_LOWER_EPOCH=$(date --utc --date="${SNAPLOCK_LOWER}" +%s)
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "${@}" == "" ]]; then
|
||||||
|
echo "Please specify a date to convert"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DATE="$@"
|
||||||
|
if ! DATE_EPOCH=$(date --utc --date="${DATE}" +%s); then
|
||||||
|
echo "Could not convert \"${DATE}\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${DATE_EPOCH} -ge ${SNAPLOCK_UPPER_EPOCH} ]; then
|
||||||
|
SNAPLOCK_DATE_EPOCH=$((DATE_EPOCH-SNAPLOCK_UPPER_EPOCH))
|
||||||
|
elif [ ${DATE_EPOCH} -le ${SNAPLOCK_LOWER_EPOCH} ]; then
|
||||||
|
SNAPLOCK_DATE_EPOCH=$((DATE_EPOCH+SNAPLOCK_UPPER_EPOCH))
|
||||||
|
else
|
||||||
|
SNAPLOCK_DATE_EPOCH="${DATE_EPOCH}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
date --utc --date="@${SNAPLOCK_DATE_EPOCH}"
|
||||||
Loading…
Reference in New Issue
Block a user