Permalink
Browse files

Upgrade timelib to 2017.05beta7

  • Loading branch information...
derickr committed Aug 15, 2017
1 parent 3af6201 commit bdd56f31078bf1f34341943603cf6aaa72e0db5c
Showing with 38,226 additions and 11,828 deletions.
  1. +2 −1 ext/date/lib/LICENSE.rst
  2. +15 −10 ext/date/lib/astro.c
  3. +58 −3 ext/date/lib/dow.c
  4. +42 −42 ext/date/lib/fallbackmap.h
  5. +4 −0 ext/date/lib/interval.c
  6. +11,931 −9,284 ext/date/lib/parse_date.c
  7. +23,670 −0 ext/date/lib/parse_date.c.orig
  8. +178 −113 ext/date/lib/parse_date.re
  9. +154 −133 ext/date/lib/parse_iso_intervals.c
  10. +3 −81 ext/date/lib/parse_iso_intervals.re
  11. +231 −64 ext/date/lib/parse_tz.c
  12. +66 −121 ext/date/lib/timelib.c
  13. +761 −39 ext/date/lib/timelib.h
  14. +6 −3 ext/date/lib/timelib.m4
  15. +158 −0 ext/date/lib/timelib_private.h
  16. +0 −315 ext/date/lib/timelib_structs.h
  17. +41 −730 ext/date/lib/timezonemap.h
  18. +57 −9 ext/date/lib/tm2unixtime.c
  19. +4 −15 ext/date/lib/unixtime2tm.c
  20. +25 −23 ext/date/php_date.c
  21. +5 −14 ext/date/tests/010.phpt
  22. +0 −21 ext/date/tests/DateTimeZone_getLocation.phpt
  23. +28 −19 ext/date/tests/DateTimeZone_listAbbreviations_basic1.phpt
  24. +1 −1 ext/date/tests/bug35499.phpt
  25. +6 −6 ext/date/tests/bug41964.phpt
  26. +1 −1 ext/date/tests/bug45081.phpt
  27. +3 −3 ext/date/tests/bug68078_negative.phpt
  28. +2 −2 ext/date/tests/date_parse_001.phpt
  29. +9 −9 ext/date/tests/date_sun_info_001.phpt
  30. +9 −9 ext/date/tests/date_sun_info_002.phpt
  31. +154 −154 ext/date/tests/date_sun_info_variation1.phpt
  32. +149 −149 ext/date/tests/date_sun_info_variation2.phpt
  33. +153 −153 ext/date/tests/date_sun_info_variation3.phpt
  34. +30 −30 ext/date/tests/date_sunrise_variation1.phpt
  35. +10 −10 ext/date/tests/date_sunrise_variation3.phpt
  36. +34 −34 ext/date/tests/date_sunrise_variation4.phpt
  37. +5 −5 ext/date/tests/date_sunrise_variation5.phpt
  38. +36 −36 ext/date/tests/date_sunrise_variation6.phpt
  39. +5 −5 ext/date/tests/date_sunrise_variation7.phpt
  40. +30 −30 ext/date/tests/date_sunset_variation1.phpt
  41. +23 −23 ext/date/tests/date_sunset_variation3.phpt
  42. +23 −23 ext/date/tests/date_sunset_variation4.phpt
  43. +2 −2 ext/date/tests/date_sunset_variation5.phpt
  44. +36 −36 ext/date/tests/date_sunset_variation6.phpt
  45. +7 −7 ext/date/tests/date_sunset_variation7.phpt
  46. +24 −24 ext/date/tests/sunfuncts.phpt
  47. +29 −20 ext/date/tests/timezone_abbreviations_list_basic1.phpt
  48. +2 −12 ext/date/tests/timezone_name_from_abbr_basic1.phpt
  49. +2 −2 ext/intl/common/common_date.cpp
  50. +2 −2 ext/intl/timezone/timezone_class.cpp
