Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fold inconsistency #41

Merged
merged 2 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/zoneinfo_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ utcoff_to_dstoff(size_t *trans_idx, long *utcoffs, long *dstoffs,
size_t num_ttinfos);
static int
ts_to_local(size_t *trans_idx, int64_t *trans_utc, long *utcoff,
int64_t *trans_local[2], size_t num_transitions);
int64_t *trans_local[2], size_t num_ttinfos,
size_t num_transitions);

static int
parse_tz_str(PyObject *tz_str_obj, _tzrule *out);
Expand Down Expand Up @@ -905,7 +906,8 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
self->num_ttinfos);

if (ts_to_local(trans_idx, self->trans_list_utc, utcoff,
self->trans_list_wall, self->num_transitions)) {
self->trans_list_wall, self->num_ttinfos,
self->num_transitions)) {
goto error;
}

Expand Down Expand Up @@ -1930,7 +1932,8 @@ utcoff_to_dstoff(size_t *trans_idx, long *utcoffs, long *dstoffs,
*/
static int
ts_to_local(size_t *trans_idx, int64_t *trans_utc, long *utcoff,
int64_t *trans_local[2], size_t num_transitions)
int64_t *trans_local[2], size_t num_ttinfos,
size_t num_transitions)
{
if (num_transitions == 0) {
return 0;
Expand All @@ -1947,7 +1950,7 @@ ts_to_local(size_t *trans_idx, int64_t *trans_utc, long *utcoff,
}

int64_t offset_0, offset_1, buff;
if (num_transitions > 1) {
if (num_ttinfos > 1) {
offset_0 = utcoff[0];
offset_1 = utcoff[trans_idx[0]];

Expand Down
5 changes: 5 additions & 0 deletions tests/data/zoneinfo_data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"Africa/Abidjan": [
"{Wp48S^xk9=GL@E0stWa761SMbT8$j-~f{VGF<>F7KxBg5R*{Ksocg8-YYVul=v7vZzaHN",
"uC=da5UI2rH18c!OnjV{y4u(+A!!VBKmY&$ORw>7UO^(500B;v0RR91bXh%WvBYQl0ssI2",
"00dcD"
],
"Africa/Casablanca": [
"{Wp48S^xk9=GL@E0stWa761SMbT8$j;0b&K$Xx&`7KxBg5R*{N&yjMUR~;C-fDaSOU;q-~",
"FqW+4{YBjbcw}`a!dW>b)R2-0a+uwf`P3{_Y@HuCz}S$J$ZJ>R_V<~|Fk>sgX4=%0vUrh-",
Expand Down
9 changes: 9 additions & 0 deletions tests/test_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,14 @@ def _get_zonedump(cls):

@classmethod
def _populate_zonedump_data(cls):
def _Africa_Abidjan():
LMT = ZoneOffset("LMT", timedelta(seconds=-968))
GMT = ZoneOffset("GMT", ZERO)

return [
ZoneTransition(datetime(1912, 1, 1), LMT, GMT),
]

def _Africa_Casablanca():
P00_s = ZoneOffset("+00", ZERO, ZERO)
P01_d = ZoneOffset("+01", ONE_H, ONE_H)
Expand Down Expand Up @@ -1760,6 +1768,7 @@ def _Pacific_Kiritimati():
]

cls._ZONEDUMP_DATA = {
"Africa/Abidjan": _Africa_Abidjan(),
"Africa/Casablanca": _Africa_Casablanca(),
"America/Los_Angeles": _America_Los_Angeles(),
"America/Santiago": _America_Santiago(),
Expand Down