#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/time-days days-count () { local beg=$1 local end=$2 local days=$(( $(dateutils.ddiff $beg $end -f "%d") + 1 )) echo "$beg -> $end: $days days" } alias days=days-count days-to () { local beg local end case $# in (1) beg=today ; end=$1 ;; (2) beg=$1 ; end=$2 ;; esac local days local time days=$(dateutils.ddiff $beg $end -f '%d') days_wo=$(( $days - 1 )) (( $days_wo < 0 )) && days_wo=0 time=$(dateutils.ddiff $beg $end \ -f "%Yy %mm %dd ($days days) [$days_wo without]") echo $time } add-16 () { local beg=${1:-today} local days=${2:-16} local i for ((i=0; $i < 3; i++)); do dateutils.dadd $beg $(( $i*$days )) done } add-days () { local beg local days case $# in (1) beg=today ; days=$1 ;; (2) beg=$1 ; days=$2 ;; (*) local fun=$funcstack[1] ; echo "$fun input error: provide 1 or 2 arguments\n" \ "\t $ $fun FROM TIME\n" \ "\t $ $fun TIME # with FROM implicitly = TODAY\n" >&2 ; return esac dateutils.dadd $beg $days }