mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Integrate timelib 2021.12
This commit is contained in:
@@ -308,6 +308,7 @@ timelib_time *timelib_sub_wall(timelib_time *old_time, timelib_rel_time *interva
|
||||
memcpy(&t->relative, interval, sizeof(timelib_rel_time));
|
||||
|
||||
timelib_update_ts(t, NULL);
|
||||
timelib_update_from_sse(t);
|
||||
} else {
|
||||
if (interval->invert) {
|
||||
bias = -1;
|
||||
@@ -331,7 +332,6 @@ timelib_time *timelib_sub_wall(timelib_time *old_time, timelib_rel_time *interva
|
||||
timelib_do_normalize(t);
|
||||
}
|
||||
|
||||
timelib_update_from_sse(t);
|
||||
if (t->zone_type == TIMELIB_ZONETYPE_ID) {
|
||||
timelib_set_timezone(t, t->tz_info);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -211,18 +211,25 @@ static timelib_relunit const timelib_relunit_lookup[] = {
|
||||
{ "year", TIMELIB_YEAR, 1 },
|
||||
{ "years", TIMELIB_YEAR, 1 },
|
||||
|
||||
{ "mondays", TIMELIB_WEEKDAY, 1 },
|
||||
{ "monday", TIMELIB_WEEKDAY, 1 },
|
||||
{ "mon", TIMELIB_WEEKDAY, 1 },
|
||||
{ "tuesdays", TIMELIB_WEEKDAY, 2 },
|
||||
{ "tuesday", TIMELIB_WEEKDAY, 2 },
|
||||
{ "tue", TIMELIB_WEEKDAY, 2 },
|
||||
{ "wednesdays", TIMELIB_WEEKDAY, 3 },
|
||||
{ "wednesday", TIMELIB_WEEKDAY, 3 },
|
||||
{ "wed", TIMELIB_WEEKDAY, 3 },
|
||||
{ "thursdays", TIMELIB_WEEKDAY, 4 },
|
||||
{ "thursday", TIMELIB_WEEKDAY, 4 },
|
||||
{ "thu", TIMELIB_WEEKDAY, 4 },
|
||||
{ "fridays", TIMELIB_WEEKDAY, 5 },
|
||||
{ "friday", TIMELIB_WEEKDAY, 5 },
|
||||
{ "fri", TIMELIB_WEEKDAY, 5 },
|
||||
{ "saturdays", TIMELIB_WEEKDAY, 6 },
|
||||
{ "saturday", TIMELIB_WEEKDAY, 6 },
|
||||
{ "sat", TIMELIB_WEEKDAY, 6 },
|
||||
{ "sundays", TIMELIB_WEEKDAY, 0 },
|
||||
{ "sunday", TIMELIB_WEEKDAY, 0 },
|
||||
{ "sun", TIMELIB_WEEKDAY, 0 },
|
||||
|
||||
@@ -813,6 +820,22 @@ static timelib_long timelib_parse_tz_cor(const char **ptr, int *tz_not_found)
|
||||
*tz_not_found = 0;
|
||||
tmp = sHOUR(strtol(begin, NULL, 10)) + sMIN(strtol(begin + 3, NULL, 10));
|
||||
return tmp;
|
||||
|
||||
case 6: /* HHMMSS */
|
||||
*tz_not_found = 0;
|
||||
tmp = strtol(begin, NULL, 10);
|
||||
tmp = sHOUR(tmp / 10000) + sMIN((tmp / 100) % 100) + (tmp % 100);
|
||||
return tmp;
|
||||
|
||||
case 8: /* HH:MM:SS */
|
||||
if (begin[2] != ':' || begin[5] != ':') {
|
||||
break;
|
||||
}
|
||||
|
||||
*tz_not_found = 0;
|
||||
tmp = sHOUR(strtol(begin, NULL, 10)) + sMIN(strtol(begin + 3, NULL, 10)) + strtol(begin + 6, NULL, 10);
|
||||
return tmp;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -945,7 +968,7 @@ second = minute | "60";
|
||||
secondlz = minutelz | "60";
|
||||
meridian = ([AaPp] "."? [Mm] "."?) [\000\t ];
|
||||
tz = "("? [A-Za-z]{1,6} ")"? | [A-Z][a-z]+([_/-][A-Za-z]+)+;
|
||||
tzcorrection = "GMT"? [+-] hour24 ":"? minute?;
|
||||
tzcorrection = "GMT"? [+-] ((hour24 (":"? minute)?) | (hour24lz minutelz secondlz) | (hour24lz ":" minutelz ":" secondlz));
|
||||
|
||||
daysuf = "st" | "nd" | "rd" | "th";
|
||||
|
||||
@@ -963,10 +986,11 @@ weekofyear = "0"[1-9] | [1-4][0-9] | "5"[0-3];
|
||||
monthlz = "0" [0-9] | "1" [0-2];
|
||||
daylz = "0" [0-9] | [1-2][0-9] | "3" [01];
|
||||
|
||||
dayfulls = 'sundays' | 'mondays' | 'tuesdays' | 'wednesdays' | 'thursdays' | 'fridays' | 'saturdays';
|
||||
dayfull = 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday';
|
||||
dayabbr = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun';
|
||||
dayspecial = 'weekday' | 'weekdays';
|
||||
daytext = dayfull | dayabbr | dayspecial;
|
||||
daytext = dayfulls | dayfull | dayabbr | dayspecial;
|
||||
|
||||
monthfull = 'january' | 'february' | 'march' | 'april' | 'may' | 'june' | 'july' | 'august' | 'september' | 'october' | 'november' | 'december';
|
||||
monthabbr = 'jan' | 'feb' | 'mar' | 'apr' | 'may' | 'jun' | 'jul' | 'aug' | 'sep' | 'sept' | 'oct' | 'nov' | 'dec';
|
||||
@@ -978,6 +1002,7 @@ timetiny12 = hour12 space? meridian;
|
||||
timeshort12 = hour12[:.]minutelz space? meridian;
|
||||
timelong12 = hour12[:.]minute[:.]secondlz space? meridian;
|
||||
|
||||
timetiny24 = 't' hour24;
|
||||
timeshort24 = 't'? hour24[:.]minute;
|
||||
timelong24 = 't'? hour24[:.]minute[:.]second;
|
||||
iso8601long = 't'? hour24 [:.] minute [:.] second frac;
|
||||
@@ -1016,7 +1041,7 @@ soap = year4 "-" monthlz "-" daylz "T" hour24lz ":" minutelz ":" sec
|
||||
xmlrpc = year4 monthlz daylz "T" hour24 ":" minutelz ":" secondlz;
|
||||
xmlrpcnocolon = year4 monthlz daylz 't' hour24 minutelz secondlz;
|
||||
wddx = year4 "-" month "-" day "T" hour24 ":" minute ":" second;
|
||||
pgydotd = year4 "."? dayofyear;
|
||||
pgydotd = year4 [.-]? dayofyear;
|
||||
pgtextshort = monthabbr "-" daylz "-" year;
|
||||
pgtextreverse = year "-" monthabbr "-" daylz;
|
||||
mssqltime = hour12 ":" minutelz ":" secondlz [:.] [0-9]+ meridian;
|
||||
@@ -1054,7 +1079,7 @@ relative = relnumber space? (reltextunit | 'week' );
|
||||
relativetext = (reltextnumber|reltexttext) space reltextunit;
|
||||
relativetextweek = reltexttext space 'week';
|
||||
|
||||
weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of';
|
||||
weekdayof = (reltextnumber|reltexttext) space (dayfulls|dayfull|dayabbr) space 'of';
|
||||
|
||||
*/
|
||||
|
||||
@@ -1143,8 +1168,10 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
|
||||
timestampms
|
||||
{
|
||||
timelib_ull i, us;
|
||||
timelib_sll i;
|
||||
timelib_ull us;
|
||||
const char *ptr_before;
|
||||
bool is_negative;
|
||||
|
||||
TIMELIB_INIT;
|
||||
TIMELIB_HAVE_RELATIVE();
|
||||
@@ -1152,11 +1179,16 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
TIMELIB_UNHAVE_TIME();
|
||||
TIMELIB_HAVE_TZ();
|
||||
|
||||
is_negative = *(ptr + 1) == '-';
|
||||
|
||||
i = timelib_get_signed_nr(s, &ptr, 24);
|
||||
|
||||
ptr_before = ptr;
|
||||
us = timelib_get_signed_nr(s, &ptr, 6);
|
||||
us = us * pow(10, 7 - (ptr - ptr_before));
|
||||
if (is_negative) {
|
||||
us *= -1;
|
||||
}
|
||||
|
||||
s->time->y = 1970;
|
||||
s->time->m = 1;
|
||||
@@ -1179,6 +1211,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
DEBUG_OUTPUT("firstdayof | lastdayof");
|
||||
TIMELIB_INIT;
|
||||
TIMELIB_HAVE_RELATIVE();
|
||||
TIMELIB_UNHAVE_TIME();
|
||||
|
||||
/* skip "last day of" or "first day of" */
|
||||
if (*ptr == 'l' || *ptr == 'L') {
|
||||
@@ -1273,19 +1306,21 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
return TIMELIB_TIME24_WITH_ZONE;
|
||||
}
|
||||
|
||||
timeshort24 | timelong24 /* | iso8601short | iso8601norm */ | iso8601long /*| iso8601shorttz | iso8601normtz | iso8601longtz*/
|
||||
timetiny24 | timeshort24 | timelong24 /* | iso8601short | iso8601norm */ | iso8601long /*| iso8601shorttz | iso8601normtz | iso8601longtz*/
|
||||
{
|
||||
int tz_not_found;
|
||||
DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
|
||||
DEBUG_OUTPUT("timetiny24 | timeshort24 | timelong24 | iso8601long");
|
||||
TIMELIB_INIT;
|
||||
TIMELIB_HAVE_TIME();
|
||||
s->time->h = timelib_get_nr(&ptr, 2);
|
||||
s->time->i = timelib_get_nr(&ptr, 2);
|
||||
if (*ptr == ':' || *ptr == '.') {
|
||||
s->time->s = timelib_get_nr(&ptr, 2);
|
||||
s->time->i = timelib_get_nr(&ptr, 2);
|
||||
if (*ptr == ':' || *ptr == '.') {
|
||||
s->time->s = timelib_get_nr(&ptr, 2);
|
||||
|
||||
if (*ptr == '.') {
|
||||
s->time->us = timelib_get_frac_nr(&ptr);
|
||||
if (*ptr == '.') {
|
||||
s->time->us = timelib_get_frac_nr(&ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2242,7 +2277,7 @@ timelib_time *timelib_parse_from_format_with_map(const char *format, const char
|
||||
break;
|
||||
}
|
||||
if (s->time->h > 12) {
|
||||
add_pbf_error(s, TIMELIB_ERR_HOUR_LARGER_THAN_12, "Hour can not be higher than 12", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_HOUR_LARGER_THAN_12, "Hour cannot be higher than 12", string, begin);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2488,7 +2523,7 @@ timelib_time *timelib_parse_from_format_with_map(const char *format, const char
|
||||
break;
|
||||
|
||||
default:
|
||||
add_pbf_error(s, TIMELIB_ERR_DATA_MISSING, "Data missing", string, ptr);
|
||||
add_pbf_error(s, TIMELIB_ERR_DATA_MISSING, "Not enough data available to satisfy format", string, ptr);
|
||||
done = 1;
|
||||
}
|
||||
fptr++;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Generated by re2c 0.15.3 on Mon Dec 21 10:32:02 2020 */
|
||||
#line 1 "parse_iso_intervals.re"
|
||||
/* Generated by re2c 0.15.3 on Fri May 20 11:35:03 2022 */
|
||||
#line 1 "ext/date/lib/parse_iso_intervals.re"
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@@ -176,7 +176,7 @@ static int scan(Scanner *s)
|
||||
std:
|
||||
s->tok = cursor;
|
||||
s->len = 0;
|
||||
#line 204 "parse_iso_intervals.re"
|
||||
#line 204 "ext/date/lib/parse_iso_intervals.re"
|
||||
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ std:
|
||||
if (yych <= '9') goto yy98;
|
||||
yy3:
|
||||
YYDEBUG(3, *YYCURSOR);
|
||||
#line 317 "parse_iso_intervals.re"
|
||||
#line 317 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
add_error(s, "Unexpected character");
|
||||
goto std;
|
||||
@@ -271,7 +271,7 @@ yy5:
|
||||
if (yych == 'T') goto yy14;
|
||||
yy6:
|
||||
YYDEBUG(6, *YYCURSOR);
|
||||
#line 244 "parse_iso_intervals.re"
|
||||
#line 244 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
timelib_sll nr;
|
||||
int in_time = 0;
|
||||
@@ -317,7 +317,7 @@ yy7:
|
||||
YYDEBUG(7, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
YYDEBUG(8, *YYCURSOR);
|
||||
#line 306 "parse_iso_intervals.re"
|
||||
#line 306 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
goto std;
|
||||
}
|
||||
@@ -326,7 +326,7 @@ yy9:
|
||||
YYDEBUG(9, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
YYDEBUG(10, *YYCURSOR);
|
||||
#line 311 "parse_iso_intervals.re"
|
||||
#line 311 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
s->pos = cursor; s->line++;
|
||||
goto std;
|
||||
@@ -661,7 +661,7 @@ yy51:
|
||||
YYDEBUG(57, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
YYDEBUG(58, *YYCURSOR);
|
||||
#line 286 "parse_iso_intervals.re"
|
||||
#line 286 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
DEBUG_OUTPUT("combinedrep");
|
||||
TIMELIB_INIT;
|
||||
@@ -809,7 +809,7 @@ yy83:
|
||||
YYDEBUG(83, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
YYDEBUG(84, *YYCURSOR);
|
||||
#line 220 "parse_iso_intervals.re"
|
||||
#line 220 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
timelib_time *current;
|
||||
|
||||
@@ -910,7 +910,7 @@ yy98:
|
||||
if (yych <= '9') goto yy98;
|
||||
yy100:
|
||||
YYDEBUG(100, *YYCURSOR);
|
||||
#line 209 "parse_iso_intervals.re"
|
||||
#line 209 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
DEBUG_OUTPUT("recurrences");
|
||||
TIMELIB_INIT;
|
||||
@@ -922,7 +922,7 @@ yy100:
|
||||
}
|
||||
#line 924 "<stdout>"
|
||||
}
|
||||
#line 321 "parse_iso_intervals.re"
|
||||
#line 321 "ext/date/lib/parse_iso_intervals.re"
|
||||
|
||||
}
|
||||
#ifdef PHP_WIN32
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
const char *timelib_error_messages[10] = {
|
||||
"No error",
|
||||
"Can not allocate buffer for parsing",
|
||||
"Cannot allocate buffer for parsing",
|
||||
"Corrupt tzfile: The transitions in the file don't always increase",
|
||||
"Corrupt tzfile: The expected 64-bit preamble is missing",
|
||||
"Corrupt tzfile: No abbreviation could be found for a transition",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015-2021 Derick Rethans
|
||||
* Copyright (c) 2015-2022 Derick Rethans
|
||||
* Copyright (c) 2018,2021 MongoDB, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -30,9 +30,9 @@
|
||||
# include "timelib_config.h"
|
||||
#endif
|
||||
|
||||
#define TIMELIB_VERSION 202111
|
||||
#define TIMELIB_EXTENDED_VERSION 20211101
|
||||
#define TIMELIB_ASCII_VERSION "2021.11"
|
||||
#define TIMELIB_VERSION 202112
|
||||
#define TIMELIB_EXTENDED_VERSION 20211201
|
||||
#define TIMELIB_ASCII_VERSION "2021.12"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -364,11 +364,8 @@ static void do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
|
||||
return;
|
||||
|
||||
case TIMELIB_ZONETYPE_ABBR: {
|
||||
timelib_sll tmp;
|
||||
|
||||
tz->is_localtime = 1;
|
||||
tmp = -tz->z;
|
||||
tmp -= tz->dst * 3600;
|
||||
tz->sse += (-tz->z - tz->dst * SECS_PER_HOUR);
|
||||
return;
|
||||
}
|
||||
@@ -382,6 +379,8 @@ static void do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
|
||||
timelib_time_offset *current, *after;
|
||||
timelib_sll adjustment;
|
||||
int in_transition;
|
||||
int32_t actual_offset;
|
||||
timelib_sll actual_transition_time;
|
||||
|
||||
if (!tzi) {
|
||||
return;
|
||||
@@ -389,15 +388,42 @@ static void do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
|
||||
|
||||
current = timelib_get_time_zone_info(tz->sse, tzi);
|
||||
after = timelib_get_time_zone_info(tz->sse - current->offset, tzi);
|
||||
actual_offset = after->offset;
|
||||
actual_transition_time = after->transition_time;
|
||||
if (current->offset == after->offset && tz->have_zone) {
|
||||
/* Make sure we're not missing a DST change because we don't know the actual offset yet */
|
||||
if (current->offset >= 0 && tz->dst && !current->is_dst) {
|
||||
/* Timezone or its DST at or east of UTC, so the local time, interpreted as UTC, leaves DST (as defined in the actual timezone) before the actual local time */
|
||||
timelib_time_offset *earlier;
|
||||
earlier = timelib_get_time_zone_info(tz->sse - current->offset - 7200, tzi);
|
||||
if ((earlier->offset != after->offset) && (tz->sse - earlier->offset < after->transition_time)) {
|
||||
/* Looking behind a bit clarified the actual offset to use */
|
||||
actual_offset = earlier->offset;
|
||||
actual_transition_time = earlier->transition_time;
|
||||
}
|
||||
timelib_time_offset_dtor(earlier);
|
||||
} else if (current->offset <= 0 && current->is_dst && !tz->dst) {
|
||||
/* Timezone west of UTC, so the local time, interpreted as UTC, leaves DST (as defined in the actual timezone) after the actual local time */
|
||||
timelib_time_offset *later;
|
||||
later = timelib_get_time_zone_info(tz->sse - current->offset + 7200, tzi);
|
||||
if ((later->offset != after->offset) && (tz->sse - later->offset >= later->transition_time)) {
|
||||
/* Looking ahead a bit clarified the actual offset to use */
|
||||
actual_offset = later->offset;
|
||||
actual_transition_time = later->transition_time;
|
||||
}
|
||||
timelib_time_offset_dtor(later);
|
||||
}
|
||||
}
|
||||
|
||||
tz->is_localtime = 1;
|
||||
|
||||
in_transition = (
|
||||
((tz->sse - after->offset) >= (after->transition_time + (current->offset - after->offset))) &&
|
||||
((tz->sse - after->offset) < after->transition_time)
|
||||
((tz->sse - actual_offset) >= (actual_transition_time + (current->offset - actual_offset))) &&
|
||||
((tz->sse - actual_offset) < actual_transition_time)
|
||||
);
|
||||
|
||||
if ((current->offset != after->offset) && !in_transition) {
|
||||
adjustment = -after->offset;
|
||||
if ((current->offset != actual_offset) && !in_transition) {
|
||||
adjustment = -actual_offset;
|
||||
} else {
|
||||
adjustment = -current->offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user