Skip to content

Commit 60a6fee

Browse files
committed
Revert "Upgrade timelib to 2017.05beta7"
This reverts commit bdd56f3.
1 parent 8af7095 commit 60a6fee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+11866
-14594
lines changed

ext/date/lib/LICENSE.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2017 Derick Rethans
4-
Copyright (c) 2017 MongoDB, Inc.
3+
Copyright (c) 2015 Derick Rethans
54

65
Permission is hereby granted, free of charge, to any person obtaining a copy
76
of this software and associated documentation files (the "Software"), to deal

ext/date/lib/astro.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
| Schlyter, who wrote this in December 1992 |
2727
*/
2828

29-
#include "timelib.h"
3029
#include <stdio.h>
3130
#include <math.h>
31+
#include "timelib.h"
3232

3333
#define days_since_2000_Jan_0(y,m,d) \
3434
(367L*(y)-((7*((y)+(((m)+9)/12)))/4)+((275*(m))/9)+(d)-730530L)
3535

3636
#ifndef PI
37-
# define PI 3.1415926535897932384
37+
#define PI 3.1415926535897932384
3838
#endif
3939

4040
#define RADEG ( 180.0 / PI )
@@ -230,8 +230,7 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
230230
t_loc->i = t_loc->s = 0;
231231
timelib_update_ts(t_loc, NULL);
232232

233-
/* Calculate TS belonging to UTC 00:00 of the current day, for input into
234-
* the algorithm */
233+
/* Calculate TS belonging to UTC 00:00 of the current day */
235234
t_utc = timelib_time_ctor();
236235
t_utc->y = t_loc->y;
237236
t_utc->m = t_loc->m;
@@ -240,8 +239,8 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
240239
timelib_update_ts(t_utc, NULL);
241240

242241
/* Compute d of 12h local mean solar time */
243-
timestamp = t_utc->sse;
244-
d = timelib_ts_to_j2000(timestamp) + 2 - lon/360.0;
242+
timestamp = t_loc->sse;
243+
d = timelib_ts_to_juliandate(timestamp) - lon/360.0;
245244

246245
/* Compute local sidereal time of this moment */
247246
sidtime = astro_revolution(astro_GMST0(d) + 180.0 + lon);
@@ -296,18 +295,14 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
296295
return rc;
297296
}
298297

299-
double timelib_ts_to_julianday(timelib_sll ts)
298+
double timelib_ts_to_juliandate(timelib_sll ts)
300299
{
301300
double tmp;
302301

303-
tmp = (double) ts;
304-
tmp /= (double) 86400;
305-
tmp += (double) 2440587.5;
302+
tmp = ts;
303+
tmp /= 86400;
304+
tmp += 2440587.5;
305+
tmp -= 2451543;
306306

307307
return tmp;
308308
}
309-
310-
double timelib_ts_to_j2000(timelib_sll ts)
311-
{
312-
return timelib_ts_to_julianday(ts) - 2451545;
313-
}

ext/date/lib/dow.c

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424

2525
#include "timelib.h"
26-
#include "timelib_private.h"
2726

2827
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
2928
static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
@@ -138,71 +137,17 @@ void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, time
138137
}
139138
}
140139

141-
void timelib_isodate_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iy, timelib_sll *iw, timelib_sll *id)
142-
{
143-
timelib_isoweek_from_date(y, m, d, iw, iy);
144-
*id = timelib_day_of_week_ex(y, m, d, 1);
145-
}
146-
147-
static timelib_sll timelib_daynr_from_weeknr_ex(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y)
140+
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d)
148141
{
149142
timelib_sll dow, day;
150143

151144
/* Figure out the dayofweek for y-1-1 */
152-
dow = timelib_day_of_week(iy, 1, 1);
145+
dow = timelib_day_of_week(y, 1, 1);
153146
/* then use that to figure out the offset for day 1 of week 1 */
154147
day = 0 - (dow > 4 ? dow - 7 : dow);
155-
/* and adjust the year to the natural year if we need to */
156-
*y = (iw == 1 && day < 0 && id < dow) ? iy - 1 : iy;
157148

158149
/* Add weeks and days */
159-
return day + ((iw - 1) * 7) + id;
160-
}
161-
162-
timelib_sll timelib_daynr_from_weeknr(timelib_sll iy, timelib_sll iw, timelib_sll id)
163-
{
164-
timelib_sll dummy_iso_year;
165-
166-
return timelib_daynr_from_weeknr_ex(iy, iw, id, &dummy_iso_year);
167-
}
168-
169-
void timelib_date_from_isodate(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y, timelib_sll *m, timelib_sll *d)
170-
{
171-
timelib_sll daynr = timelib_daynr_from_weeknr_ex(iy, iw, id, y) + 1;
172-
int *table;
173-
174-
*m = 0;
175-
176-
if (daynr <= 0) {
177-
*y += 1;
178-
}
179-
180-
if (timelib_is_leap(*y)) {
181-
table = ml_table_leap;
182-
if (daynr > 366) {
183-
*y += 1;
184-
daynr -= 366;
185-
}
186-
} else {
187-
table = ml_table_common;
188-
if (daynr > 365) {
189-
*y += 1;
190-
daynr -= 365;
191-
}
192-
}
193-
194-
do {
195-
daynr -= table[*m];
196-
(*m)++;
197-
} while (daynr > table[*m]);
198-
199-
if (daynr <= 0) {
200-
daynr += 31;
201-
*y -= 1;
202-
*m = 12;
203-
}
204-
205-
*d = daynr;
150+
return day + ((w - 1) * 7) + d;
206151
}
207152

