Skip to content

Commit 2bf451b

Browse files
committed
Upgrade timelib to 2021.08, which address some defects and performance
- Fixed bug #80998 (Missing second with inverted interval). - Speed up finding timezone offset information.
1 parent 14f599e commit 2bf451b

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ PHP NEWS
99
. Dispatch using LANG_NEUTRAL instead of LOCALE_SYSTEM_DEFAULT. (Dmitry
1010
Maksimov)
1111

12+
- Date:
13+
. Fixed bug #80998 (Missing second with inverted interval). (Derick)
14+
. Speed up finding timezone offset information. (Derick)
15+
1216
19 Aug 2021, PHP 8.1.0beta3
1317

1418
- Core:

ext/date/lib/interval.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ timelib_time *timelib_add_wall(timelib_time *old_time, timelib_rel_time *interva
232232
memcpy(&t->relative, interval, sizeof(timelib_rel_time));
233233

234234
timelib_update_ts(t, NULL);
235+
236+
timelib_update_from_sse(t);
235237
} else {
236238
if (interval->invert) {
237239
bias = -1;
@@ -247,11 +249,14 @@ timelib_time *timelib_add_wall(timelib_time *old_time, timelib_rel_time *interva
247249

248250
do_range_limit(0, 1000000, 1000000, &interval->us, &interval->s);
249251
t->sse += bias * timelib_hms_to_seconds(interval->h, interval->i, interval->s);
252+
timelib_update_from_sse(t);
250253
t->us += interval->us * bias;
254+
if (bias == -1 && interval->us > 0) {
255+
t->sse--;
256+
}
251257
timelib_do_normalize(t);
252258
}
253259

254-
timelib_update_from_sse(t);
255260
if (t->zone_type == TIMELIB_ZONETYPE_ID) {
256261
timelib_set_timezone(t, t->tz_info);
257262
}
@@ -287,7 +292,11 @@ timelib_time *timelib_sub_wall(timelib_time *old_time, timelib_rel_time *interva
287292

288293
do_range_limit(0, 1000000, 1000000, &interval->us, &interval->s);
289294
t->sse -= bias * timelib_hms_to_seconds(interval->h, interval->i, interval->s);
295+
timelib_update_from_sse(t);
290296
t->us -= interval->us * bias;
297+
if (bias == -1 && interval->us > 0) {
298+
t->sse++;
299+
}
291300
timelib_do_normalize(t);
292301
}
293302

ext/date/lib/parse_date.re

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <ctype.h>
3030
#include <math.h>
3131
#include <assert.h>
32+
#include <limits.h>
3233

3334
#if defined(_MSC_VER)
3435
# define strtoll(s, f, b) _atoi64(s)
@@ -166,7 +167,13 @@ static const timelib_tz_lookup_table timelib_timezone_utc[] = {
166167
{ "utc", 0, 0, "UTC" },
167168
};
168169

169-
#define MAX_ABBR_LEN 5 /* the longest name in "timezonemap.h" and "fallbackmap.h" */
170+
#if defined(_POSIX_TZNAME_MAX)
171+
# define MAX_ABBR_LEN _POSIX_TZNAME_MAX
172+
#elif defined(TZNAME_MAX)
173+
# define MAX_ABBR_LEN TZNAME_MAX
174+
#else
175+
# define MAX_ABBR_LEN 6
176+
#endif
170177

171178
static timelib_relunit const timelib_relunit_lookup[] = {
172179
{ "ms", TIMELIB_MICROSEC, 1000 },

ext/date/lib/timelib.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
# include "timelib_config.h"
3131
#endif
3232

33-
#define TIMELIB_VERSION 202107
34-
#define TIMELIB_EXTENDED_VERSION 20210701
35-
#define TIMELIB_ASCII_VERSION "2021.07"
33+
#define TIMELIB_VERSION 202108
34+
#define TIMELIB_EXTENDED_VERSION 20210801
35+
#define TIMELIB_ASCII_VERSION "2021.08"
3636

3737
#include <stdlib.h>
3838
#include <stdbool.h>

0 commit comments

Comments
 (0)