DateDiff shows different results depending on the format
lamyergeier opened this issue · comments
Lamyergeier commented
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!
Sebastian Freundt commented
Hi Anish,
good catch. Thanks for reporting this. A fix is in bd51663.