View
@@ -1,6 +1,7 @@
The MIT License (MIT)
Copyright (c) 2015 Derick Rethans
Copyright (c) 2015-2017 Derick Rethans
Copyright (c) 2017 MongoDB, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
@@ -26,15 +26,15 @@
| Schlyter, who wrote this in December 1992 |
*/
#include "timelib.h"
#include <stdio.h>
#include <math.h>
#include "timelib.h"
#define days_since_2000_Jan_0(y,m,d) \
(367L*(y)-((7*((y)+(((m)+9)/12)))/4)+((275*(m))/9)+(d)-730530L)
#ifndef PI
#define PI 3.1415926535897932384
# define PI 3.1415926535897932384
#endif
#define RADEG ( 180.0 / PI )
@@ -230,7 +230,8 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
t_loc->i = t_loc->s = 0;
timelib_update_ts(t_loc, NULL);
/* Calculate TS belonging to UTC 00:00 of the current day */
/* Calculate TS belonging to UTC 00:00 of the current day, for input into
* the algorithm */
t_utc = timelib_time_ctor();
t_utc->y = t_loc->y;
t_utc->m = t_loc->m;
@@ -239,8 +240,8 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
timelib_update_ts(t_utc, NULL);
/* Compute d of 12h local mean solar time */
timestamp = t_loc->sse;
d = timelib_ts_to_juliandate(timestamp) - lon/360.0;
timestamp = t_utc->sse;
d = timelib_ts_to_j2000(timestamp) + 2 - lon/360.0;
/* Compute local sidereal time of this moment */
sidtime = astro_revolution(astro_GMST0(d) + 180.0 + lon);
@@ -295,14 +296,18 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
return rc;
}
double timelib_ts_to_juliandate(timelib_sll ts)
double timelib_ts_to_julianday(timelib_sll ts)
{
double tmp;
tmp = ts;
tmp /= 86400;
tmp += 2440587.5;
tmp -= 2451543;
tmp = (double) ts;
tmp /= (double) 86400;
tmp += (double) 2440587.5;
return tmp;
}
double timelib_ts_to_j2000(timelib_sll ts)
{
return timelib_ts_to_julianday(ts) - 2451545;
}
View
@@ -23,6 +23,7 @@
*/
#include "timelib.h"
#include "timelib_private.h"
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
@@ -137,17 +138,71 @@ void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, time
}
}
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d)
void timelib_isodate_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iy, timelib_sll *iw, timelib_sll *id)
{
timelib_isoweek_from_date(y, m, d, iw, iy);
*id = timelib_day_of_week_ex(y, m, d, 1);
}
static timelib_sll timelib_daynr_from_weeknr_ex(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y)
{
timelib_sll dow, day;
/* Figure out the dayofweek for y-1-1 */
dow = timelib_day_of_week(y, 1, 1);
dow = timelib_day_of_week(iy, 1, 1);
/* then use that to figure out the offset for day 1 of week 1 */
day = 0 - (dow > 4 ? dow - 7 : dow);
/* and adjust the year to the natural year if we need to */
*y = (iw == 1 && day < 0 && id < dow) ? iy - 1 : iy;
/* Add weeks and days */
return day + ((w - 1) * 7) + d;
return day + ((iw - 1) * 7) + id;
}
timelib_sll timelib_daynr_from_weeknr(timelib_sll iy, timelib_sll iw, timelib_sll id)
{
timelib_sll dummy_iso_year;
return timelib_daynr_from_weeknr_ex(iy, iw, id, &dummy_iso_year);
}
void timelib_date_from_isodate(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y, timelib_sll *m, timelib_sll *d)
{
timelib_sll daynr = timelib_daynr_from_weeknr_ex(iy, iw, id, y) + 1;
int *table;
*m = 0;
if (daynr <= 0) {
*y += 1;

This comment has been minimized.

Show comment
Hide comment
@KsaR99

KsaR99 Sep 8, 2017

In case of pointers, not better do (*y)++ ? will look nicer 🌝

@KsaR99

KsaR99 Sep 8, 2017

In case of pointers, not better do (*y)++ ? will look nicer 🌝

}
if (timelib_is_leap(*y)) {
table = ml_table_leap;
if (daynr > 366) {
*y += 1;
daynr -= 366;
}
} else {
table = ml_table_common;
if (daynr > 365) {
*y += 1;
daynr -= 365;
}
}
do {
daynr -= table[*m];
(*m)++;
} while (daynr > table[*m]);
if (daynr <= 0) {
daynr += 31;
*y -= 1;
*m = 12;
}
*d = daynr;
}
int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s)
View
@@ -1,42 +1,42 @@
{ "sst", 0, -660, "Pacific/Apia" },
{ "hst", 0, -600, "Pacific/Honolulu" },
{ "akst", 0, -540, "America/Anchorage" },
{ "akdt", 1, -480, "America/Anchorage" },
{ "pst", 0, -480, "America/Los_Angeles" },
{ "pdt", 1, -420, "America/Los_Angeles" },
{ "mst", 0, -420, "America/Denver" },
{ "mdt", 1, -360, "America/Denver" },
{ "cst", 0, -360, "America/Chicago" },
{ "cdt", 1, -300, "America/Chicago" },
{ "est", 0, -300, "America/New_York" },
{ "vet", 0, -270, "America/Caracas" },
{ "edt", 1, -240, "America/New_York" },
{ "ast", 0, -240, "America/Halifax" },
{ "adt", 1, -180, "America/Halifax" },
{ "brt", 0, -180, "America/Sao_Paulo" },
{ "brst", 1, -120, "America/Sao_Paulo" },
{ "azost", 0, -60, "Atlantic/Azores" },
{ "azodt", 1, 0, "Atlantic/Azores" },
{ "gmt", 0, 0, "Europe/London" },
{ "bst", 1, 60, "Europe/London" },
{ "cet", 0, 60, "Europe/Paris" },
{ "cest", 1, 120, "Europe/Paris" },
{ "eet", 0, 120, "Europe/Helsinki" },
{ "eest", 1, 180, "Europe/Helsinki" },
{ "msk", 0, 180, "Europe/Moscow" },
{ "msd", 1, 240, "Europe/Moscow" },
{ "gst", 0, 240, "Asia/Dubai" },
{ "pkt", 0, 300, "Asia/Karachi" },
{ "ist", 0, 330, "Asia/Kolkata" },
{ "npt", 0, 345, "Asia/Katmandu" },
{ "yekt", 1, 360, "Asia/Yekaterinburg" },
{ "novst", 1, 420, "Asia/Novosibirsk" },
{ "krat", 0, 420, "Asia/Krasnoyarsk" },
{ "cst", 0, 480, "Asia/Shanghai" },
{ "krast", 1, 480, "Asia/Krasnoyarsk" },
{ "jst", 0, 540, "Asia/Tokyo" },
{ "est", 0, 600, "Australia/Melbourne" },
{ "cst", 1, 630, "Australia/Adelaide" },
{ "est", 1, 660, "Australia/Melbourne" },
{ "nzst", 0, 720, "Pacific/Auckland" },
{ "nzdt", 1, 780, "Pacific/Auckland" },
{ "sst", 0, -660 * 60, "Pacific/Apia" },
{ "hst", 0, -600 * 60, "Pacific/Honolulu" },
{ "akst", 0, -540 * 60, "America/Anchorage" },
{ "akdt", 1, -480 * 60, "America/Anchorage" },
{ "pst", 0, -480 * 60, "America/Los_Angeles" },
{ "pdt", 1, -420 * 60, "America/Los_Angeles" },
{ "mst", 0, -420 * 60, "America/Denver" },
{ "mdt", 1, -360 * 60, "America/Denver" },
{ "cst", 0, -360 * 60, "America/Chicago" },
{ "cdt", 1, -300 * 60, "America/Chicago" },
{ "est", 0, -300 * 60, "America/New_York" },
{ "vet", 0, -270 * 60, "America/Caracas" },
{ "edt", 1, -240 * 60, "America/New_York" },
{ "ast", 0, -240 * 60, "America/Halifax" },
{ "adt", 1, -180 * 60, "America/Halifax" },
{ "brt", 0, -180 * 60, "America/Sao_Paulo" },
{ "brst", 1, -120 * 60, "America/Sao_Paulo" },
{ "azost", 0, -60 * 60, "Atlantic/Azores" },
{ "azodt", 1, 0 * 60, "Atlantic/Azores" },
{ "gmt", 0, 0 * 60, "Europe/London" },
{ "bst", 1, 60 * 60, "Europe/London" },
{ "cet", 0, 60 * 60, "Europe/Paris" },
{ "cest", 1, 120 * 60, "Europe/Paris" },
{ "eet", 0, 120 * 60, "Europe/Helsinki" },
{ "eest", 1, 180 * 60, "Europe/Helsinki" },
{ "msk", 0, 180 * 60, "Europe/Moscow" },
{ "msd", 1, 240 * 60, "Europe/Moscow" },
{ "gst", 0, 240 * 60, "Asia/Dubai" },
{ "pkt", 0, 300 * 60, "Asia/Karachi" },
{ "ist", 0, 330 * 60, "Asia/Kolkata" },
{ "npt", 0, 345 * 60, "Asia/Katmandu" },
{ "yekt", 1, 360 * 60, "Asia/Yekaterinburg" },
{ "novst", 1, 420 * 60, "Asia/Novosibirsk" },
{ "krat", 0, 420 * 60, "Asia/Krasnoyarsk" },
{ "cst", 0, 480 * 60, "Asia/Shanghai" },
{ "krast", 1, 480 * 60, "Asia/Krasnoyarsk" },
{ "jst", 0, 540 * 60, "Asia/Tokyo" },
{ "est", 0, 600 * 60, "Australia/Melbourne" },
{ "cst", 1, 630 * 60, "Australia/Adelaide" },
{ "est", 1, 660 * 60, "Australia/Melbourne" },
{ "nzst", 0, 720 * 60, "Pacific/Auckland" },
{ "nzdt", 1, 780 * 60, "Pacific/Auckland" },
View
@@ -23,6 +23,7 @@
*/
#include "timelib.h"
#include "timelib_private.h"
#include <math.h>
timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
@@ -65,6 +66,7 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
rt->h = two->h - one->h;
rt->i = two->i - one->i;
rt->s = two->s - one->s;
rt->us = two->us - one->us;
if (one_backup.dst == 0 && two_backup.dst == 1 && two->sse >= one->sse + 86400 - dst_corr) {
rt->h += dst_h_corr;
rt->i += dst_m_corr;
@@ -110,6 +112,7 @@ timelib_time *timelib_add(timelib_time *old_time, timelib_rel_time *interval)
t->relative.h = interval->h * bias;
t->relative.i = interval->i * bias;
t->relative.s = interval->s * bias;
t->relative.us = interval->us * bias;
}
t->have_relative = 1;
t->sse_uptodate = 0;
@@ -145,6 +148,7 @@ timelib_time *timelib_sub(timelib_time *old_time, timelib_rel_time *interval)
t->relative.h = 0 - (interval->h * bias);
t->relative.i = 0 - (interval->i * bias);
t->relative.s = 0 - (interval->s * bias);
t->relative.us = 0 - (interval->us * bias);
t->have_relative = 1;
t->sse_uptodate = 0;
Oops, something went wrong.

