|
From: | Michael Stone |
Subject: | Re: How to calculate date relative to another date? |
Date: | Wed, 22 May 2019 10:41:52 -0400 |
User-agent: | NeoMutt/20170113 (1.7.2) |
On Wed, May 22, 2019 at 06:44:40AM -0400, Steeve McCauley wrote:
--iso seems to be an undocumented equivalent to the --iso-8601 date format, that gives you YYYY-MM-DD as the default format. You seem to have fallen on a bug in that either, 1) date string is corrupt and doesn't emit an error 2) date string is correct but fails to generate a correct result According to the man page it is fully documented in the "info" documentation. From what I can tell the more complex relative date string (4 years 11 months ago) is not supported, https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html#Relative-items-in-date-strings It would be pretty awesome if one could specify "4 years 11 months 3 days 4 hours and 7 minutes ago" but that seems not possible. In your case I also tried "4 years 11 months from 2018-05" but that just failed.
In general my advice is to just avoid the date parsing entirely, it will never, ever do what you predict. If you find something that happens to work, just copy and paste it and never change it. It would be nice if there were a new, simple and predictable grammer option in date(1) (abandon the natural language guessing) but nobody has ever wanted to do the work. :)
You might try "2018-05-01 59 months ago", but I'd suggest using a python module or somesuch with a more regular grammar if you want something maintainable in the long term.
[Prev in Thread] | Current Thread | [Next in Thread] |