datetimehelper.sh
390 Bytes
function tstodate() {
[[ $# -eq 0 ]] && return 1
date -d @${1} +%Y-%m-%d
}
function extracttime() {
local OIFS=${IFS}
if [[ $# -eq 0 || -z $1 ]]
then
TIMEKEY=""
TIME="00:00:00"
else
IFS=:
set -- $=1
IFS=${OIFS}
TIMEKEY=$1
TIME=$(printf "%02d:%02d:%02d" ${2:-0} ${3:-0} $4)
fi
}
# vim: set et ts=4 sw=4: