]> granicus.if.org Git - php/commitdiff
- MFH: Added a few new separation specifiers.
authorDerick Rethans <derick@php.net>
Mon, 25 Feb 2008 18:26:33 +0000 (18:26 +0000)
committerDerick Rethans <derick@php.net>
Mon, 25 Feb 2008 18:26:33 +0000 (18:26 +0000)
- MFH: Added specifiers that can reset or default the y/m/d/h/i/s/tz values.
- MFH: Fixed a problem with parsing timezones as part of a format.

ext/date/lib/parse_date.c
ext/date/lib/parse_date.re

index d46a37f956a9fb27a87eabbc28d69233770976fa..bd13182f3c8e27bf6c99e9a1789898624bffd772 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.12.1 on Sun Feb 17 19:15:32 2008 */
+/* Generated by re2c 0.12.1 on Sun Feb 24 19:24:27 2008 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -728,7 +728,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found
        long  value = 0;
        const timelib_tz_lookup_table *tp;
 
-       while (**ptr != '\0' && **ptr != ')') {
+       while (**ptr != '\0' && **ptr != ')' && **ptr != ' ') {
                ++*ptr;
        }
        end = *ptr;
@@ -23095,6 +23095,39 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
                                }
                                break;
 
+                       case ';':
+                       case ':':
+                       case '/':
+                       case '.':
+                       case ',':
+                       case '-':
+                               if (*ptr == *fptr) {
+                                       ++ptr;
+                               } else {
+                                       add_pbf_error(s, "The separation symbol could not be found", string, begin);
+                               }
+                               break;
+
+                       case '!': // reset all fields to default
+                               s->time->y = 1970;
+                               s->time->m = 1;
+                               s->time->d = 1;
+                               s->time->h = s->time->i = s->time->s = 0;
+                               s->time->f = 0.0;
+                               s->time->tz_info = NULL;
+                               break; // break intentionally not missing
+
+                       case '|': // reset all fields to default when not set
+                               if (s->time->y == TIMELIB_UNSET ) s->time->y = 1970;
+                               if (s->time->m == TIMELIB_UNSET ) s->time->m = 1;
+                               if (s->time->d == TIMELIB_UNSET ) s->time->d = 1;
+                               if (s->time->h == TIMELIB_UNSET ) s->time->h = 0;
+                               if (s->time->i == TIMELIB_UNSET ) s->time->i = 0;
+                               if (s->time->s == TIMELIB_UNSET ) s->time->s = 0;
+                               if (s->time->f == TIMELIB_UNSET ) s->time->f = 0.0;
+                               
+                               break; // break intentionally not missing
+
                        case '?': // random char
                                ++ptr;
                                break;
@@ -23118,6 +23151,20 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
                add_pbf_error(s, "Data missing", string, ptr);
        }
 
+       // clean up a bit
+       if (s->time->h != TIMELIB_UNSET || s->time->i != TIMELIB_UNSET || s->time->s != TIMELIB_UNSET) {
+               if (s->time->h == TIMELIB_UNSET ) {
+                       s->time->h = 0;
+               }
+               if (s->time->i == TIMELIB_UNSET ) {
+                       s->time->i = 0;
+               }
+               if (s->time->s == TIMELIB_UNSET ) {
+                       s->time->s = 0;
+               }
+       }
+
+
        if (errors) {
                *errors = in.errors;
        } else {
index 21f4fa951661d5c4a782afeed36b6c2fa041bfb5..ccc8df63221eae9f79ce6176bc8dd1d20696fbfb 100644 (file)
@@ -726,7 +726,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found
        long  value = 0;
        const timelib_tz_lookup_table *tp;
 
-       while (**ptr != '\0' && **ptr != ')') {
+       while (**ptr != '\0' && **ptr != ')' && **ptr != ' ') {
                ++*ptr;
        }
        end = *ptr;
@@ -1867,6 +1867,39 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
                                }
                                break;
 
+                       case ';':
+                       case ':':
+                       case '/':
+                       case '.':
+                       case ',':
+                       case '-':
+                               if (*ptr == *fptr) {
+                                       ++ptr;
+                               } else {
+                                       add_pbf_error(s, "The separation symbol could not be found", string, begin);
+                               }
+                               break;
+
+                       case '!': // reset all fields to default
+                               s->time->y = 1970;
+                               s->time->m = 1;
+                               s->time->d = 1;
+                               s->time->h = s->time->i = s->time->s = 0;
+                               s->time->f = 0.0;
+                               s->time->tz_info = NULL;
+                               break; // break intentionally not missing
+
+                       case '|': // reset all fields to default when not set
+                               if (s->time->y == TIMELIB_UNSET ) s->time->y = 1970;
+                               if (s->time->m == TIMELIB_UNSET ) s->time->m = 1;
+                               if (s->time->d == TIMELIB_UNSET ) s->time->d = 1;
+                               if (s->time->h == TIMELIB_UNSET ) s->time->h = 0;
+                               if (s->time->i == TIMELIB_UNSET ) s->time->i = 0;
+                               if (s->time->s == TIMELIB_UNSET ) s->time->s = 0;
+                               if (s->time->f == TIMELIB_UNSET ) s->time->f = 0.0;
+                               
+                               break; // break intentionally not missing
+
                        case '?': // random char
                                ++ptr;
                                break;
@@ -1890,6 +1923,20 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
                add_pbf_error(s, "Data missing", string, ptr);
        }
 
+       // clean up a bit
+       if (s->time->h != TIMELIB_UNSET || s->time->i != TIMELIB_UNSET || s->time->s != TIMELIB_UNSET) {
+               if (s->time->h == TIMELIB_UNSET ) {
+                       s->time->h = 0;
+               }
+               if (s->time->i == TIMELIB_UNSET ) {
+                       s->time->i = 0;
+               }
+               if (s->time->s == TIMELIB_UNSET ) {
+                       s->time->s = 0;
+               }
+       }
+
+
        if (errors) {
                *errors = in.errors;
        } else {