Skip to content

Commit

Permalink
Use timezone.utc instead of pytz.utc
Browse files Browse the repository at this point in the history
These both should equal to 0 as far as tzinfo structure is concerned,
so there is no need to require pytz just to express utc timezone
  • Loading branch information
asfaltboy authored and fitnr committed Nov 7, 2021
1 parent 7c02440 commit 5870536
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
],
python_requires=">=3.5",
install_requires=[
'pytz>=2014.10',
'pymeeus>=0.3.13, <=1'
],
tests_require=tests_require,
Expand Down
15 changes: 11 additions & 4 deletions src/convertdate/julianday.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
The `Julian day <https://en.wikipedia.org/wiki/Julian_day>`__
is a continuous count of days since the beginning of the Julian era on January 1, 4713 BC.
"""
from datetime import datetime

from pytz import utc
from datetime import datetime, timezone

from . import gregorian, julian

Expand All @@ -36,7 +34,16 @@ def to_datetime(jdc):
# down to ms, which are 1/1000 of a second
ms = int(1000 * round(msfrac, 6))

return datetime(year, month, day, int(hours), int(mins), int(secs), int(ms), tzinfo=utc)
return datetime(
year,
month,
day,
int(hours),
int(mins),
int(secs),
int(ms),
tzinfo=timezone.utc
)


def from_datetime(dt):
Expand Down
16 changes: 7 additions & 9 deletions tests/test_general.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
import time
from datetime import datetime

import pytz
from datetime import datetime, timezone

from convertdate import coptic, dublin, gregorian, hebrew, islamic, iso, julian, julianday, ordinal, persian, utils

Expand Down Expand Up @@ -115,16 +113,16 @@ def test_dublin_dc(self):

def test_julian_day(self):
self.assertEqual(julianday.from_gregorian(*self.c_greg), self.c)
self.assertEqual(julianday.to_datetime(self.c), datetime(1492, 10, 21, tzinfo=pytz.utc))
self.assertEqual(julianday.to_datetime(self.x), datetime(2016, 2, 29, tzinfo=pytz.utc))
self.assertEqual(julianday.to_datetime(self.c), datetime(1492, 10, 21, tzinfo=timezone.utc))
self.assertEqual(julianday.to_datetime(self.x), datetime(2016, 2, 29, tzinfo=timezone.utc))

self.assertEqual(julianday.to_datetime(self.c + 0.25), datetime(1492, 10, 21, 6, tzinfo=pytz.utc))
self.assertEqual(julianday.to_datetime(self.x + 0.525), datetime(2016, 2, 29, 12, 36, tzinfo=pytz.utc))
self.assertEqual(julianday.to_datetime(self.c + 0.25), datetime(1492, 10, 21, 6, tzinfo=timezone.utc))
self.assertEqual(julianday.to_datetime(self.x + 0.525), datetime(2016, 2, 29, 12, 36, tzinfo=timezone.utc))

dt = datetime(2014, 11, 8, 3, 37, tzinfo=pytz.utc)
dt = datetime(2014, 11, 8, 3, 37, tzinfo=timezone.utc)
self.assertEqual(julianday.from_datetime(dt), 2456969.65069)

self.assertEqual(julianday.to_datetime(self.x + 0.525), datetime(2016, 2, 29, 12, 36, tzinfo=pytz.utc))
self.assertEqual(julianday.to_datetime(self.x + 0.525), datetime(2016, 2, 29, 12, 36, tzinfo=timezone.utc))

def test_month_length_julian(self):
self.assertEqual(julian.month_length(1582, 10), 31)
Expand Down
1 change: 0 additions & 1 deletion tests/test_julian.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from convertdate import julian
import pytz

from . import CalTestCase

Expand Down

0 comments on commit 5870536

Please sign in to comment.