8 comments on commit bdd56f3

@Jan-E

This comment has been minimized.

Show comment
Hide comment
@Jan-E

Jan-E Aug 16, 2017

@derickr This upgrade somehow triggered an error when compiling php_mongodb.dll (Windows, VC14):

ext\mongodb\src\BSON\UTCDateTime.c(131): error C2039: 'f': is not a member of 'timelib_time'
n:\php-sdk\php71dev\ext\date\lib/timelib.h(204): note: see declaration of 'timelib_time'
ext\mongodb\src\BSON\UTCDateTime.c(131): error C2168: 'floor': too few actual parameters for intrinsic function
ext\mongodb\src\BSON\UTCDateTime.c(259): error C2039: 'f': is not a member of 'timelib_time'
n:\php-sdk\php71dev\ext\date\lib/timelib.h(204): note: see declaration of 'timelib_time'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe"' : return code '0x2'
Stop.

Jan-E replied Aug 16, 2017

@derickr This upgrade somehow triggered an error when compiling php_mongodb.dll (Windows, VC14):

ext\mongodb\src\BSON\UTCDateTime.c(131): error C2039: 'f': is not a member of 'timelib_time'
n:\php-sdk\php71dev\ext\date\lib/timelib.h(204): note: see declaration of 'timelib_time'
ext\mongodb\src\BSON\UTCDateTime.c(131): error C2168: 'floor': too few actual parameters for intrinsic function
ext\mongodb\src\BSON\UTCDateTime.c(259): error C2039: 'f': is not a member of 'timelib_time'
n:\php-sdk\php71dev\ext\date\lib/timelib.h(204): note: see declaration of 'timelib_time'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe"' : return code '0x2'
Stop.

