[prev in list] [next in list] [prev in thread] [next in thread]
List: coreutils
Subject: Re: date fails to parse seconds and nanoseconds
From: Pádraig Brady <P () draigBrady ! com>
Date: 2014-06-09 17:49:39
Message-ID: 5395F3B3.3000306 () draigBrady ! com
[Download RAW message or body]
On 06/09/2014 06:35 PM, Kasza Péter wrote:
> Date can't seem to parse seconds (or nanoseconds) when they are
> immedately after another term. E.g. trying to parse the string
> "20140609T150610" (2014-06-09-15:06:10) fails.
>
>> % date +%Y%m%dT%H%M%S -d "20140609T150610"
>> date: invalid date ‘20140609T150610'
>
>
> The date parses correctly, if the seconds are removed:
>
>> % date +%Y%m%dT%H%M%S -d "20140609T1506"
>> 20140609T100600
>
>
> Using the output from the previous command also gives an error:
>
>> % date +%Y%m%dT%H%M%S -d "20140609T150600"
>> date: invalid date ‘20140609T150600'
>
> Is this a bug or am I doing something the wrong way?
Well it's documented as such in:
http://www.gnu.org/software/coreutils/manual/coreutils.html#Pure-numbers-in-date-strings
I guess not supporting seconds here avoids ambiguities as to whether you're
referring to a date or a time.
A proposal I saw recently was for date to support specifying
an input format for precise control like this, like FreeBSD supports:
BSD> date -j -f "%H%M%S" "010203"
Mon Jun 9 01:02:03 GMT 2014
GNU> date -d '010203'
Sat Feb 3 00:00:00 GMT 2001
Pádraig.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic