[Top][All Lists]

[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: Pádraig Brady
Subject: Re: [PATCH] lib/parse-datetime.y: Add ability to parse output of GNU date(1)
Date: Mon, 02 Feb 2015 17:27:28 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

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’
> This is not aesthetically pleasing at the very least.
> Signed-off-by: Chris Lamb <address@hidden>
> ---
>  lib/parse-datetime.y | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)

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’

$ date -d"$(LC_TIME=en_US date)"
Mon Feb  2 17:23:35 GMT 2015

Also the timezone output is ambiguous depending on your location.
See http://www.pixelbeat.org/docs/linux_timezones/

I think the best we could offer is formats to guide parsing:


reply via email to

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