@Jan-E

This comment has been minimized.

Show comment
Hide comment
@Jan-E

Jan-E replied Aug 16, 2017

Issue filed here: mongodb/mongo-php-driver#632

@Jan-E

This comment has been minimized.

Show comment
Hide comment
@Jan-E

Jan-E Aug 16, 2017

mongodb happened to be the only extension in my build tree that stumbled over this commit, but others may suffer as well. Is it a BC break for PHP 7.1+ ?
pinging the RM's: @sgolemon @krakjoe

Jan-E replied Aug 16, 2017

mongodb happened to be the only extension in my build tree that stumbled over this commit, but others may suffer as well. Is it a BC break for PHP 7.1+ ?
pinging the RM's: @sgolemon @krakjoe

@remicollet

This comment has been minimized.

Show comment
Hide comment
@remicollet

remicollet Aug 16, 2017

Contributor
-	double           f;           /* Fraction */
+	timelib_sll      us;          /* Microseconds */

indeed, this look like a BC break (and this have been apply in 7.0+, is not part of 7.0.23RC1/7.2.0beta3 but part of 7.1.9RC1)

Contributor

remicollet replied Aug 16, 2017

-	double           f;           /* Fraction */
+	timelib_sll      us;          /* Microseconds */

indeed, this look like a BC break (and this have been apply in 7.0+, is not part of 7.0.23RC1/7.2.0beta3 but part of 7.1.9RC1)

