From: markus schnalke Date: Wed, 7 Sep 2016 20:41:06 +0000 (+0200) Subject: Add support for simplified ISO 8601/RFC 3339 dates X-Git-Tag: mmh-0.4~61 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=9c9972821e53c2e5ac94431e3c9be3aeb63ef26c Add support for simplified ISO 8601/RFC 3339 dates It is now possible to use: pick -after 2016-02-15 -and -before 2016-08-31T16:30:00+02:00 At the same time drop support for the highly ambiguous date format XX-XX-YY. --- diff --git a/man/pick.man1 b/man/pick.man1 index e93a0cd..076f99d 100644 --- a/man/pick.man1 +++ b/man/pick.man1 @@ -169,6 +169,8 @@ ago), and `tomorrow' (24 hours from now). All days of the week are judged to refer to a day in the past (e.g., telling \fIpick\fR `saturday' on a `tuesday' means `last\ saturday' not `this\ saturday'). +Further more, dates in a simplified ISO 8601/RFC 3339 style (e.g. +`YYYY-MM-DD' or `YYYY-MM-DD hh:mm:ss') are accepted. Finally, in addition to these special specifications, .B pick will diff --git a/sbr/dtimep.lex b/sbr/dtimep.lex index 0581736..e06a068 100644 --- a/sbr/dtimep.lex +++ b/sbr/dtimep.lex @@ -102,6 +102,8 @@ name2num(char *name, char *names[]) tw.tw_sec = atoi(++cp); SKIPD(); } } #define SETZONE(x) { tw.tw_zone = ((x)/100)*60+(x)%100; \ tw.tw_flags |= TW_SZEXP; SKIPD(); } +#define SETZONEC(h, m) { tw.tw_zone = (h)*60+(m); \ + tw.tw_flags |= TW_SZEXP; SKIPD(); } #define SETDST() { tw.tw_flags |= TW_DST; } #define SKIPD() { while ( isdigit(*cp++) ) ; --cp; } #define SKIPTOD() { while ( !isdigit(*cp++) ) ; --cp; } @@ -266,7 +268,29 @@ nl [ \t\n()] SKIPTOD(); SETYEAR(); } -{D}("-"|"/"){D}("-"|"/"){YEAR}{W}{TIME} { +{d}{4}"-"{d}{2}"-"{d}{2}(" "|"T"){TIME} { + INIT(); + SETYEAR(); + SKIPTOD(); + SETMON_NUM(); + SKIPTOD(); + SETDAY(); + SKIPTOD(); + SETTIME(); +} +{d}{4}"-"{d}{2}"-"{d}{2} { + INIT(); + SETYEAR(); + SKIPTOD(); + SETMON_NUM(); + SKIPTOD(); + SETDAY(); +} +{d}{2}"-"{d}{2}"-"{d}{2} { + fprintf(stderr, "the highly ambiguous date format XX-XX-XX..." + " is no longer supported\n"); +} +{D}"/"{D}"/"{YEAR}{W}{TIME} { INIT(); if(europeandate) { /* DD/MM/YY */ @@ -284,7 +308,7 @@ nl [ \t\n()] SKIPTOD(); SETTIME(); } -{D}("-"|"/"){D}("-"|"/"){YEAR} { +{D}"/"{D}"/"{YEAR} { INIT(); if(europeandate) { /* DD/MM/YY */ @@ -323,6 +347,25 @@ nl [ \t\n()] yyterminate(); } +"+"{d}{d}":"{d}{d} { + INIT(); + SKIPTOD(); + SETZONEC(atoi(cp), atoi(cp+3)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ + yyterminate(); +} +"-"{d}{d}":"{d}{d} { + INIT(); + SKIPTOD(); + SETZONEC(-atoi(cp), -atoi(cp+3)); +#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST + zonehack (&tw); +#endif /* ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST */ + yyterminate(); + +} {nl}("ut"|"UT") INIT(); SETZONE(0); yyterminate(); {nl}("gmt"|"GMT") INIT(); SETZONE(0); yyterminate(); {nl}("est"|"EST") INIT(); SETZONE(-500); yyterminate();