git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Approxidate with YYYY.MM

From
VEVictor Engmark <victor.engmark@terreactive.ch>
Date
May 10, 2011, 07:40 UTC
Message-ID
<4DC8EBD8.50707@terreactive.ch>
In-Reply-To
<964517.31047.1305010481774.JavaMail.trustmail@mail1.terreactive.ch>
On 05/10/2011 08:54 AM, Andreas Ericsson wrote:
Show 27 quoted lines
> On 05/10/2011 08:35 AM, Michael J Gruber wrote:
>> Brian Gernhardt venit, vidit, dixit 09.05.2011 21:02:
>>> (This is in response to a discussion on #parrot.)
>>>
>>> Rakudo (https://github.com/rakudo/rakudo/) uses tags of the form
>>> YYYY.MM for their monthly releases.  When we were attempting to find
>>> the cause of a slowdown, somewhat was trying to find what commits
>>> occurred after the 2011.01 release with "git log --after=2011.01".
>>> His mistake was pointed out but this led to the confusion of why this
>>> was parsed as "May 1 2011" instead of "Jan 1 2011".  Shouldn't
>>> date.c:match_multi_number() parse something with only two numbers as
>>> a beginning of month instead of allowing it to pass through to the
>>> generic parsing?
>>
>> I just don't think there is a format like that. There is dd.mm.[yy]yy
>> and apparently also yyyy.mm.dd, but without leading zeros in mm for the
>> latter. Our date parser also takes "." for a space so that you don't
>> need to quote a space ("1.day.ago"). I can see the logic behind parsing
>> 2011.01 as January 2011, but it's a stretch from the existing formats:
>>
> 
> It would be far more logical to parse "2011-01" as "January 2011" as
> that's the preferred way to write month-precision dates in most
> countries that use both the metric system and the gregorian calender.
> 
> I've never seen that date-type with dot as a separator, but with the
> dash it's very, very common.

Seconded. ISO dates are getting pretty common, and in the extended format hyphens are the default separator between year, month, and date <https://secure.wikimedia.org/wikipedia/en/wiki/ISO_8601#Calendar_dates>.

A few notes on support:

GNU `date` 8.5 parses some ISO date strings correctly: $ date --date='2001-02-03' +%Y-%m-%d\ %H:%M:%S 2001-02-03 00:00:00 $ date --date='2001-02-03 04:05:06' +%Y-%m-%d\ %H:%M:%S 2001-02-03 04:05:06

Unfortunately, it doesn't handle partial dates: $ date --date='2001-02' +%Y-%m-%d\ %H:%M:%S date: invalid date `2001-02'

But it does handle HH:MM: $ date --date='04:05' +%Y-%m-%d\ %H:%M:%S 2011-05-10 04:05:00

Basic format dates are sometimes parsed correctly: $ date --date='20010203' +%Y-%m-%d\ %H:%M:%S 2001-02-03 00:00:00

But not with seconds: $ date --date='20010203040506' +%Y-%m-%d\ %H:%M:%S 2001020304-05-06 00:00:00

The W3C recommends the use of ISO dates: <http://www.w3.org/QA/Tips/iso-date>, and their standards, like XML, typically support only ISO dates (or a subset thereof).

Cheers, Victor Engmark

Previous: Michael J GruberNext: Michael J Gruber
Message 5 of 7 in “Approxidate with YYYY.MM”
  1. Brian GernhardtMay 9, 2011
  2. Michael J GruberMay 10, 2011
  3. Andreas EricssonMay 10, 2011
  4. Michael J GruberMay 10, 2011
  5. Victor EngmarkMay 10, 2011
  6. Michael J GruberMay 10, 2011
  7. Michael WittenMay 22, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.