Drop pytz
It can be replaced by the built-in datetime module. Change-Id: Ib33163496fb8068b9578c4cb231bf6d070cc78b9
This commit is contained in:
parent
0f8cb1c461
commit
4c0da145f2
@ -1,6 +1,5 @@
|
||||
WebOb>=1.8.0
|
||||
simplegeneric
|
||||
pytz
|
||||
netaddr>=0.7.12
|
||||
# TODO: Drop this when Python 3.10 is our minimum supported version
|
||||
importlib_metadata>=4.4 # Apache-2.0
|
||||
|
@ -1,6 +1,5 @@
|
||||
import datetime
|
||||
import unittest
|
||||
import pytz
|
||||
|
||||
from wsme import utils
|
||||
|
||||
@ -27,11 +26,14 @@ class TestUtils(unittest.TestCase):
|
||||
good_times = [
|
||||
('12:03:54', datetime.time(12, 3, 54)),
|
||||
('23:59:59.000004', datetime.time(23, 59, 59, 4)),
|
||||
('01:02:03+00:00', datetime.time(1, 2, 3, 0, pytz.UTC)),
|
||||
('01:02:03+23:59', datetime.time(1, 2, 3, 0,
|
||||
pytz.FixedOffset(1439))),
|
||||
('01:02:03-23:59', datetime.time(1, 2, 3, 0,
|
||||
pytz.FixedOffset(-1439))),
|
||||
('01:02:03+00:00', datetime.time(
|
||||
1, 2, 3, 0, datetime.timezone.utc)),
|
||||
('01:02:03+23:59', datetime.time(
|
||||
1, 2, 3, 0,
|
||||
datetime.timezone(datetime.timedelta(minutes=1439)))),
|
||||
('01:02:03-23:59', datetime.time(
|
||||
1, 2, 3, 0,
|
||||
datetime.timezone(datetime.timedelta(minutes=-1439)))),
|
||||
]
|
||||
ill_formatted_times = [
|
||||
'24-12-2004'
|
||||
@ -54,13 +56,16 @@ class TestUtils(unittest.TestCase):
|
||||
('2012-05-14T23:59:59.000004',
|
||||
datetime.datetime(2012, 5, 14, 23, 59, 59, 4)),
|
||||
('1856-07-10T01:02:03+00:00',
|
||||
datetime.datetime(1856, 7, 10, 1, 2, 3, 0, pytz.UTC)),
|
||||
datetime.datetime(1856, 7, 10, 1, 2, 3, 0,
|
||||
datetime.timezone.utc)),
|
||||
('1856-07-10T01:02:03+23:59',
|
||||
datetime.datetime(1856, 7, 10, 1, 2, 3, 0,
|
||||
pytz.FixedOffset(1439))),
|
||||
datetime.datetime(
|
||||
1856, 7, 10, 1, 2, 3, 0,
|
||||
datetime.timezone(datetime.timedelta(minutes=1439)))),
|
||||
('1856-07-10T01:02:03-23:59',
|
||||
datetime.datetime(1856, 7, 10, 1, 2, 3, 0,
|
||||
pytz.FixedOffset(-1439))),
|
||||
datetime.datetime(
|
||||
1856, 7, 10, 1, 2, 3, 0,
|
||||
datetime.timezone(datetime.timedelta(minutes=-1439)))),
|
||||
]
|
||||
ill_formatted_datetimes = [
|
||||
'24-32-2004',
|
||||
|
@ -2,7 +2,6 @@ import builtins
|
||||
import datetime
|
||||
import decimal
|
||||
from http import client as http_client
|
||||
import pytz
|
||||
import re
|
||||
|
||||
try:
|
||||
@ -91,14 +90,15 @@ def parse_isodatetime(value):
|
||||
|
||||
def _parse_tzparts(parts):
|
||||
if 'tz_z' in parts and parts['tz_z'] == 'Z':
|
||||
return pytz.UTC
|
||||
return datetime.timezone.utc
|
||||
if 'tz_min' not in parts or not parts['tz_min']:
|
||||
return None
|
||||
|
||||
tz_minute_offset = (int(parts['tz_hour']) * 60 + int(parts['tz_min']))
|
||||
tz_multiplier = -1 if parts['tz_sign'] == '-' else 1
|
||||
minutes = tz_multiplier * tz_minute_offset
|
||||
|
||||
return pytz.FixedOffset(tz_multiplier * tz_minute_offset)
|
||||
return datetime.timezone(datetime.timedelta(minutes=minutes))
|
||||
|
||||
|
||||
def is_valid_code(code_value):
|
||||
|
Loading…
Reference in New Issue
Block a user