-/* Generated by re2c 0.13.4 on Sun May 4 22:48:22 2008 */
+/* Generated by re2c 0.13.4 on Tue Jul 8 19:53:07 2008 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
TIMELIB_INIT;
TIMELIB_HAVE_RELATIVE();
- // skip "last day of" or "first day of"
+ /* skip "last day of" or "first day of" */
if (*ptr == 'l') {
s->time->relative.first_last_day_of = 2;
} else {
while (*fptr && *ptr) {
begin = ptr;
switch (*fptr) {
- case 'd': // two digit day, with leading zero
- case 'j': // two digit day, without leading zero
+ case 'd': /* two digit day, with leading zero */
+ case 'j': /* two digit day, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->d = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit day could not be found", string, begin);
}
break;
- case 'S': // day suffix, ignored, nor checked
+ case 'S': /* day suffix, ignored, nor checked */
timelib_skip_day_suffix((char **) &ptr);
break;
- case 'z': // day of year - resets month (0 based)
+ case 'z': /* day of year - resets month (0 based) */
TIMELIB_CHECK_NUMBER;
if ((tmp = timelib_get_nr((char **) &ptr, 3)) == TIMELIB_UNSET) {
add_pbf_error(s, "A three digit day-of-year could not be found", string, begin);
}
break;
- case 'm': // two digit month, with leading zero
- case 'n': // two digit month, without leading zero
+ case 'm': /* two digit month, with leading zero */
+ case 'n': /* two digit month, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->m = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit month could not be found", string, begin);
}
break;
- case 'M': // three letter month
- case 'F': // full month
+ case 'M': /* three letter month */
+ case 'F': /* full month */
tmp = timelib_lookup_month((char **) &ptr);
if (!tmp) {
add_pbf_error(s, "A textual month could not be found", string, begin);
s->time->m = tmp;
}
break;
- case 'y': // two digit year
+ case 'y': /* two digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit year could not be found", string, begin);
}
TIMELIB_PROCESS_YEAR(s->time->y);
break;
- case 'Y': // four digit year
+ case 'Y': /* four digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 4)) == TIMELIB_UNSET) {
add_pbf_error(s, "A four digit year could not be found", string, begin);
}
break;
- case 'g': // two digit hour, with leading zero
- case 'h': // two digit hour, without leading zero
+ case 'g': /* two digit hour, with leading zero */
+ case 'h': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
add_pbf_error(s, "Hour can not be higher than 12", string, begin);
}
break;
- case 'G': // two digit hour, with leading zero
- case 'H': // two digit hour, without leading zero
+ case 'G': /* two digit hour, with leading zero */
+ case 'H': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
}
break;
- case 'a': // am/pm/a.m./p.m.
- case 'A': // AM/PM/A.M./P.M.
+ case 'a': /* am/pm/a.m./p.m. */
+ case 'A': /* AM/PM/A.M./P.M. */
if (s->time->h == TIMELIB_UNSET) {
add_pbf_error(s, "Meridian can only come after an hour has been found", string, begin);
} else if ((tmp = timelib_meridian_with_check((char **) &ptr, s->time->h)) == TIMELIB_UNSET) {
s->time->h += tmp;
}
break;
- case 'i': // two digit minute, with leading zero
+ case 'i': /* two digit minute, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->i = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit minute could not be found", string, begin);
}
break;
- case 's': // two digit second, with leading zero
+ case 's': /* two digit second, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->s = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
- case 'u': // five digit millisecond, with leading zero
+ case 'u': /* five digit millisecond, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
}
break;
- case ' ': // any sort of whitespace (' ' and \t)
+ case ' ': /* any sort of whitespace (' ' and \t) */
timelib_eat_spaces((char **) &ptr);
break;
- case 'U': // epoch seconds
+ case 'U': /* epoch seconds */
TIMELIB_CHECK_NUMBER;
TIMELIB_HAVE_RELATIVE();
tmp = timelib_get_unsigned_nr((char **) &ptr, 24);
s->time->z = 0;
break;
- case 'e': // timezone
+ case 'e': /* timezone */
{
int tz_not_found;
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
}
break;
- case '#': // separation symbol
+ case '#': /* separation symbol */
if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-') {
++ptr;
} else {
}
break;
- case '!': // reset all fields to default
+ 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
+ break; /* break intentionally not missing */
- case '|': // reset all fields to default when not set
+ 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->s == TIMELIB_UNSET ) s->time->s = 0;
if (s->time->f == TIMELIB_UNSET ) s->time->f = 0.0;
- break; // break intentionally not missing
+ break; /* break intentionally not missing */
- case '?': // random char
+ case '?': /* random char */
++ptr;
break;
- case '*': // random chars until a separator or number ([ \t.,:;/-0123456789])
+ case '*': /* random chars until a separator or number ([ \t.,:;/-0123456789]) */
timelib_eat_until_separator((char **) &ptr);
break;
add_pbf_error(s, "Data missing", string, ptr);
}
- // clean up a bit
+ /* 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;
TIMELIB_INIT;
TIMELIB_HAVE_RELATIVE();
- // skip "last day of" or "first day of"
+ /* skip "last day of" or "first day of" */
if (*ptr == 'l') {
s->time->relative.first_last_day_of = 2;
} else {
while (*fptr && *ptr) {
begin = ptr;
switch (*fptr) {
- case 'd': // two digit day, with leading zero
- case 'j': // two digit day, without leading zero
+ case 'd': /* two digit day, with leading zero */
+ case 'j': /* two digit day, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->d = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit day could not be found", string, begin);
}
break;
- case 'S': // day suffix, ignored, nor checked
+ case 'S': /* day suffix, ignored, nor checked */
timelib_skip_day_suffix((char **) &ptr);
break;
- case 'z': // day of year - resets month (0 based)
+ case 'z': /* day of year - resets month (0 based) */
TIMELIB_CHECK_NUMBER;
if ((tmp = timelib_get_nr((char **) &ptr, 3)) == TIMELIB_UNSET) {
add_pbf_error(s, "A three digit day-of-year could not be found", string, begin);
}
break;
- case 'm': // two digit month, with leading zero
- case 'n': // two digit month, without leading zero
+ case 'm': /* two digit month, with leading zero */
+ case 'n': /* two digit month, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->m = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit month could not be found", string, begin);
}
break;
- case 'M': // three letter month
- case 'F': // full month
+ case 'M': /* three letter month */
+ case 'F': /* full month */
tmp = timelib_lookup_month((char **) &ptr);
if (!tmp) {
add_pbf_error(s, "A textual month could not be found", string, begin);
s->time->m = tmp;
}
break;
- case 'y': // two digit year
+ case 'y': /* two digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit year could not be found", string, begin);
}
TIMELIB_PROCESS_YEAR(s->time->y);
break;
- case 'Y': // four digit year
+ case 'Y': /* four digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 4)) == TIMELIB_UNSET) {
add_pbf_error(s, "A four digit year could not be found", string, begin);
}
break;
- case 'g': // two digit hour, with leading zero
- case 'h': // two digit hour, without leading zero
+ case 'g': /* two digit hour, with leading zero */
+ case 'h': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
add_pbf_error(s, "Hour can not be higher than 12", string, begin);
}
break;
- case 'G': // two digit hour, with leading zero
- case 'H': // two digit hour, without leading zero
+ case 'G': /* two digit hour, with leading zero */
+ case 'H': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
}
break;
- case 'a': // am/pm/a.m./p.m.
- case 'A': // AM/PM/A.M./P.M.
+ case 'a': /* am/pm/a.m./p.m. */
+ case 'A': /* AM/PM/A.M./P.M. */
if (s->time->h == TIMELIB_UNSET) {
add_pbf_error(s, "Meridian can only come after an hour has been found", string, begin);
} else if ((tmp = timelib_meridian_with_check((char **) &ptr, s->time->h)) == TIMELIB_UNSET) {
s->time->h += tmp;
}
break;
- case 'i': // two digit minute, with leading zero
+ case 'i': /* two digit minute, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->i = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit minute could not be found", string, begin);
}
break;
- case 's': // two digit second, with leading zero
+ case 's': /* two digit second, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->s = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
- case 'u': // five digit millisecond, with leading zero
+ case 'u': /* five digit millisecond, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
}
break;
- case ' ': // any sort of whitespace (' ' and \t)
+ case ' ': /* any sort of whitespace (' ' and \t) */
timelib_eat_spaces((char **) &ptr);
break;
- case 'U': // epoch seconds
+ case 'U': /* epoch seconds */
TIMELIB_CHECK_NUMBER;
TIMELIB_HAVE_RELATIVE();
tmp = timelib_get_unsigned_nr((char **) &ptr, 24);
s->time->z = 0;
break;
- case 'e': // timezone
+ case 'e': /* timezone */
{
int tz_not_found;
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
}
break;
- case '#': // separation symbol
+ case '#': /* separation symbol */
if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-') {
++ptr;
} else {
}
break;
- case '!': // reset all fields to default
+ 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
+ break; /* break intentionally not missing */
- case '|': // reset all fields to default when not set
+ 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->s == TIMELIB_UNSET ) s->time->s = 0;
if (s->time->f == TIMELIB_UNSET ) s->time->f = 0.0;
- break; // break intentionally not missing
+ break; /* break intentionally not missing */
- case '?': // random char
+ case '?': /* random char */
++ptr;
break;
- case '*': // random chars until a separator or number ([ \t.,:;/-0123456789])
+ case '*': /* random chars until a separator or number ([ \t.,:;/-0123456789]) */
timelib_eat_until_separator((char **) &ptr);
break;
add_pbf_error(s, "Data missing", string, ptr);
}
- // clean up a bit
+ /* 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;
-/* Generated by re2c 0.13.4 on Sat May 3 13:59:42 2008 */
+/* Generated by re2c 0.13.4 on Tue Jul 8 19:53:10 2008 */
#line 1 "ext/date/lib/parse_iso_intervals.re"
/*
+----------------------------------------------------------------------+
time->y += time->relative.y;
}
switch (time->relative.first_last_day_of) {
- case 1: // first
+ case 1: /* first */
time->d = 1;
break;
- case 2: // last
+ case 2: /* last */
time->d = 0;
time->m++;
break;
current_dow = timelib_day_of_week(time->y, time->m, time->d);
if (count == 0) {
- // skip over saturday and sunday
+ /* skip over saturday and sunday */
if (current_dow == 6) {
time->d += 2;
}
- // skip over sunday
+ /* skip over sunday */
if (current_dow == 0) {
time->d += 1;
}
} else if (count > 0) {
- // skip over saturday and sunday
+ /* skip over saturday and sunday */
if (current_dow == 5) {
time->d += 2;
}
- // skip over sunday
+ /* skip over sunday */
if (current_dow == 6) {
time->d += 1;
}
- // add increments of 5 weekdays as a week
+ /* add increments of 5 weekdays as a week */
time->d += (count / 5) * 7;
- // if current DOW plus the remainder > 5, add two days
+ /* if current DOW plus the remainder > 5, add two days */
current_dow = timelib_day_of_week(time->y, time->m, time->d);
time->d += (count % 5);
if ((count % 5) + current_dow > 5) {
time->d += 2;
}
} else if (count < 0) {
- // skip over sunday and saturday
+ /* skip over sunday and saturday */
if (current_dow == 1) {
time->d -= 2;
}
- // skip over satruday
+ /* skip over satruday */
if (current_dow == 0 ) {
time->d -= 1;
}
- // subtract increments of 5 weekdays as a week
+ /* subtract increments of 5 weekdays as a week */
time->d += (count / 5) * 7;
- // if current DOW minus the remainder < 0, subtract two days
+ /* if current DOW minus the remainder < 0, subtract two days */
current_dow = timelib_day_of_week(time->y, time->m, time->d);
time->d += (count % 5);
if ((count % 5) + current_dow < 1) {
timelib_sll res = 0;
timelib_sll eras;
- eras = (year - 1970) / 400;
+ eras = (year - 1970) / 40000;
if (eras != 0) {
- year = year - (eras * 400);
- res += (SECS_PER_ERA * eras);
+ year = year - (eras * 40000);
+ res += (SECS_PER_ERA * eras * 100);
}
if (year >= 1970) {
int initialized;
int type;
union {
- timelib_tzinfo *tz; // TIMELIB_ZONETYPE_ID;
- timelib_sll utc_offset; // TIMELIB_ZONETYPE_OFFSET
- struct // TIMELIB_ZONETYPE_ABBR
+ timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */
+ timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
+ struct /* TIMELIB_ZONETYPE_ABBR */
{
timelib_sll utc_offset;
char *abbr;
return props;
}
- // first we add the date and time in ISO format
+ /* first we add the date and time in ISO format */
MAKE_STD_ZVAL(zv);
ZVAL_STRING(zv, date_format("Y-m-d H:i:s", 12, dateobj->time, 1), 0);
zend_hash_update(props, "date", 5, &zv, sizeof(zval), NULL);
- // then we add the timezone name (or similar)
+ /* then we add the timezone name (or similar) */
if (dateobj->time->is_localtime) {
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, dateobj->time->zone_type);
dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB);
}
- // update last errors and warnings
+ /* update last errors and warnings */
update_errors_warnings(err TSRMLS_CC);