bug-gnulib
[Top][All Lists]
Advanced

[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: Wed, 04 Feb 2015 19:36:28 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 04/02/15 18:44, Bruce Korb wrote:
> True.  It was mostly a plea for some (findable) documentation.
> In truth, my most common usage is more like:
> 
>     touch -t $(date address@hidden(( $(stat -c %Y file1) + 10 ))
> +%Y%m%d%H%M.%S ) file2

Note +%Y%m%d%H%M.%S is ambiguous on distributed systems (no timezone).
If you're using GNU date, then it's reasonable to assume GNU touch,
in which case you can:

  touch file2 --ref=file1 --date='+10 seconds'

Or you can reference the file itself like:

  touch file --ref=file --date='-10 seconds'

As for generating unambiguous time representations, you can use
more abstract output formats like:

  for fmt in --rfc-2822 --iso-8601=seconds --rfc-3339=seconds; do date $fmt; 
done

  Wed, 04 Feb 2015 18:13:07 +0000
  2015-02-04T18:13:07+0000
  2015-02-04 18:13:07+00:00

Also more abstract input formats can provide advantages.
For example relative dates like "last month" etc. could
be context sensitive (though they currently are not).
For example the following could work no matter what time it was:

  touch --date='yesterday'

cheers,
Pádraig.




reply via email to

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