coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [date] Parse common European date formats


From: Pádraig Brady
Subject: Re: [date] Parse common European date formats
Date: Fri, 16 Jan 2026 16:50:47 +0000
User-agent: Mozilla Thunderbird Beta

On 16/01/2026 15:35, Gabriel wrote:
Hello there,

I'd love to have date support another common format, like it does with
mm/dd/yyyy for the U.S.[1].
dd.mm.yyyy (e.g. 16.01.2026) is used in a lot of countries (30 if I
counted correctly [2]) , especially in and around Europe. Thanks to the
dots it is not ambiguous and does not clash with any of the existing ones.
There is also a shorter form omitting the year as in dd.mm. (16.01.)
like the U.S. mm/dd .

The patch for gnulib looks easy enough, so I've added it below. I can
also add one for corelib where the docs and the actual date format tests
are, I think? gnulib's test-parse-datetime.c seems to test only general
date parsing.

Gabriel

[1]:
https://www.gnu.org/software/coreutils/manual/html_node/Calendar-date-items.html
[2]:
https://en.wikipedia.org/wiki/List_of_date_formats_by_country#Table_coding


date: add parsing for common European dd.mm.yyyy and dd.mm. formats
---
   lib/parse-datetime.y | 13 +++++++++++++
   1 file changed, 13 insertions(+)

diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y
index 85a7a92..9456f48 100644
--- a/lib/parse-datetime.y
+++ b/lib/parse-datetime.y
@@ -847,6 +847,19 @@ date:
               pc->year = $5;
             }
         }
+  | tUNUMBER '.' tUNUMBER '.'
+      {
+        /* E.g., 17.6.  */
+        pc->day = $1.value;
+        pc->month = $3.value;
+      }
+  | tUNUMBER '.' tUNUMBER '.' tUNUMBER
+      {
+        /* E.g., 17.6.1992  */
+        pc->day = $1.value;
+        pc->month = $3.value;
+        pc->year = $5.value;
+      }
     | tUNUMBER tMONTH tSNUMBER
         {
           /* E.g., 17-JUN-1992.  */
--
2.43.0


That does seem worthwhile.

We already support dots in a couple of contexts,
but there is no ambiguity I think:

  $ date --iso=ns -d '01:02:03.04 1 Jan.'
  2026-01-01T01:02:03,040000000+00:00

cheers,
Padraig



reply via email to

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