hroptatyr / dateutils

nifty command line date and time utilities; fast date calculations and conversion in the shell
http://www.fresse.org/dateutils/
Other
609 stars 40 forks source link

DateDiff shows different results depending on the format #108

Open lamyergeier opened 4 years ago

lamyergeier commented 4 years ago
   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!

hroptatyr commented 4 years ago

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