]> granicus.if.org Git - php/commitdiff
- MFH: Also add the warnings for times. This does not make sense for the
authorDerick Rethans <derick@php.net>
Tue, 15 Jul 2008 17:38:27 +0000 (17:38 +0000)
committerDerick Rethans <derick@php.net>
Tue, 15 Jul 2008 17:38:27 +0000 (17:38 +0000)
  english text parser, as invalid times are never allowed in there.

ext/date/lib/dow.c
ext/date/lib/parse_date.c
ext/date/lib/parse_date.re
ext/date/lib/timelib.h

index bd12d82fc7802c7e96137b734b326216530eaba3..50f10587da36f4dcffea52d18b71dba4481093f7 100644 (file)
@@ -140,6 +140,14 @@ timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll
        return day + ((w - 1) * 7) + d;
 }
 
+int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s)
+{
+       if (h < 0 || h > 23 || i < 0 || i > 59 || s < 0 || s > 59) {
+               return 0;
+       }
+       return 1;
+}
+
 int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d)
 {
        if (m < 1 || m > 12 || d < 1 || d > timelib_days_in_month(y, m)) {
index 69663a7c1d206a9470b94b86c2609dfacefa19a5..dd0984c8b6e177e1f7d5b1e6debacb3d763c1f1a 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon Jul 14 19:34:39 2008 */
+/* Generated by re2c 0.13.5 on Tue Jul 15 19:21:36 2008 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -23630,6 +23630,12 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
                }
        }
 
+       /* do funky checking whether the parsed time was valid time */
+       if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET &&
+               s->time->s != TIMELIB_UNSET && 
+               !timelib_valid_time( s->time->h, s->time->i, s->time->s)) {
+               add_pbf_warning(s, "The parsed time was invalid", string, ptr);
+       }
        /* do funky checking whether the parsed date was valid date */
        if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
                s->time->d != TIMELIB_UNSET && 
index d538ea7510decbd54d8380940ef3c26741b93617..14bd7e88db4a737daddbccf39e44ee4b01cf463d 100644 (file)
@@ -2040,6 +2040,12 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
                }
        }
 
+       /* do funky checking whether the parsed time was valid time */
+       if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET &&
+               s->time->s != TIMELIB_UNSET && 
+               !timelib_valid_time( s->time->h, s->time->i, s->time->s)) {
+               add_pbf_warning(s, "The parsed time was invalid", string, ptr);
+       }
        /* do funky checking whether the parsed date was valid date */
        if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
                s->time->d != TIMELIB_UNSET && 
index 20234827480065d02fdaa413b69adca41ba79799..f23978f89a181400790ddc2276564d2d790fad8d 100644 (file)
@@ -56,6 +56,7 @@ timelib_sll timelib_day_of_year(timelib_sll y, timelib_sll m, timelib_sll d);
 timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d);
 timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m);
 void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy);
+int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s);
 int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d);
 
 /* From parse_date.re */