Package: coreutils
Version: 8.21-1
Severity: minor
File: /bin/date
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=
-- System Information:
Debian Release: jessie/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.11-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages coreutils depends on:
ii libacl1 2.2.52-1
ii libattr1 1:2.4.47-1
ii libc6 2.17-93
ii libselinux1 2.1.13-3
coreutils recommends no packages.
coreutils suggests no packages.
-- no debconf information
Acknowledgement sent
to Michael Stone <[email protected]>:
Extra info received and forwarded to list.
(Thu, 21 Nov 2013 19:24:05 GMT) (full text, mbox, link).
Subject: Re: Bug#729952: /bin/date: date parsing inconsistencies
Date: Thu, 21 Nov 2013 14:16:05 -0500
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
Debbugs is free software and licensed under the terms of the GNU General
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.