@remicollet

This comment has been minimized.

Show comment
Hide comment
@remicollet

remicollet Aug 16, 2017

Contributor

Also ping @dshafik (7.1) @weltling @Tyrael (7.0)

Contributor

remicollet replied Aug 16, 2017

Also ping @dshafik (7.1) @weltling @Tyrael (7.0)

@remicollet

This comment has been minimized.

Show comment
Hide comment
@remicollet

remicollet Aug 16, 2017

Contributor

This change have been reverted in 7.0 and 7.1

Contributor

remicollet replied Aug 16, 2017

This change have been reverted in 7.0 and 7.1

@Majkl578

This comment has been minimized.

Show comment
Hide comment
@Majkl578

Majkl578 Sep 7, 2017

Contributor

I don't really understand why API/ABI breaks are accepted for RC phase. :/ Wish this was reverted for 7.2 too as it's causing much pain quite late in the release cycle when PHP users are already starting PHP 7.2 adoption on Travis etc...
We're now seeing Travis failures due to this breakage regarding Mongo driver mentioned above. Travis is still running 7.2.0beta3 and Mongo driver has broken compatibility today in version 1.2.10 -- this release addresses this BC break while breaking compatibility with <RC1.
Reported here: mongodb/mongo-php-driver#649

Contributor

Majkl578 replied Sep 7, 2017

I don't really understand why API/ABI breaks are accepted for RC phase. :/ Wish this was reverted for 7.2 too as it's causing much pain quite late in the release cycle when PHP users are already starting PHP 7.2 adoption on Travis etc...
We're now seeing Travis failures due to this breakage regarding Mongo driver mentioned above. Travis is still running 7.2.0beta3 and Mongo driver has broken compatibility today in version 1.2.10 -- this release addresses this BC break while breaking compatibility with <RC1.
Reported here: mongodb/mongo-php-driver#649

@remicollet

This comment has been minimized.

Show comment
Hide comment
@remicollet

remicollet Sep 8, 2017

Contributor

API/ABI break are not acceptable in RC phase, this one was discovered and thus revert in 7.0 and 7.1. It happens in 7.2 "before" RC.

Contributor

remicollet replied Sep 8, 2017

API/ABI break are not acceptable in RC phase, this one was discovered and thus revert in 7.0 and 7.1. It happens in 7.2 "before" RC.

Please sign in to comment.