208153
int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s)

ext/date/lib/fallbackmap.h

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
{ "sst", 0, -660 * 60, "Pacific/Apia" },
2-
{ "hst", 0, -600 * 60, "Pacific/Honolulu" },
3-
{ "akst", 0, -540 * 60, "America/Anchorage" },
4-
{ "akdt", 1, -480 * 60, "America/Anchorage" },
5-
{ "pst", 0, -480 * 60, "America/Los_Angeles" },
6-
{ "pdt", 1, -420 * 60, "America/Los_Angeles" },
7-
{ "mst", 0, -420 * 60, "America/Denver" },
8-
{ "mdt", 1, -360 * 60, "America/Denver" },
9-
{ "cst", 0, -360 * 60, "America/Chicago" },
10-
{ "cdt", 1, -300 * 60, "America/Chicago" },
11-
{ "est", 0, -300 * 60, "America/New_York" },
12-
{ "vet", 0, -270 * 60, "America/Caracas" },
13-
{ "edt", 1, -240 * 60, "America/New_York" },
14-
{ "ast", 0, -240 * 60, "America/Halifax" },
15-
{ "adt", 1, -180 * 60, "America/Halifax" },
16-
{ "brt", 0, -180 * 60, "America/Sao_Paulo" },
17-
{ "brst", 1, -120 * 60, "America/Sao_Paulo" },
18-
{ "azost", 0, -60 * 60, "Atlantic/Azores" },
19-
{ "azodt", 1, 0 * 60, "Atlantic/Azores" },
20-
{ "gmt", 0, 0 * 60, "Europe/London" },
21-
{ "bst", 1, 60 * 60, "Europe/London" },
22-
{ "cet", 0, 60 * 60, "Europe/Paris" },
23-
{ "cest", 1, 120 * 60, "Europe/Paris" },
24-
{ "eet", 0, 120 * 60, "Europe/Helsinki" },
25-
{ "eest", 1, 180 * 60, "Europe/Helsinki" },
26-
{ "msk", 0, 180 * 60, "Europe/Moscow" },
27-
{ "msd", 1, 240 * 60, "Europe/Moscow" },
28-
{ "gst", 0, 240 * 60, "Asia/Dubai" },
29-
{ "pkt", 0, 300 * 60, "Asia/Karachi" },
30-
{ "ist", 0, 330 * 60, "Asia/Kolkata" },
31-
{ "npt", 0, 345 * 60, "Asia/Katmandu" },
32-
{ "yekt", 1, 360 * 60, "Asia/Yekaterinburg" },
33-
{ "novst", 1, 420 * 60, "Asia/Novosibirsk" },
34-
{ "krat", 0, 420 * 60, "Asia/Krasnoyarsk" },
35-
{ "cst", 0, 480 * 60, "Asia/Shanghai" },
36-
{ "krast", 1, 480 * 60, "Asia/Krasnoyarsk" },
37-
{ "jst", 0, 540 * 60, "Asia/Tokyo" },
38-
{ "est", 0, 600 * 60, "Australia/Melbourne" },
39-
{ "cst", 1, 630 * 60, "Australia/Adelaide" },
40-
{ "est", 1, 660 * 60, "Australia/Melbourne" },
41-
{ "nzst", 0, 720 * 60, "Pacific/Auckland" },
42-
{ "nzdt", 1, 780 * 60, "Pacific/Auckland" },
1+
{ "sst", 0, -660, "Pacific/Apia" },
2+
{ "hst", 0, -600, "Pacific/Honolulu" },
3+
{ "akst", 0, -540, "America/Anchorage" },
4+
{ "akdt", 1, -480, "America/Anchorage" },
5+
{ "pst", 0, -480, "America/Los_Angeles" },
6+
{ "pdt", 1, -420, "America/Los_Angeles" },
7+
{ "mst", 0, -420, "America/Denver" },
8+
{ "mdt", 1, -360, "America/Denver" },
9+
{ "cst", 0, -360, "America/Chicago" },
10+
{ "cdt", 1, -300, "America/Chicago" },
11+
{ "est", 0, -300, "America/New_York" },
12+
{ "vet", 0, -270, "America/Caracas" },
13+
{ "edt", 1, -240, "America/New_York" },
14+
{ "ast", 0, -240, "America/Halifax" },
15+
{ "adt", 1, -180, "America/Halifax" },
16+
{ "brt", 0, -180, "America/Sao_Paulo" },
17+
{ "brst", 1, -120, "America/Sao_Paulo" },
18+
{ "azost", 0, -60, "Atlantic/Azores" },
19+
{ "azodt", 1, 0, "Atlantic/Azores" },
20+
{ "gmt", 0, 0, "Europe/London" },
21+
{ "bst", 1, 60, "Europe/London" },
22+
{ "cet", 0, 60, "Europe/Paris" },
23+
{ "cest", 1, 120, "Europe/Paris" },
24+
{ "eet", 0, 120, "Europe/Helsinki" },
25+
{ "eest", 1, 180, "Europe/Helsinki" },
26+
{ "msk", 0, 180, "Europe/Moscow" },
27+
{ "msd", 1, 240, "Europe/Moscow" },
28+
{ "gst", 0, 240, "Asia/Dubai" },
29+
{ "pkt", 0, 300, "Asia/Karachi" },
30+
{ "ist", 0, 330, "Asia/Kolkata" },
31+
{ "npt", 0, 345, "Asia/Katmandu" },
32+
{ "yekt", 1, 360, "Asia/Yekaterinburg" },
33+
{ "novst", 1, 420, "Asia/Novosibirsk" },
34+
{ "krat", 0, 420, "Asia/Krasnoyarsk" },
35+
{ "cst", 0, 480, "Asia/Shanghai" },
36+
{ "krast", 1, 480, "Asia/Krasnoyarsk" },
37+
{ "jst", 0, 540, "Asia/Tokyo" },
38+
{ "est", 0, 600, "Australia/Melbourne" },
39+
{ "cst", 1, 630, "Australia/Adelaide" },
40+
{ "est", 1, 660, "Australia/Melbourne" },
41+
{ "nzst", 0, 720, "Pacific/Auckland" },
42+
{ "nzdt", 1, 780, "Pacific/Auckland" },

