Skip to content

Commit e84286d

Browse files
committed
Makes .offset_hours return a float.
1 parent df1ff91 commit e84286d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/index.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,11 @@ Pendulum gives access to more attributes and properties than the default `dateti
335335
pendulum.from_timestamp(0, 'America/Toronto').offset
336336
-18000
337337
338-
# Returns an int of hours difference from UTC (+/- sign included)
338+
# Returns a float of hours difference from UTC (+/- sign included)
339339
pendulum.from_timestamp(0, 'America/Toronto').offset_hours
340-
-5
340+
-5.0
341+
pendulum.from_timestamp(0, 'Australia/Adelaide').offset_hours
342+
9.5
341343
342344
# Indicates if day light savings time is on
343345
pendulum.from_date(2012, 1, 1, 'America/Toronto').is_dst

tests/pendulum_tests/test_getters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def test_offset_hours_no_dst(self):
107107
def test_offset_hours_for_gmt(self):
108108
self.assertEqual(0, Pendulum.create_from_date(2012, 6, 1, 'GMT').offset_hours)
109109

110+
def test_offset_hours_float(self):
111+
self.assertEqual(9.5, Pendulum.create_from_date(2012, 6, 1, 9.5).offset_hours)
112+
110113
def test_is_leap_year(self):
111114
self.assertTrue(Pendulum.create_from_date(2012, 1, 1).is_leap_year())
112115
self.assertFalse(Pendulum.create_from_date(2011, 1, 1).is_leap_year())

0 commit comments

Comments
 (0)