Add support for simplified ISO 8601/RFC 3339 dates
authormarkus schnalke <meillo@marmaro.de>
Wed, 7 Sep 2016 20:41:06 +0000 (22:41 +0200)
committermarkus schnalke <meillo@marmaro.de>
Wed, 7 Sep 2016 20:47:28 +0000 (22:47 +0200)
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.

man/pick.man1
sbr/dtimep.lex

index e93a0cd..076f99d 100644 (file)
@@ -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').
 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
 Finally, in addition to these special specifications,
 .B pick
 will
index 0581736..e06a068 100644 (file)
@@ -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(); }
        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; }
 #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();
 }
        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 */
        INIT();
        if(europeandate) {
                /* DD/MM/YY */
@@ -284,7 +308,7 @@ nl  [ \t\n()]
        SKIPTOD();
        SETTIME();
 }
        SKIPTOD();
        SETTIME();
 }
-{D}("-"|"/"){D}("-"|"/"){YEAR}  {
+{D}"/"{D}"/"{YEAR}  {
        INIT();
        if(europeandate) {
                /* DD/MM/YY */
        INIT();
        if(europeandate) {
                /* DD/MM/YY */
@@ -323,6 +347,25 @@ nl [ \t\n()]
        yyterminate();
 
 }
        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();
 {nl}("ut"|"UT")                INIT(); SETZONE(0); yyterminate();
 {nl}("gmt"|"GMT")      INIT(); SETZONE(0); yyterminate();
 {nl}("est"|"EST")      INIT(); SETZONE(-500); yyterminate();