GNU bug report logs -
#55401
date man page
Previous Next
Full log
Message #8 received at 55401 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 13/05/2022 20:10, t0th wrote:
> Man page of date command should make explicit that -d and -r options are
> mutually exclusive.
Right. More accurately, we might have a sentence to say that:
"All options to specify the date to display are mutually exclusive.
I.e.: --date, --file, --reference, --resolution".
However...
> date -d -3 minutes -r tmp.txt "+%Y%m%d_%H%M"
> date: the options to specify dates for printing are mutually exclusive
As you've seen, one might expect to be able to combine, as -d can be relative.
So theoretically we could support this (with the attached),
to honor the relative adjustment, but give precedence to a non relative date.
$ src/date -r src/ls.c -d '-3 minutes'
Fri 15 Apr 2022 16:30:53 IST
$ src/date -r src/ls.c -d '1/1/2022'
Sat 01 Jan 2022 00:00:00 GMT
In fact touch(1) behaves like this, which suggests date(1) should also.
From the info docs for the touch --reference option:
"--reference
Use the times of the reference FILE instead of the current time.
If this option is combined with the --date=TIME
(-d TIME) option, the reference FILES's time is
the origin for any relative TIMEs given, but is otherwise ignored."
BTW, one might also expect that multiple -d options might combine like this,
however currently we silently ignore multiple -d (or -s) options.
The attached also at least warns about this with --debug:
$ date --debug -d '15/4/2022' -d '-3 minutes'
date: discarding previous -d: ‘15/4/2022’
date: parsed relative part: -3 minutes
...
cheers,
Pádraig
[date-d-r.patch (text/x-patch, attachment)]
This bug report was last modified 2 years and 335 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.