Skip to content

Commit 396dbfc

Browse files
sam002derickr
authored andcommitted
FIxed #46: Unix time parsed as non relative
This is PHP issue #76770
1 parent 6fea594 commit 396dbfc

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

parse_date.re

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,18 +2249,15 @@ timelib_time *timelib_parse_from_format_with_map(char *format, char *string, siz
22492249
break;
22502250
case TIMELIB_FORMAT_EPOCH_SECONDS: /* epoch seconds */
22512251
TIMELIB_CHECK_SIGNED_NUMBER;
2252-
TIMELIB_HAVE_RELATIVE();
22532252
tmp = timelib_get_unsigned_nr((char **) &ptr, 24);
2254-
s->time->y = 1970;
2255-
s->time->m = 1;
2256-
s->time->d = 1;
2257-
s->time->h = s->time->i = s->time->s = 0;
2258-
s->time->relative.s += tmp;
2253+
s->time->sse = tmp;
22592254
s->time->is_localtime = 1;
22602255
s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
22612256
s->time->z = 0;
22622257
s->time->dst = 0;
2258+
timelib_update_from_sse(s->time);
22632259
break;
2260+
22642261
case TIMELIB_FORMAT_ANY_SEPARATOR: /* separation symbol */
22652262
if (timelib_lookup_format(*ptr, format_map) == TIMELIB_FORMAT_SEPARATOR) {
22662263
++ptr;

tests/files/epoch-seconds.parseformat

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
TS: 0 | 1970-01-01 00:00:00 GMT 00000 0Y 0M 0D / 0H 0M -12219146756S | U | -12219146756
2-
TS: 0 | 1970-01-01 00:00:00 GMT 00000 0Y 0M 0D / 0H 0M 12219146756S | U | 12219146756
3-
TS: 0 | 1970-01-01 00:00:00 0.123456 GMT 00000 0Y 0M 0D / 0H 0M -12219146756S | U u | -12219146756 123456
4-
TS: 0 | 1970-01-01 00:00:00 0.123456 GMT 00000 0Y 0M 0D / 0H 0M 12219146756S | U u | 12219146756 123456
5-
TS: 0 | 1970-01-01 00:00:00 0.123456 GMT 00000 0Y 0M 0D / 0H 0M -12219146756S | u U | 123456 -12219146756
6-
TS: 0 | 1970-01-01 00:00:00 0.123456 GMT 00000 0Y 0M 0D / 0H 0M 12219146756S | u U | 123456 12219146756
1+
TS: 0 | 1582-10-16 16:34:04 GMT 00000 | U | -12219146756
2+
TS: 0 | 2357-03-18 07:25:56 GMT 00000 | U | 12219146756
3+
TS: 0 | 1582-10-16 16:34:04 0.123456 GMT 00000 | U u | -12219146756 123456
4+
TS: 0 | 2357-03-18 07:25:56 0.123456 GMT 00000 | U u | 12219146756 123456
5+
TS: 0 | 1582-10-16 16:34:04 0.123456 GMT 00000 | u U | 123456 -12219146756
6+
TS: 0 | 2357-03-18 07:25:56 0.123456 GMT 00000 | u U | 123456 12219146756

0 commit comments

Comments
 (0)