Skip to content

Commit 042a966

Browse files
committed
Fixes loading of timezones without transitions.
1 parent 6024485 commit 042a966

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

pendulum/tz/loader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ def _load(cls, fp):
9393
i += 3
9494

9595
# Now build the timezone object
96-
if len(transition_times) == 0:
96+
if not transition_times:
9797
transitions = tuple()
98+
99+
if transition_types:
100+
transitions += (Transition(0, 0, datetime(1970, 1, 1), datetime(1970, 1, 1), 0),)
98101
else:
99102
# calculate transition info
100103
transitions = tuple()

tests/pendulum_tests/test_construct.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,8 @@ def test_create(self):
165165

166166
d = Pendulum.create(microsecond=123456)
167167
self.assertPendulum(d, now.year, now.month, now.day, 0, 0, 0, 123456)
168+
169+
def test_create_with_not_transition_timezone(self):
170+
dt = Pendulum.create(tz='Etc/UTC')
171+
172+
self.assertEqual('Etc/UTC', dt.timezone_name)

tests/tz_tests/test_loader.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ def test_load_from_file_invalid(self):
3030
local_path = os.path.join(os.path.split(__file__)[0], '..')
3131
tz_file = os.path.join(local_path, 'fixtures', 'tz', 'NOT_A_TIMEZONE')
3232
self.assertRaises(ValueError, Loader.load_from_file, tz_file)
33+
34+
def test_set_transitions_for_no_transition_database_file(self):
35+
tz = Loader.load('Etc/UTC')
36+
37+
self.assertEqual(1, len(tz[0]))

0 commit comments

Comments
 (0)