ext/date/lib/interval.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424

2525
#include "timelib.h"
26-
#include "timelib_private.h"
2726
#include <math.h>
2827

2928
timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
@@ -66,7 +65,6 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
6665
rt->h = two->h - one->h;
6766
rt->i = two->i - one->i;
6867
rt->s = two->s - one->s;
69-
rt->us = two->us - one->us;
7068
if (one_backup.dst == 0 && two_backup.dst == 1 && two->sse >= one->sse + 86400 - dst_corr) {
7169
rt->h += dst_h_corr;
7270
rt->i += dst_m_corr;
@@ -112,7 +110,6 @@ timelib_time *timelib_add(timelib_time *old_time, timelib_rel_time *interval)
112110
t->relative.h = interval->h * bias;
113111
t->relative.i = interval->i * bias;
114112
t->relative.s = interval->s * bias;
115-
t->relative.us = interval->us * bias;
116113
}
117114
t->have_relative = 1;
118115
t->sse_uptodate = 0;
@@ -148,7 +145,6 @@ timelib_time *timelib_sub(timelib_time *old_time, timelib_rel_time *interval)
148145
t->relative.h = 0 - (interval->h * bias);
149146
t->relative.i = 0 - (interval->i * bias);
150147
t->relative.s = 0 - (interval->s * bias);
151-
t->relative.us = 0 - (interval->us * bias);
152148
t->have_relative = 1;
153149
t->sse_uptodate = 0;
154150

0 commit comments

Comments
 (0)