#729952 /bin/date: date parsing inconsistencies

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
"Ph. Marek"
Date:
2026-05-30 03:07:01 UTC
Severity:
minor
#729952#5
Date:
2013-11-19 10:18:23 UTC
From:
To:
These work as expected:

$ date -d '1 hour'
Die Nov 19 11:21:35 CET 2013
$ date -d '0 hour'
Die Nov 19 10:21:37 CET 2013
$ date -d '1 hour ago'
Die Nov 19 09:21:40 CET 2013


This gives a wrong answer, and no parsing error:
$ date -d 'a hour ago'
Die Nov 19 11:21:44 CET 2013

It looks like single characters are parsed as hour offsets:
$ date -d 'a'
Die Nov 19 02:00:00 CET 2013
$ date -d 'b'
Die Nov 19 03:00:00 CET 2013
$ date -d 'c'
$ date -d 'h'
Die Nov 19 09:00:00 CET 2013
$ date -d 'o'
Mon Nov 18 23:00:00 CET 2013
$ date -d 'p'
Mon Nov 18 22:00:00 CET 2013

I couldn't find anything about that in the info documentation.


This would be a bit more correct, but gives an error:
$ date -d 'an hour ago'
date: invalid date 'an hour ago'


$ echo $TZ
Europe/Vienna
$ locale
LANG=de_AT.UTF-8
LANGUAGE=de_AT:de
LC_CTYPE="de_AT.UTF-8"
LC_NUMERIC="de_AT.UTF-8"
LC_TIME="de_AT.UTF-8"
LC_COLLATE="de_AT.UTF-8"
LC_MONETARY="de_AT.UTF-8"
LC_MESSAGES="de_AT.UTF-8"
LC_PAPER="de_AT.UTF-8"
LC_NAME="de_AT.UTF-8"
LC_ADDRESS="de_AT.UTF-8"
LC_TELEPHONE="de_AT.UTF-8"
LC_MEASUREMENT="de_AT.UTF-8"
LC_IDENTIFICATION="de_AT.UTF-8"
LC_ALL=

#729952#10
Date:
2013-11-21 19:16:05 UTC
From:
To:
The date parsing feature exists in Debian only for compatibility with
upstream. It is a complete misfeature, and I would prefer that it didn't
exist at all. In an ideal world the entire idea of trying to utilize a
natural language parser would be scrapped in favor of a simple and
regular grammar. Unfortunately, it is what it is. The only way to use
the feature is to experiment until you find something that does what you
want. The corollary to that is that nothing can be changed, because
doing so would break existing scripts that were tweaked to perform
correctly using the current implementation.

Mike Stone

#729952#15
Date:
2026-05-30 03:04:13 UTC
From:
To:
$ date -I -d '1 year ago'
2025-05-30

$ date -I -d '1 year 2 months ago'
2027-03-30

This aligns perfectly with the documentation, but it's annoying nonetheless.