dateutils icon indicating copy to clipboard operation
dateutils copied to clipboard

DateDiff shows different results depending on the format

Open lamyergeier opened this issue 5 years ago • 1 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!

lamyergeier avatar Apr 16 '20 15:04 lamyergeier

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

hroptatyr avatar Apr 20 '20 03:04 hroptatyr