datetimehelper.sh 476 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
}

function formattime() {
    days=${1%%:*}
    printf "%03dd %s" ${days:-0} ${1#*:}
}

# vim: set et ts=4 sw=4: