be invalid.
return day + ((w - 1) * 7) + d;
}
+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)) {
+ return 0;
+ }
+ return 1;
+}
#if 0
int main(void)
{
-/* Generated by re2c 0.13.5 on Fri Jul 11 10:39:11 2008 */
+/* Generated by re2c 0.13.5 on Mon Jul 14 19:34:39 2008 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
#endif
} while(t != EOI);
+ /* do funky checking whether the parsed date was valid date */
+ if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m, in.time->d)) {
+ add_warning(&in, "The parsed date was invalid");
+ }
+
free(in.str);
if (errors) {
*errors = in.errors;
}
}
+ /* 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 &&
+ !timelib_valid_date( s->time->y, s->time->m, s->time->d)) {
+ add_pbf_warning(s, "The parsed date was invalid", string, ptr);
+ }
if (errors) {
*errors = in.errors;
#endif
} while(t != EOI);
+ /* do funky checking whether the parsed date was valid date */
+ if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m, in.time->d)) {
+ add_warning(&in, "The parsed date was invalid");
+ }
+
free(in.str);
if (errors) {
*errors = in.errors;
}
}
+ /* 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 &&
+ !timelib_valid_date( s->time->y, s->time->m, s->time->d)) {
+ add_pbf_warning(s, "The parsed date was invalid", string, ptr);
+ }
if (errors) {
*errors = in.errors;
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_date(timelib_sll y, timelib_sll m, timelib_sll d);
/* From parse_date.re */
timelib_time *timelib_strtotime(char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb);
RETURN_FALSE;
}
- if (y < 1 || y > 32767 || m < 1 || m > 12 || d < 1 || d > timelib_days_in_month(y, m)) {
+ if (y < 1 || y > 32767 || timelib_valid_date(y, m, d)) {
RETURN_FALSE;
}
RETURN_TRUE; /* True : This month, day, year arguments are valid */