[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55401: date man page

From: Pádraig Brady
Subject: bug#55401: date man page
Date: Sat, 14 May 2022 01:42:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Thunderbird/97.0

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".

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:

  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


Attachment: date-d-r.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]