[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] lib/parse-datetime.y: Add ability to parse output of GNU dat
From: |
Jim Meyering |
Subject: |
Re: [PATCH] lib/parse-datetime.y: Add ability to parse output of GNU date(1) |
Date: |
Wed, 4 Feb 2015 10:05:39 -0800 |
On Wed, Feb 4, 2015 at 9:25 AM, Bruce Korb <address@hidden> wrote:
> On 02/02/15 09:27, Pádraig Brady wrote:
>>
>> On 02/02/15 16:41, Chris Lamb wrote:
>>>
>>> We are currently in a funny situation where GNU date can't parse its own
>>> output:
>>>
>>> $ date --date="$(date)"
>>> date: invalid date 'Mon 2 Feb 16:37:46 GMT 2015'
>
>
>> I don't think this will work as the output from date(1) is ambiguous.
>> For example locales change change the output order, and names.
>> In your example, date(1) can parse US locale default format, but not UK:
>>
>> $ date -d"$(LC_TIME=en_GB date)"
>> date: invalid date 'Mon 2 Feb 17:23:25 GMT 2015'
>
>
> It would still be useful to make the ways for doing this more readily known.
> e.g. in examples:
>
> touch -t $(date --date @$(( $(date +%s) + 10 )) +%Y%m%d%H%M.%S) file
>
> set the modify time of "file" to 10 seconds from now. It's a little obtuse.
If you are willing to rely on GNU date's --date=... option,
you can set FILE's mtime to 10 seconds in the future more concisely with this:
touch -d '10 seconds' FILE