hroptatyr / dateutils

nifty command line date and time utilities; fast date calculations and conversion in the shell

Home Page:http://www.fresse.org/dateutils/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DateDiff shows different results depending on the format

lamyergeier opened this issue · comments

function DateDuration() {
 DateOther=${1:?"Enter a date in iso format. e.g. \$(date --iso-8601=seconds -d 'last mon')"}
 DateNow=$(date --iso-8601=seconds -d "now") # Current date in ISO Format

 datediff -f '%Y years, %m months, %d days, %H:%0M:%0S' "${DateNow}" "${DateOther}"
 datediff -f '%d days, %H:%0M:%0S' "${DateNow}" "${DateOther}"
 }
 ```

 ```bash
 $ DateDuration $(date --iso-8601=seconds -d 'last tue')
 -0 years, 0 months, 3 days, 6:23:34
 -2 days, 17:36:26
 ```

As can be seen the answers don't match!

Hi Anish,
good catch. Thanks for reporting this. A fix is in bd51663.