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