From 99929166475f719dc8e445fe0061ff96bac6acec Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 20 Mar 2022 20:43:43 -0400 Subject: datetime: Add formats with "." --- diff --git a/TODO b/TODO index 27e0571..b7ad21a 100644 --- a/TODO +++ b/TODO @@ -3,5 +3,4 @@ spaces between specifiers in strptime() formats -- strftime()? test with other libc's (newlib? musl? fbsd? obsd?) `./@ 7:00 PM` doesn't work with musl strptime() test other times -"." in date/time formats gettext? diff --git a/src/datetime.c b/src/datetime.c index a3b4c58..962c867 100644 --- a/src/datetime.c +++ b/src/datetime.c @@ -35,10 +35,13 @@ static const char *DATETIME_DATE_FMTS_[] = { " %a ", /* Wed */ " %Y-%m-%d ", /* 1969-12-31 */ " %Y/%m/%d ", /* 1969/12/31 */ + " %Y.%m.%d ", /* 1969.12.31 */ " %m-%d-%Y ", /* 12-31-1969 */ " %m-%d ", /* 12-31 */ " %m/%d/%Y ", /* 12/31/1969 */ " %m/%d ", /* 12/31 */ + " %m.%d.%Y ", /* 12.31.1969 */ + " %m.%d ", /* 12.31 */ " %e %b %Y ", /* 31 Dec 1969 */ " %e %b ", /* 31 Dec */ " %d-%b-%Y ", /* 31-Dec-1969 */ @@ -81,6 +84,10 @@ static const char *DATETIME_TIME_FMTS_[] = { " %H:%M:%S ", /* 19:00:01 */ " %I:%M %p ", /* 7:00 PM */ " %H:%M ", /* 19:00 */ + " %I.%M.%S %p ", /* 7.00.01 PM */ + " %H.%M.%S ", /* 19.00.01 */ + " %I.%M %p ", /* 7.00 PM */ + " %H.%M ", /* 19.00 */ " %I%M%S %p ", /* 70001 PM */ " %H%M%S ", /* 190001 */ " %I%M %p ", /* 700 PM */ diff --git a/tests/formats.exp b/tests/formats.exp index 8286264..2a8d5c6 100644 --- a/tests/formats.exp +++ b/tests/formats.exp @@ -3,6 +3,10 @@ Time formats: * 03:04:05 * 03:04 AM * 03:04 + * 03.04.05 AM + * 03.04.05 + * 03.04 AM + * 03.04 * 030405 AM * 030405 * 0304 AM @@ -11,10 +15,13 @@ Date formats: * Fri * 1970-01-02 * 1970/01/02 + * 1970.01.02 * 01-02-1970 * 01-02 * 01/02/1970 * 01/02 + * 01.02.1970 + * 01.02 * 2 Jan 1970 * 2 Jan * 02-Jan-1970 -- cgit v0.9.1