Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_cparser.pxd.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_find_header.pxd.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_helpers.pyi.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_helpers.pyx.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_http_parser.pyx.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_http_writer.pyx.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_websocket.pyx.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/hdrs.py.hash +1 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/abc.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/base_protocol.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/client_exceptions.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/client_reqrep.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/client_ws.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/connector.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/formdata.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/hdrs.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_exceptions.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_parser.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_websocket.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_writer.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/multipart.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/payload_streamer.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/resolver.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/tcp_helpers.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/typedefs.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_app.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_exceptions.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_fileresponse.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_urldispatcher.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/worker.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/__init__.py +1555 -0
- llmeval-env/lib/python3.10/site-packages/pytz/exceptions.py +59 -0
- llmeval-env/lib/python3.10/site-packages/pytz/lazy.py +172 -0
- llmeval-env/lib/python3.10/site-packages/pytz/reference.py +140 -0
- llmeval-env/lib/python3.10/site-packages/pytz/tzfile.py +133 -0
- llmeval-env/lib/python3.10/site-packages/pytz/tzinfo.py +580 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/CST6CDT +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Cuba +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/EET +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/EST +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Egypt +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Factory +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GB +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GB-Eire +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GMT +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GMT0 +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/HST +0 -0
- llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Hongkong +0 -0
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_cparser.pxd.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
f2318883e549f69de597009a914603b0f1b10381e265ef5d98af499ad973fb98 /home/runner/work/aiohttp/aiohttp/aiohttp/_cparser.pxd
|
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_find_header.pxd.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
d067f01423cddb3c442933b5fcc039b18ab651fcec1bc91c577693aafc25cf78 /home/runner/work/aiohttp/aiohttp/aiohttp/_find_header.pxd
|
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_helpers.pyi.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
6682a22524b9d4fc442e123672622be7bdfb6238d9709b7b15b2113b7ca6d52b /home/runner/work/aiohttp/aiohttp/aiohttp/_helpers.pyi
|
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_helpers.pyx.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
5de2db35fb795ffe227e2f1007c8ba4f2ad1b9aca28cc48edc80c779203cf6e3 /home/runner/work/aiohttp/aiohttp/aiohttp/_helpers.pyx
|
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_http_parser.pyx.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
abaf11ab4e8ca56f90c0bc6b884de120999620a73895515a587537725b077786 /home/runner/work/aiohttp/aiohttp/aiohttp/_http_parser.pyx
|
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_http_writer.pyx.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
6881c0a7c838655e646c645d99971efaf5e310bc3633a7c62b226e39d81842ac /home/runner/work/aiohttp/aiohttp/aiohttp/_http_writer.pyx
|
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/_websocket.pyx.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
d57b8e48d0c26f20ebcc5e6e300da2b2a6aeb12b3c9768d64cb0e53432ccf48a /home/runner/work/aiohttp/aiohttp/aiohttp/_websocket.pyx
|
llmeval-env/lib/python3.10/site-packages/aiohttp/.hash/hdrs.py.hash
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
bb39f96a09ff8d789dda1fa4cba63464043c06b3de4c62c31abfb07a231cb6ca /home/runner/work/aiohttp/aiohttp/aiohttp/hdrs.py
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/abc.cpython-310.pyc
ADDED
Binary file (8.58 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/base_protocol.cpython-310.pyc
ADDED
Binary file (2.89 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/client_exceptions.cpython-310.pyc
ADDED
Binary file (11.2 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/client_reqrep.cpython-310.pyc
ADDED
Binary file (30.8 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/client_ws.cpython-310.pyc
ADDED
Binary file (9.2 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/connector.cpython-310.pyc
ADDED
Binary file (36.9 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/formdata.cpython-310.pyc
ADDED
Binary file (4.85 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/hdrs.cpython-310.pyc
ADDED
Binary file (5.2 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http.cpython-310.pyc
ADDED
Binary file (1.47 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_exceptions.cpython-310.pyc
ADDED
Binary file (4.44 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_parser.cpython-310.pyc
ADDED
Binary file (19.7 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_websocket.cpython-310.pyc
ADDED
Binary file (15.6 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/http_writer.cpython-310.pyc
ADDED
Binary file (5.68 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/multipart.cpython-310.pyc
ADDED
Binary file (27.4 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/payload_streamer.cpython-310.pyc
ADDED
Binary file (3.27 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/resolver.cpython-310.pyc
ADDED
Binary file (4.04 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/tcp_helpers.cpython-310.pyc
ADDED
Binary file (1.15 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/typedefs.cpython-310.pyc
ADDED
Binary file (1.39 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web.cpython-310.pyc
ADDED
Binary file (11.4 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_app.cpython-310.pyc
ADDED
Binary file (16.5 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_exceptions.cpython-310.pyc
ADDED
Binary file (11.7 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_fileresponse.cpython-310.pyc
ADDED
Binary file (6.51 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/web_urldispatcher.cpython-310.pyc
ADDED
Binary file (41.9 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/aiohttp/__pycache__/worker.cpython-310.pyc
ADDED
Binary file (6.53 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/__init__.py
ADDED
@@ -0,0 +1,1555 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''
|
2 |
+
datetime.tzinfo timezone definitions generated from the
|
3 |
+
Olson timezone database:
|
4 |
+
|
5 |
+
ftp://elsie.nci.nih.gov/pub/tz*.tar.gz
|
6 |
+
|
7 |
+
See the datetime section of the Python Library Reference for information
|
8 |
+
on how to use these modules.
|
9 |
+
'''
|
10 |
+
|
11 |
+
import sys
|
12 |
+
import datetime
|
13 |
+
import os.path
|
14 |
+
|
15 |
+
from pytz.exceptions import AmbiguousTimeError
|
16 |
+
from pytz.exceptions import InvalidTimeError
|
17 |
+
from pytz.exceptions import NonExistentTimeError
|
18 |
+
from pytz.exceptions import UnknownTimeZoneError
|
19 |
+
from pytz.lazy import LazyDict, LazyList, LazySet # noqa
|
20 |
+
from pytz.tzinfo import unpickler, BaseTzInfo
|
21 |
+
from pytz.tzfile import build_tzinfo
|
22 |
+
|
23 |
+
|
24 |
+
# The IANA (nee Olson) database is updated several times a year.
|
25 |
+
OLSON_VERSION = '2024a'
|
26 |
+
VERSION = '2024.1' # pip compatible version number.
|
27 |
+
__version__ = VERSION
|
28 |
+
|
29 |
+
OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
|
30 |
+
|
31 |
+
__all__ = [
|
32 |
+
'timezone', 'utc', 'country_timezones', 'country_names',
|
33 |
+
'AmbiguousTimeError', 'InvalidTimeError',
|
34 |
+
'NonExistentTimeError', 'UnknownTimeZoneError',
|
35 |
+
'all_timezones', 'all_timezones_set',
|
36 |
+
'common_timezones', 'common_timezones_set',
|
37 |
+
'BaseTzInfo', 'FixedOffset',
|
38 |
+
]
|
39 |
+
|
40 |
+
|
41 |
+
if sys.version_info[0] > 2: # Python 3.x
|
42 |
+
|
43 |
+
# Python 3.x doesn't have unicode(), making writing code
|
44 |
+
# for Python 2.3 and Python 3.x a pain.
|
45 |
+
unicode = str
|
46 |
+
|
47 |
+
def ascii(s):
|
48 |
+
r"""
|
49 |
+
>>> ascii('Hello')
|
50 |
+
'Hello'
|
51 |
+
>>> ascii('\N{TRADE MARK SIGN}') #doctest: +IGNORE_EXCEPTION_DETAIL
|
52 |
+
Traceback (most recent call last):
|
53 |
+
...
|
54 |
+
UnicodeEncodeError: ...
|
55 |
+
"""
|
56 |
+
if type(s) == bytes:
|
57 |
+
s = s.decode('ASCII')
|
58 |
+
else:
|
59 |
+
s.encode('ASCII') # Raise an exception if not ASCII
|
60 |
+
return s # But the string - not a byte string.
|
61 |
+
|
62 |
+
else: # Python 2.x
|
63 |
+
|
64 |
+
def ascii(s):
|
65 |
+
r"""
|
66 |
+
>>> ascii('Hello')
|
67 |
+
'Hello'
|
68 |
+
>>> ascii(u'Hello')
|
69 |
+
'Hello'
|
70 |
+
>>> ascii(u'\N{TRADE MARK SIGN}') #doctest: +IGNORE_EXCEPTION_DETAIL
|
71 |
+
Traceback (most recent call last):
|
72 |
+
...
|
73 |
+
UnicodeEncodeError: ...
|
74 |
+
"""
|
75 |
+
return s.encode('ASCII')
|
76 |
+
|
77 |
+
|
78 |
+
def open_resource(name):
|
79 |
+
"""Open a resource from the zoneinfo subdir for reading.
|
80 |
+
|
81 |
+
Uses the pkg_resources module if available and no standard file
|
82 |
+
found at the calculated location.
|
83 |
+
|
84 |
+
It is possible to specify different location for zoneinfo
|
85 |
+
subdir by using the PYTZ_TZDATADIR environment variable.
|
86 |
+
"""
|
87 |
+
name_parts = name.lstrip('/').split('/')
|
88 |
+
for part in name_parts:
|
89 |
+
if part == os.path.pardir or os.sep in part:
|
90 |
+
raise ValueError('Bad path segment: %r' % part)
|
91 |
+
zoneinfo_dir = os.environ.get('PYTZ_TZDATADIR', None)
|
92 |
+
if zoneinfo_dir is not None:
|
93 |
+
filename = os.path.join(zoneinfo_dir, *name_parts)
|
94 |
+
else:
|
95 |
+
filename = os.path.join(os.path.dirname(__file__),
|
96 |
+
'zoneinfo', *name_parts)
|
97 |
+
if not os.path.exists(filename):
|
98 |
+
# http://bugs.launchpad.net/bugs/383171 - we avoid using this
|
99 |
+
# unless absolutely necessary to help when a broken version of
|
100 |
+
# pkg_resources is installed.
|
101 |
+
try:
|
102 |
+
from pkg_resources import resource_stream
|
103 |
+
except ImportError:
|
104 |
+
resource_stream = None
|
105 |
+
|
106 |
+
if resource_stream is not None:
|
107 |
+
return resource_stream(__name__, 'zoneinfo/' + name)
|
108 |
+
return open(filename, 'rb')
|
109 |
+
|
110 |
+
|
111 |
+
def resource_exists(name):
|
112 |
+
"""Return true if the given resource exists"""
|
113 |
+
try:
|
114 |
+
if os.environ.get('PYTZ_SKIPEXISTSCHECK', ''):
|
115 |
+
# In "standard" distributions, we can assume that
|
116 |
+
# all the listed timezones are present. As an
|
117 |
+
# import-speed optimization, you can set the
|
118 |
+
# PYTZ_SKIPEXISTSCHECK flag to skip checking
|
119 |
+
# for the presence of the resource file on disk.
|
120 |
+
return True
|
121 |
+
open_resource(name).close()
|
122 |
+
return True
|
123 |
+
except IOError:
|
124 |
+
return False
|
125 |
+
|
126 |
+
|
127 |
+
_tzinfo_cache = {}
|
128 |
+
|
129 |
+
|
130 |
+
def timezone(zone):
|
131 |
+
r''' Return a datetime.tzinfo implementation for the given timezone
|
132 |
+
|
133 |
+
>>> from datetime import datetime, timedelta
|
134 |
+
>>> utc = timezone('UTC')
|
135 |
+
>>> eastern = timezone('US/Eastern')
|
136 |
+
>>> eastern.zone
|
137 |
+
'US/Eastern'
|
138 |
+
>>> timezone(unicode('US/Eastern')) is eastern
|
139 |
+
True
|
140 |
+
>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
|
141 |
+
>>> loc_dt = utc_dt.astimezone(eastern)
|
142 |
+
>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
|
143 |
+
>>> loc_dt.strftime(fmt)
|
144 |
+
'2002-10-27 01:00:00 EST (-0500)'
|
145 |
+
>>> (loc_dt - timedelta(minutes=10)).strftime(fmt)
|
146 |
+
'2002-10-27 00:50:00 EST (-0500)'
|
147 |
+
>>> eastern.normalize(loc_dt - timedelta(minutes=10)).strftime(fmt)
|
148 |
+
'2002-10-27 01:50:00 EDT (-0400)'
|
149 |
+
>>> (loc_dt + timedelta(minutes=10)).strftime(fmt)
|
150 |
+
'2002-10-27 01:10:00 EST (-0500)'
|
151 |
+
|
152 |
+
Raises UnknownTimeZoneError if passed an unknown zone.
|
153 |
+
|
154 |
+
>>> try:
|
155 |
+
... timezone('Asia/Shangri-La')
|
156 |
+
... except UnknownTimeZoneError:
|
157 |
+
... print('Unknown')
|
158 |
+
Unknown
|
159 |
+
|
160 |
+
>>> try:
|
161 |
+
... timezone(unicode('\N{TRADE MARK SIGN}'))
|
162 |
+
... except UnknownTimeZoneError:
|
163 |
+
... print('Unknown')
|
164 |
+
Unknown
|
165 |
+
|
166 |
+
'''
|
167 |
+
if zone is None:
|
168 |
+
raise UnknownTimeZoneError(None)
|
169 |
+
|
170 |
+
if zone.upper() == 'UTC':
|
171 |
+
return utc
|
172 |
+
|
173 |
+
try:
|
174 |
+
zone = ascii(zone)
|
175 |
+
except UnicodeEncodeError:
|
176 |
+
# All valid timezones are ASCII
|
177 |
+
raise UnknownTimeZoneError(zone)
|
178 |
+
|
179 |
+
zone = _case_insensitive_zone_lookup(_unmunge_zone(zone))
|
180 |
+
if zone not in _tzinfo_cache:
|
181 |
+
if zone in all_timezones_set: # noqa
|
182 |
+
fp = open_resource(zone)
|
183 |
+
try:
|
184 |
+
_tzinfo_cache[zone] = build_tzinfo(zone, fp)
|
185 |
+
finally:
|
186 |
+
fp.close()
|
187 |
+
else:
|
188 |
+
raise UnknownTimeZoneError(zone)
|
189 |
+
|
190 |
+
return _tzinfo_cache[zone]
|
191 |
+
|
192 |
+
|
193 |
+
def _unmunge_zone(zone):
|
194 |
+
"""Undo the time zone name munging done by older versions of pytz."""
|
195 |
+
return zone.replace('_plus_', '+').replace('_minus_', '-')
|
196 |
+
|
197 |
+
|
198 |
+
_all_timezones_lower_to_standard = None
|
199 |
+
|
200 |
+
|
201 |
+
def _case_insensitive_zone_lookup(zone):
|
202 |
+
"""case-insensitively matching timezone, else return zone unchanged"""
|
203 |
+
global _all_timezones_lower_to_standard
|
204 |
+
if _all_timezones_lower_to_standard is None:
|
205 |
+
_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in _all_timezones_unchecked) # noqa
|
206 |
+
return _all_timezones_lower_to_standard.get(zone.lower()) or zone # noqa
|
207 |
+
|
208 |
+
|
209 |
+
ZERO = datetime.timedelta(0)
|
210 |
+
HOUR = datetime.timedelta(hours=1)
|
211 |
+
|
212 |
+
|
213 |
+
class UTC(BaseTzInfo):
|
214 |
+
"""UTC
|
215 |
+
|
216 |
+
Optimized UTC implementation. It unpickles using the single module global
|
217 |
+
instance defined beneath this class declaration.
|
218 |
+
"""
|
219 |
+
zone = "UTC"
|
220 |
+
|
221 |
+
_utcoffset = ZERO
|
222 |
+
_dst = ZERO
|
223 |
+
_tzname = zone
|
224 |
+
|
225 |
+
def fromutc(self, dt):
|
226 |
+
if dt.tzinfo is None:
|
227 |
+
return self.localize(dt)
|
228 |
+
return super(utc.__class__, self).fromutc(dt)
|
229 |
+
|
230 |
+
def utcoffset(self, dt):
|
231 |
+
return ZERO
|
232 |
+
|
233 |
+
def tzname(self, dt):
|
234 |
+
return "UTC"
|
235 |
+
|
236 |
+
def dst(self, dt):
|
237 |
+
return ZERO
|
238 |
+
|
239 |
+
def __reduce__(self):
|
240 |
+
return _UTC, ()
|
241 |
+
|
242 |
+
def localize(self, dt, is_dst=False):
|
243 |
+
'''Convert naive time to local time'''
|
244 |
+
if dt.tzinfo is not None:
|
245 |
+
raise ValueError('Not naive datetime (tzinfo is already set)')
|
246 |
+
return dt.replace(tzinfo=self)
|
247 |
+
|
248 |
+
def normalize(self, dt, is_dst=False):
|
249 |
+
'''Correct the timezone information on the given datetime'''
|
250 |
+
if dt.tzinfo is self:
|
251 |
+
return dt
|
252 |
+
if dt.tzinfo is None:
|
253 |
+
raise ValueError('Naive time - no tzinfo set')
|
254 |
+
return dt.astimezone(self)
|
255 |
+
|
256 |
+
def __repr__(self):
|
257 |
+
return "<UTC>"
|
258 |
+
|
259 |
+
def __str__(self):
|
260 |
+
return "UTC"
|
261 |
+
|
262 |
+
|
263 |
+
UTC = utc = UTC() # UTC is a singleton
|
264 |
+
|
265 |
+
|
266 |
+
def _UTC():
|
267 |
+
"""Factory function for utc unpickling.
|
268 |
+
|
269 |
+
Makes sure that unpickling a utc instance always returns the same
|
270 |
+
module global.
|
271 |
+
|
272 |
+
These examples belong in the UTC class above, but it is obscured; or in
|
273 |
+
the README.rst, but we are not depending on Python 2.4 so integrating
|
274 |
+
the README.rst examples with the unit tests is not trivial.
|
275 |
+
|
276 |
+
>>> import datetime, pickle
|
277 |
+
>>> dt = datetime.datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)
|
278 |
+
>>> naive = dt.replace(tzinfo=None)
|
279 |
+
>>> p = pickle.dumps(dt, 1)
|
280 |
+
>>> naive_p = pickle.dumps(naive, 1)
|
281 |
+
>>> len(p) - len(naive_p)
|
282 |
+
17
|
283 |
+
>>> new = pickle.loads(p)
|
284 |
+
>>> new == dt
|
285 |
+
True
|
286 |
+
>>> new is dt
|
287 |
+
False
|
288 |
+
>>> new.tzinfo is dt.tzinfo
|
289 |
+
True
|
290 |
+
>>> utc is UTC is timezone('UTC')
|
291 |
+
True
|
292 |
+
>>> utc is timezone('GMT')
|
293 |
+
False
|
294 |
+
"""
|
295 |
+
return utc
|
296 |
+
|
297 |
+
|
298 |
+
_UTC.__safe_for_unpickling__ = True
|
299 |
+
|
300 |
+
|
301 |
+
def _p(*args):
|
302 |
+
"""Factory function for unpickling pytz tzinfo instances.
|
303 |
+
|
304 |
+
Just a wrapper around tzinfo.unpickler to save a few bytes in each pickle
|
305 |
+
by shortening the path.
|
306 |
+
"""
|
307 |
+
return unpickler(*args)
|
308 |
+
|
309 |
+
|
310 |
+
_p.__safe_for_unpickling__ = True
|
311 |
+
|
312 |
+
|
313 |
+
class _CountryTimezoneDict(LazyDict):
|
314 |
+
"""Map ISO 3166 country code to a list of timezone names commonly used
|
315 |
+
in that country.
|
316 |
+
|
317 |
+
iso3166_code is the two letter code used to identify the country.
|
318 |
+
|
319 |
+
>>> def print_list(list_of_strings):
|
320 |
+
... 'We use a helper so doctests work under Python 2.3 -> 3.x'
|
321 |
+
... for s in list_of_strings:
|
322 |
+
... print(s)
|
323 |
+
|
324 |
+
>>> print_list(country_timezones['nz'])
|
325 |
+
Pacific/Auckland
|
326 |
+
Pacific/Chatham
|
327 |
+
>>> print_list(country_timezones['ch'])
|
328 |
+
Europe/Zurich
|
329 |
+
>>> print_list(country_timezones['CH'])
|
330 |
+
Europe/Zurich
|
331 |
+
>>> print_list(country_timezones[unicode('ch')])
|
332 |
+
Europe/Zurich
|
333 |
+
>>> print_list(country_timezones['XXX'])
|
334 |
+
Traceback (most recent call last):
|
335 |
+
...
|
336 |
+
KeyError: 'XXX'
|
337 |
+
|
338 |
+
Previously, this information was exposed as a function rather than a
|
339 |
+
dictionary. This is still supported::
|
340 |
+
|
341 |
+
>>> print_list(country_timezones('nz'))
|
342 |
+
Pacific/Auckland
|
343 |
+
Pacific/Chatham
|
344 |
+
"""
|
345 |
+
def __call__(self, iso3166_code):
|
346 |
+
"""Backwards compatibility."""
|
347 |
+
return self[iso3166_code]
|
348 |
+
|
349 |
+
def _fill(self):
|
350 |
+
data = {}
|
351 |
+
zone_tab = open_resource('zone.tab')
|
352 |
+
try:
|
353 |
+
for line in zone_tab:
|
354 |
+
line = line.decode('UTF-8')
|
355 |
+
if line.startswith('#'):
|
356 |
+
continue
|
357 |
+
code, coordinates, zone = line.split(None, 4)[:3]
|
358 |
+
if zone not in all_timezones_set: # noqa
|
359 |
+
continue
|
360 |
+
try:
|
361 |
+
data[code].append(zone)
|
362 |
+
except KeyError:
|
363 |
+
data[code] = [zone]
|
364 |
+
self.data = data
|
365 |
+
finally:
|
366 |
+
zone_tab.close()
|
367 |
+
|
368 |
+
|
369 |
+
country_timezones = _CountryTimezoneDict()
|
370 |
+
|
371 |
+
|
372 |
+
class _CountryNameDict(LazyDict):
|
373 |
+
'''Dictionary proving ISO3166 code -> English name.
|
374 |
+
|
375 |
+
>>> print(country_names['au'])
|
376 |
+
Australia
|
377 |
+
'''
|
378 |
+
def _fill(self):
|
379 |
+
data = {}
|
380 |
+
zone_tab = open_resource('iso3166.tab')
|
381 |
+
try:
|
382 |
+
for line in zone_tab.readlines():
|
383 |
+
line = line.decode('UTF-8')
|
384 |
+
if line.startswith('#'):
|
385 |
+
continue
|
386 |
+
code, name = line.split(None, 1)
|
387 |
+
data[code] = name.strip()
|
388 |
+
self.data = data
|
389 |
+
finally:
|
390 |
+
zone_tab.close()
|
391 |
+
|
392 |
+
|
393 |
+
country_names = _CountryNameDict()
|
394 |
+
|
395 |
+
|
396 |
+
# Time-zone info based solely on fixed offsets
|
397 |
+
|
398 |
+
class _FixedOffset(datetime.tzinfo):
|
399 |
+
|
400 |
+
zone = None # to match the standard pytz API
|
401 |
+
|
402 |
+
def __init__(self, minutes):
|
403 |
+
if abs(minutes) >= 1440:
|
404 |
+
raise ValueError("absolute offset is too large", minutes)
|
405 |
+
self._minutes = minutes
|
406 |
+
self._offset = datetime.timedelta(minutes=minutes)
|
407 |
+
|
408 |
+
def utcoffset(self, dt):
|
409 |
+
return self._offset
|
410 |
+
|
411 |
+
def __reduce__(self):
|
412 |
+
return FixedOffset, (self._minutes, )
|
413 |
+
|
414 |
+
def dst(self, dt):
|
415 |
+
return ZERO
|
416 |
+
|
417 |
+
def tzname(self, dt):
|
418 |
+
return None
|
419 |
+
|
420 |
+
def __repr__(self):
|
421 |
+
return 'pytz.FixedOffset(%d)' % self._minutes
|
422 |
+
|
423 |
+
def localize(self, dt, is_dst=False):
|
424 |
+
'''Convert naive time to local time'''
|
425 |
+
if dt.tzinfo is not None:
|
426 |
+
raise ValueError('Not naive datetime (tzinfo is already set)')
|
427 |
+
return dt.replace(tzinfo=self)
|
428 |
+
|
429 |
+
def normalize(self, dt, is_dst=False):
|
430 |
+
'''Correct the timezone information on the given datetime'''
|
431 |
+
if dt.tzinfo is self:
|
432 |
+
return dt
|
433 |
+
if dt.tzinfo is None:
|
434 |
+
raise ValueError('Naive time - no tzinfo set')
|
435 |
+
return dt.astimezone(self)
|
436 |
+
|
437 |
+
|
438 |
+
def FixedOffset(offset, _tzinfos={}):
|
439 |
+
"""return a fixed-offset timezone based off a number of minutes.
|
440 |
+
|
441 |
+
>>> one = FixedOffset(-330)
|
442 |
+
>>> one
|
443 |
+
pytz.FixedOffset(-330)
|
444 |
+
>>> str(one.utcoffset(datetime.datetime.now()))
|
445 |
+
'-1 day, 18:30:00'
|
446 |
+
>>> str(one.dst(datetime.datetime.now()))
|
447 |
+
'0:00:00'
|
448 |
+
|
449 |
+
>>> two = FixedOffset(1380)
|
450 |
+
>>> two
|
451 |
+
pytz.FixedOffset(1380)
|
452 |
+
>>> str(two.utcoffset(datetime.datetime.now()))
|
453 |
+
'23:00:00'
|
454 |
+
>>> str(two.dst(datetime.datetime.now()))
|
455 |
+
'0:00:00'
|
456 |
+
|
457 |
+
The datetime.timedelta must be between the range of -1 and 1 day,
|
458 |
+
non-inclusive.
|
459 |
+
|
460 |
+
>>> FixedOffset(1440)
|
461 |
+
Traceback (most recent call last):
|
462 |
+
...
|
463 |
+
ValueError: ('absolute offset is too large', 1440)
|
464 |
+
|
465 |
+
>>> FixedOffset(-1440)
|
466 |
+
Traceback (most recent call last):
|
467 |
+
...
|
468 |
+
ValueError: ('absolute offset is too large', -1440)
|
469 |
+
|
470 |
+
An offset of 0 is special-cased to return UTC.
|
471 |
+
|
472 |
+
>>> FixedOffset(0) is UTC
|
473 |
+
True
|
474 |
+
|
475 |
+
There should always be only one instance of a FixedOffset per timedelta.
|
476 |
+
This should be true for multiple creation calls.
|
477 |
+
|
478 |
+
>>> FixedOffset(-330) is one
|
479 |
+
True
|
480 |
+
>>> FixedOffset(1380) is two
|
481 |
+
True
|
482 |
+
|
483 |
+
It should also be true for pickling.
|
484 |
+
|
485 |
+
>>> import pickle
|
486 |
+
>>> pickle.loads(pickle.dumps(one)) is one
|
487 |
+
True
|
488 |
+
>>> pickle.loads(pickle.dumps(two)) is two
|
489 |
+
True
|
490 |
+
"""
|
491 |
+
if offset == 0:
|
492 |
+
return UTC
|
493 |
+
|
494 |
+
info = _tzinfos.get(offset)
|
495 |
+
if info is None:
|
496 |
+
# We haven't seen this one before. we need to save it.
|
497 |
+
|
498 |
+
# Use setdefault to avoid a race condition and make sure we have
|
499 |
+
# only one
|
500 |
+
info = _tzinfos.setdefault(offset, _FixedOffset(offset))
|
501 |
+
|
502 |
+
return info
|
503 |
+
|
504 |
+
|
505 |
+
FixedOffset.__safe_for_unpickling__ = True
|
506 |
+
|
507 |
+
|
508 |
+
def _test():
|
509 |
+
import doctest
|
510 |
+
sys.path.insert(0, os.pardir)
|
511 |
+
import pytz
|
512 |
+
return doctest.testmod(pytz)
|
513 |
+
|
514 |
+
|
515 |
+
if __name__ == '__main__':
|
516 |
+
_test()
|
517 |
+
_all_timezones_unchecked = \
|
518 |
+
['Africa/Abidjan',
|
519 |
+
'Africa/Accra',
|
520 |
+
'Africa/Addis_Ababa',
|
521 |
+
'Africa/Algiers',
|
522 |
+
'Africa/Asmara',
|
523 |
+
'Africa/Asmera',
|
524 |
+
'Africa/Bamako',
|
525 |
+
'Africa/Bangui',
|
526 |
+
'Africa/Banjul',
|
527 |
+
'Africa/Bissau',
|
528 |
+
'Africa/Blantyre',
|
529 |
+
'Africa/Brazzaville',
|
530 |
+
'Africa/Bujumbura',
|
531 |
+
'Africa/Cairo',
|
532 |
+
'Africa/Casablanca',
|
533 |
+
'Africa/Ceuta',
|
534 |
+
'Africa/Conakry',
|
535 |
+
'Africa/Dakar',
|
536 |
+
'Africa/Dar_es_Salaam',
|
537 |
+
'Africa/Djibouti',
|
538 |
+
'Africa/Douala',
|
539 |
+
'Africa/El_Aaiun',
|
540 |
+
'Africa/Freetown',
|
541 |
+
'Africa/Gaborone',
|
542 |
+
'Africa/Harare',
|
543 |
+
'Africa/Johannesburg',
|
544 |
+
'Africa/Juba',
|
545 |
+
'Africa/Kampala',
|
546 |
+
'Africa/Khartoum',
|
547 |
+
'Africa/Kigali',
|
548 |
+
'Africa/Kinshasa',
|
549 |
+
'Africa/Lagos',
|
550 |
+
'Africa/Libreville',
|
551 |
+
'Africa/Lome',
|
552 |
+
'Africa/Luanda',
|
553 |
+
'Africa/Lubumbashi',
|
554 |
+
'Africa/Lusaka',
|
555 |
+
'Africa/Malabo',
|
556 |
+
'Africa/Maputo',
|
557 |
+
'Africa/Maseru',
|
558 |
+
'Africa/Mbabane',
|
559 |
+
'Africa/Mogadishu',
|
560 |
+
'Africa/Monrovia',
|
561 |
+
'Africa/Nairobi',
|
562 |
+
'Africa/Ndjamena',
|
563 |
+
'Africa/Niamey',
|
564 |
+
'Africa/Nouakchott',
|
565 |
+
'Africa/Ouagadougou',
|
566 |
+
'Africa/Porto-Novo',
|
567 |
+
'Africa/Sao_Tome',
|
568 |
+
'Africa/Timbuktu',
|
569 |
+
'Africa/Tripoli',
|
570 |
+
'Africa/Tunis',
|
571 |
+
'Africa/Windhoek',
|
572 |
+
'America/Adak',
|
573 |
+
'America/Anchorage',
|
574 |
+
'America/Anguilla',
|
575 |
+
'America/Antigua',
|
576 |
+
'America/Araguaina',
|
577 |
+
'America/Argentina/Buenos_Aires',
|
578 |
+
'America/Argentina/Catamarca',
|
579 |
+
'America/Argentina/ComodRivadavia',
|
580 |
+
'America/Argentina/Cordoba',
|
581 |
+
'America/Argentina/Jujuy',
|
582 |
+
'America/Argentina/La_Rioja',
|
583 |
+
'America/Argentina/Mendoza',
|
584 |
+
'America/Argentina/Rio_Gallegos',
|
585 |
+
'America/Argentina/Salta',
|
586 |
+
'America/Argentina/San_Juan',
|
587 |
+
'America/Argentina/San_Luis',
|
588 |
+
'America/Argentina/Tucuman',
|
589 |
+
'America/Argentina/Ushuaia',
|
590 |
+
'America/Aruba',
|
591 |
+
'America/Asuncion',
|
592 |
+
'America/Atikokan',
|
593 |
+
'America/Atka',
|
594 |
+
'America/Bahia',
|
595 |
+
'America/Bahia_Banderas',
|
596 |
+
'America/Barbados',
|
597 |
+
'America/Belem',
|
598 |
+
'America/Belize',
|
599 |
+
'America/Blanc-Sablon',
|
600 |
+
'America/Boa_Vista',
|
601 |
+
'America/Bogota',
|
602 |
+
'America/Boise',
|
603 |
+
'America/Buenos_Aires',
|
604 |
+
'America/Cambridge_Bay',
|
605 |
+
'America/Campo_Grande',
|
606 |
+
'America/Cancun',
|
607 |
+
'America/Caracas',
|
608 |
+
'America/Catamarca',
|
609 |
+
'America/Cayenne',
|
610 |
+
'America/Cayman',
|
611 |
+
'America/Chicago',
|
612 |
+
'America/Chihuahua',
|
613 |
+
'America/Ciudad_Juarez',
|
614 |
+
'America/Coral_Harbour',
|
615 |
+
'America/Cordoba',
|
616 |
+
'America/Costa_Rica',
|
617 |
+
'America/Creston',
|
618 |
+
'America/Cuiaba',
|
619 |
+
'America/Curacao',
|
620 |
+
'America/Danmarkshavn',
|
621 |
+
'America/Dawson',
|
622 |
+
'America/Dawson_Creek',
|
623 |
+
'America/Denver',
|
624 |
+
'America/Detroit',
|
625 |
+
'America/Dominica',
|
626 |
+
'America/Edmonton',
|
627 |
+
'America/Eirunepe',
|
628 |
+
'America/El_Salvador',
|
629 |
+
'America/Ensenada',
|
630 |
+
'America/Fort_Nelson',
|
631 |
+
'America/Fort_Wayne',
|
632 |
+
'America/Fortaleza',
|
633 |
+
'America/Glace_Bay',
|
634 |
+
'America/Godthab',
|
635 |
+
'America/Goose_Bay',
|
636 |
+
'America/Grand_Turk',
|
637 |
+
'America/Grenada',
|
638 |
+
'America/Guadeloupe',
|
639 |
+
'America/Guatemala',
|
640 |
+
'America/Guayaquil',
|
641 |
+
'America/Guyana',
|
642 |
+
'America/Halifax',
|
643 |
+
'America/Havana',
|
644 |
+
'America/Hermosillo',
|
645 |
+
'America/Indiana/Indianapolis',
|
646 |
+
'America/Indiana/Knox',
|
647 |
+
'America/Indiana/Marengo',
|
648 |
+
'America/Indiana/Petersburg',
|
649 |
+
'America/Indiana/Tell_City',
|
650 |
+
'America/Indiana/Vevay',
|
651 |
+
'America/Indiana/Vincennes',
|
652 |
+
'America/Indiana/Winamac',
|
653 |
+
'America/Indianapolis',
|
654 |
+
'America/Inuvik',
|
655 |
+
'America/Iqaluit',
|
656 |
+
'America/Jamaica',
|
657 |
+
'America/Jujuy',
|
658 |
+
'America/Juneau',
|
659 |
+
'America/Kentucky/Louisville',
|
660 |
+
'America/Kentucky/Monticello',
|
661 |
+
'America/Knox_IN',
|
662 |
+
'America/Kralendijk',
|
663 |
+
'America/La_Paz',
|
664 |
+
'America/Lima',
|
665 |
+
'America/Los_Angeles',
|
666 |
+
'America/Louisville',
|
667 |
+
'America/Lower_Princes',
|
668 |
+
'America/Maceio',
|
669 |
+
'America/Managua',
|
670 |
+
'America/Manaus',
|
671 |
+
'America/Marigot',
|
672 |
+
'America/Martinique',
|
673 |
+
'America/Matamoros',
|
674 |
+
'America/Mazatlan',
|
675 |
+
'America/Mendoza',
|
676 |
+
'America/Menominee',
|
677 |
+
'America/Merida',
|
678 |
+
'America/Metlakatla',
|
679 |
+
'America/Mexico_City',
|
680 |
+
'America/Miquelon',
|
681 |
+
'America/Moncton',
|
682 |
+
'America/Monterrey',
|
683 |
+
'America/Montevideo',
|
684 |
+
'America/Montreal',
|
685 |
+
'America/Montserrat',
|
686 |
+
'America/Nassau',
|
687 |
+
'America/New_York',
|
688 |
+
'America/Nipigon',
|
689 |
+
'America/Nome',
|
690 |
+
'America/Noronha',
|
691 |
+
'America/North_Dakota/Beulah',
|
692 |
+
'America/North_Dakota/Center',
|
693 |
+
'America/North_Dakota/New_Salem',
|
694 |
+
'America/Nuuk',
|
695 |
+
'America/Ojinaga',
|
696 |
+
'America/Panama',
|
697 |
+
'America/Pangnirtung',
|
698 |
+
'America/Paramaribo',
|
699 |
+
'America/Phoenix',
|
700 |
+
'America/Port-au-Prince',
|
701 |
+
'America/Port_of_Spain',
|
702 |
+
'America/Porto_Acre',
|
703 |
+
'America/Porto_Velho',
|
704 |
+
'America/Puerto_Rico',
|
705 |
+
'America/Punta_Arenas',
|
706 |
+
'America/Rainy_River',
|
707 |
+
'America/Rankin_Inlet',
|
708 |
+
'America/Recife',
|
709 |
+
'America/Regina',
|
710 |
+
'America/Resolute',
|
711 |
+
'America/Rio_Branco',
|
712 |
+
'America/Rosario',
|
713 |
+
'America/Santa_Isabel',
|
714 |
+
'America/Santarem',
|
715 |
+
'America/Santiago',
|
716 |
+
'America/Santo_Domingo',
|
717 |
+
'America/Sao_Paulo',
|
718 |
+
'America/Scoresbysund',
|
719 |
+
'America/Shiprock',
|
720 |
+
'America/Sitka',
|
721 |
+
'America/St_Barthelemy',
|
722 |
+
'America/St_Johns',
|
723 |
+
'America/St_Kitts',
|
724 |
+
'America/St_Lucia',
|
725 |
+
'America/St_Thomas',
|
726 |
+
'America/St_Vincent',
|
727 |
+
'America/Swift_Current',
|
728 |
+
'America/Tegucigalpa',
|
729 |
+
'America/Thule',
|
730 |
+
'America/Thunder_Bay',
|
731 |
+
'America/Tijuana',
|
732 |
+
'America/Toronto',
|
733 |
+
'America/Tortola',
|
734 |
+
'America/Vancouver',
|
735 |
+
'America/Virgin',
|
736 |
+
'America/Whitehorse',
|
737 |
+
'America/Winnipeg',
|
738 |
+
'America/Yakutat',
|
739 |
+
'America/Yellowknife',
|
740 |
+
'Antarctica/Casey',
|
741 |
+
'Antarctica/Davis',
|
742 |
+
'Antarctica/DumontDUrville',
|
743 |
+
'Antarctica/Macquarie',
|
744 |
+
'Antarctica/Mawson',
|
745 |
+
'Antarctica/McMurdo',
|
746 |
+
'Antarctica/Palmer',
|
747 |
+
'Antarctica/Rothera',
|
748 |
+
'Antarctica/South_Pole',
|
749 |
+
'Antarctica/Syowa',
|
750 |
+
'Antarctica/Troll',
|
751 |
+
'Antarctica/Vostok',
|
752 |
+
'Arctic/Longyearbyen',
|
753 |
+
'Asia/Aden',
|
754 |
+
'Asia/Almaty',
|
755 |
+
'Asia/Amman',
|
756 |
+
'Asia/Anadyr',
|
757 |
+
'Asia/Aqtau',
|
758 |
+
'Asia/Aqtobe',
|
759 |
+
'Asia/Ashgabat',
|
760 |
+
'Asia/Ashkhabad',
|
761 |
+
'Asia/Atyrau',
|
762 |
+
'Asia/Baghdad',
|
763 |
+
'Asia/Bahrain',
|
764 |
+
'Asia/Baku',
|
765 |
+
'Asia/Bangkok',
|
766 |
+
'Asia/Barnaul',
|
767 |
+
'Asia/Beirut',
|
768 |
+
'Asia/Bishkek',
|
769 |
+
'Asia/Brunei',
|
770 |
+
'Asia/Calcutta',
|
771 |
+
'Asia/Chita',
|
772 |
+
'Asia/Choibalsan',
|
773 |
+
'Asia/Chongqing',
|
774 |
+
'Asia/Chungking',
|
775 |
+
'Asia/Colombo',
|
776 |
+
'Asia/Dacca',
|
777 |
+
'Asia/Damascus',
|
778 |
+
'Asia/Dhaka',
|
779 |
+
'Asia/Dili',
|
780 |
+
'Asia/Dubai',
|
781 |
+
'Asia/Dushanbe',
|
782 |
+
'Asia/Famagusta',
|
783 |
+
'Asia/Gaza',
|
784 |
+
'Asia/Harbin',
|
785 |
+
'Asia/Hebron',
|
786 |
+
'Asia/Ho_Chi_Minh',
|
787 |
+
'Asia/Hong_Kong',
|
788 |
+
'Asia/Hovd',
|
789 |
+
'Asia/Irkutsk',
|
790 |
+
'Asia/Istanbul',
|
791 |
+
'Asia/Jakarta',
|
792 |
+
'Asia/Jayapura',
|
793 |
+
'Asia/Jerusalem',
|
794 |
+
'Asia/Kabul',
|
795 |
+
'Asia/Kamchatka',
|
796 |
+
'Asia/Karachi',
|
797 |
+
'Asia/Kashgar',
|
798 |
+
'Asia/Kathmandu',
|
799 |
+
'Asia/Katmandu',
|
800 |
+
'Asia/Khandyga',
|
801 |
+
'Asia/Kolkata',
|
802 |
+
'Asia/Krasnoyarsk',
|
803 |
+
'Asia/Kuala_Lumpur',
|
804 |
+
'Asia/Kuching',
|
805 |
+
'Asia/Kuwait',
|
806 |
+
'Asia/Macao',
|
807 |
+
'Asia/Macau',
|
808 |
+
'Asia/Magadan',
|
809 |
+
'Asia/Makassar',
|
810 |
+
'Asia/Manila',
|
811 |
+
'Asia/Muscat',
|
812 |
+
'Asia/Nicosia',
|
813 |
+
'Asia/Novokuznetsk',
|
814 |
+
'Asia/Novosibirsk',
|
815 |
+
'Asia/Omsk',
|
816 |
+
'Asia/Oral',
|
817 |
+
'Asia/Phnom_Penh',
|
818 |
+
'Asia/Pontianak',
|
819 |
+
'Asia/Pyongyang',
|
820 |
+
'Asia/Qatar',
|
821 |
+
'Asia/Qostanay',
|
822 |
+
'Asia/Qyzylorda',
|
823 |
+
'Asia/Rangoon',
|
824 |
+
'Asia/Riyadh',
|
825 |
+
'Asia/Saigon',
|
826 |
+
'Asia/Sakhalin',
|
827 |
+
'Asia/Samarkand',
|
828 |
+
'Asia/Seoul',
|
829 |
+
'Asia/Shanghai',
|
830 |
+
'Asia/Singapore',
|
831 |
+
'Asia/Srednekolymsk',
|
832 |
+
'Asia/Taipei',
|
833 |
+
'Asia/Tashkent',
|
834 |
+
'Asia/Tbilisi',
|
835 |
+
'Asia/Tehran',
|
836 |
+
'Asia/Tel_Aviv',
|
837 |
+
'Asia/Thimbu',
|
838 |
+
'Asia/Thimphu',
|
839 |
+
'Asia/Tokyo',
|
840 |
+
'Asia/Tomsk',
|
841 |
+
'Asia/Ujung_Pandang',
|
842 |
+
'Asia/Ulaanbaatar',
|
843 |
+
'Asia/Ulan_Bator',
|
844 |
+
'Asia/Urumqi',
|
845 |
+
'Asia/Ust-Nera',
|
846 |
+
'Asia/Vientiane',
|
847 |
+
'Asia/Vladivostok',
|
848 |
+
'Asia/Yakutsk',
|
849 |
+
'Asia/Yangon',
|
850 |
+
'Asia/Yekaterinburg',
|
851 |
+
'Asia/Yerevan',
|
852 |
+
'Atlantic/Azores',
|
853 |
+
'Atlantic/Bermuda',
|
854 |
+
'Atlantic/Canary',
|
855 |
+
'Atlantic/Cape_Verde',
|
856 |
+
'Atlantic/Faeroe',
|
857 |
+
'Atlantic/Faroe',
|
858 |
+
'Atlantic/Jan_Mayen',
|
859 |
+
'Atlantic/Madeira',
|
860 |
+
'Atlantic/Reykjavik',
|
861 |
+
'Atlantic/South_Georgia',
|
862 |
+
'Atlantic/St_Helena',
|
863 |
+
'Atlantic/Stanley',
|
864 |
+
'Australia/ACT',
|
865 |
+
'Australia/Adelaide',
|
866 |
+
'Australia/Brisbane',
|
867 |
+
'Australia/Broken_Hill',
|
868 |
+
'Australia/Canberra',
|
869 |
+
'Australia/Currie',
|
870 |
+
'Australia/Darwin',
|
871 |
+
'Australia/Eucla',
|
872 |
+
'Australia/Hobart',
|
873 |
+
'Australia/LHI',
|
874 |
+
'Australia/Lindeman',
|
875 |
+
'Australia/Lord_Howe',
|
876 |
+
'Australia/Melbourne',
|
877 |
+
'Australia/NSW',
|
878 |
+
'Australia/North',
|
879 |
+
'Australia/Perth',
|
880 |
+
'Australia/Queensland',
|
881 |
+
'Australia/South',
|
882 |
+
'Australia/Sydney',
|
883 |
+
'Australia/Tasmania',
|
884 |
+
'Australia/Victoria',
|
885 |
+
'Australia/West',
|
886 |
+
'Australia/Yancowinna',
|
887 |
+
'Brazil/Acre',
|
888 |
+
'Brazil/DeNoronha',
|
889 |
+
'Brazil/East',
|
890 |
+
'Brazil/West',
|
891 |
+
'CET',
|
892 |
+
'CST6CDT',
|
893 |
+
'Canada/Atlantic',
|
894 |
+
'Canada/Central',
|
895 |
+
'Canada/Eastern',
|
896 |
+
'Canada/Mountain',
|
897 |
+
'Canada/Newfoundland',
|
898 |
+
'Canada/Pacific',
|
899 |
+
'Canada/Saskatchewan',
|
900 |
+
'Canada/Yukon',
|
901 |
+
'Chile/Continental',
|
902 |
+
'Chile/EasterIsland',
|
903 |
+
'Cuba',
|
904 |
+
'EET',
|
905 |
+
'EST',
|
906 |
+
'EST5EDT',
|
907 |
+
'Egypt',
|
908 |
+
'Eire',
|
909 |
+
'Etc/GMT',
|
910 |
+
'Etc/GMT+0',
|
911 |
+
'Etc/GMT+1',
|
912 |
+
'Etc/GMT+10',
|
913 |
+
'Etc/GMT+11',
|
914 |
+
'Etc/GMT+12',
|
915 |
+
'Etc/GMT+2',
|
916 |
+
'Etc/GMT+3',
|
917 |
+
'Etc/GMT+4',
|
918 |
+
'Etc/GMT+5',
|
919 |
+
'Etc/GMT+6',
|
920 |
+
'Etc/GMT+7',
|
921 |
+
'Etc/GMT+8',
|
922 |
+
'Etc/GMT+9',
|
923 |
+
'Etc/GMT-0',
|
924 |
+
'Etc/GMT-1',
|
925 |
+
'Etc/GMT-10',
|
926 |
+
'Etc/GMT-11',
|
927 |
+
'Etc/GMT-12',
|
928 |
+
'Etc/GMT-13',
|
929 |
+
'Etc/GMT-14',
|
930 |
+
'Etc/GMT-2',
|
931 |
+
'Etc/GMT-3',
|
932 |
+
'Etc/GMT-4',
|
933 |
+
'Etc/GMT-5',
|
934 |
+
'Etc/GMT-6',
|
935 |
+
'Etc/GMT-7',
|
936 |
+
'Etc/GMT-8',
|
937 |
+
'Etc/GMT-9',
|
938 |
+
'Etc/GMT0',
|
939 |
+
'Etc/Greenwich',
|
940 |
+
'Etc/UCT',
|
941 |
+
'Etc/UTC',
|
942 |
+
'Etc/Universal',
|
943 |
+
'Etc/Zulu',
|
944 |
+
'Europe/Amsterdam',
|
945 |
+
'Europe/Andorra',
|
946 |
+
'Europe/Astrakhan',
|
947 |
+
'Europe/Athens',
|
948 |
+
'Europe/Belfast',
|
949 |
+
'Europe/Belgrade',
|
950 |
+
'Europe/Berlin',
|
951 |
+
'Europe/Bratislava',
|
952 |
+
'Europe/Brussels',
|
953 |
+
'Europe/Bucharest',
|
954 |
+
'Europe/Budapest',
|
955 |
+
'Europe/Busingen',
|
956 |
+
'Europe/Chisinau',
|
957 |
+
'Europe/Copenhagen',
|
958 |
+
'Europe/Dublin',
|
959 |
+
'Europe/Gibraltar',
|
960 |
+
'Europe/Guernsey',
|
961 |
+
'Europe/Helsinki',
|
962 |
+
'Europe/Isle_of_Man',
|
963 |
+
'Europe/Istanbul',
|
964 |
+
'Europe/Jersey',
|
965 |
+
'Europe/Kaliningrad',
|
966 |
+
'Europe/Kiev',
|
967 |
+
'Europe/Kirov',
|
968 |
+
'Europe/Kyiv',
|
969 |
+
'Europe/Lisbon',
|
970 |
+
'Europe/Ljubljana',
|
971 |
+
'Europe/London',
|
972 |
+
'Europe/Luxembourg',
|
973 |
+
'Europe/Madrid',
|
974 |
+
'Europe/Malta',
|
975 |
+
'Europe/Mariehamn',
|
976 |
+
'Europe/Minsk',
|
977 |
+
'Europe/Monaco',
|
978 |
+
'Europe/Moscow',
|
979 |
+
'Europe/Nicosia',
|
980 |
+
'Europe/Oslo',
|
981 |
+
'Europe/Paris',
|
982 |
+
'Europe/Podgorica',
|
983 |
+
'Europe/Prague',
|
984 |
+
'Europe/Riga',
|
985 |
+
'Europe/Rome',
|
986 |
+
'Europe/Samara',
|
987 |
+
'Europe/San_Marino',
|
988 |
+
'Europe/Sarajevo',
|
989 |
+
'Europe/Saratov',
|
990 |
+
'Europe/Simferopol',
|
991 |
+
'Europe/Skopje',
|
992 |
+
'Europe/Sofia',
|
993 |
+
'Europe/Stockholm',
|
994 |
+
'Europe/Tallinn',
|
995 |
+
'Europe/Tirane',
|
996 |
+
'Europe/Tiraspol',
|
997 |
+
'Europe/Ulyanovsk',
|
998 |
+
'Europe/Uzhgorod',
|
999 |
+
'Europe/Vaduz',
|
1000 |
+
'Europe/Vatican',
|
1001 |
+
'Europe/Vienna',
|
1002 |
+
'Europe/Vilnius',
|
1003 |
+
'Europe/Volgograd',
|
1004 |
+
'Europe/Warsaw',
|
1005 |
+
'Europe/Zagreb',
|
1006 |
+
'Europe/Zaporozhye',
|
1007 |
+
'Europe/Zurich',
|
1008 |
+
'GB',
|
1009 |
+
'GB-Eire',
|
1010 |
+
'GMT',
|
1011 |
+
'GMT+0',
|
1012 |
+
'GMT-0',
|
1013 |
+
'GMT0',
|
1014 |
+
'Greenwich',
|
1015 |
+
'HST',
|
1016 |
+
'Hongkong',
|
1017 |
+
'Iceland',
|
1018 |
+
'Indian/Antananarivo',
|
1019 |
+
'Indian/Chagos',
|
1020 |
+
'Indian/Christmas',
|
1021 |
+
'Indian/Cocos',
|
1022 |
+
'Indian/Comoro',
|
1023 |
+
'Indian/Kerguelen',
|
1024 |
+
'Indian/Mahe',
|
1025 |
+
'Indian/Maldives',
|
1026 |
+
'Indian/Mauritius',
|
1027 |
+
'Indian/Mayotte',
|
1028 |
+
'Indian/Reunion',
|
1029 |
+
'Iran',
|
1030 |
+
'Israel',
|
1031 |
+
'Jamaica',
|
1032 |
+
'Japan',
|
1033 |
+
'Kwajalein',
|
1034 |
+
'Libya',
|
1035 |
+
'MET',
|
1036 |
+
'MST',
|
1037 |
+
'MST7MDT',
|
1038 |
+
'Mexico/BajaNorte',
|
1039 |
+
'Mexico/BajaSur',
|
1040 |
+
'Mexico/General',
|
1041 |
+
'NZ',
|
1042 |
+
'NZ-CHAT',
|
1043 |
+
'Navajo',
|
1044 |
+
'PRC',
|
1045 |
+
'PST8PDT',
|
1046 |
+
'Pacific/Apia',
|
1047 |
+
'Pacific/Auckland',
|
1048 |
+
'Pacific/Bougainville',
|
1049 |
+
'Pacific/Chatham',
|
1050 |
+
'Pacific/Chuuk',
|
1051 |
+
'Pacific/Easter',
|
1052 |
+
'Pacific/Efate',
|
1053 |
+
'Pacific/Enderbury',
|
1054 |
+
'Pacific/Fakaofo',
|
1055 |
+
'Pacific/Fiji',
|
1056 |
+
'Pacific/Funafuti',
|
1057 |
+
'Pacific/Galapagos',
|
1058 |
+
'Pacific/Gambier',
|
1059 |
+
'Pacific/Guadalcanal',
|
1060 |
+
'Pacific/Guam',
|
1061 |
+
'Pacific/Honolulu',
|
1062 |
+
'Pacific/Johnston',
|
1063 |
+
'Pacific/Kanton',
|
1064 |
+
'Pacific/Kiritimati',
|
1065 |
+
'Pacific/Kosrae',
|
1066 |
+
'Pacific/Kwajalein',
|
1067 |
+
'Pacific/Majuro',
|
1068 |
+
'Pacific/Marquesas',
|
1069 |
+
'Pacific/Midway',
|
1070 |
+
'Pacific/Nauru',
|
1071 |
+
'Pacific/Niue',
|
1072 |
+
'Pacific/Norfolk',
|
1073 |
+
'Pacific/Noumea',
|
1074 |
+
'Pacific/Pago_Pago',
|
1075 |
+
'Pacific/Palau',
|
1076 |
+
'Pacific/Pitcairn',
|
1077 |
+
'Pacific/Pohnpei',
|
1078 |
+
'Pacific/Ponape',
|
1079 |
+
'Pacific/Port_Moresby',
|
1080 |
+
'Pacific/Rarotonga',
|
1081 |
+
'Pacific/Saipan',
|
1082 |
+
'Pacific/Samoa',
|
1083 |
+
'Pacific/Tahiti',
|
1084 |
+
'Pacific/Tarawa',
|
1085 |
+
'Pacific/Tongatapu',
|
1086 |
+
'Pacific/Truk',
|
1087 |
+
'Pacific/Wake',
|
1088 |
+
'Pacific/Wallis',
|
1089 |
+
'Pacific/Yap',
|
1090 |
+
'Poland',
|
1091 |
+
'Portugal',
|
1092 |
+
'ROC',
|
1093 |
+
'ROK',
|
1094 |
+
'Singapore',
|
1095 |
+
'Turkey',
|
1096 |
+
'UCT',
|
1097 |
+
'US/Alaska',
|
1098 |
+
'US/Aleutian',
|
1099 |
+
'US/Arizona',
|
1100 |
+
'US/Central',
|
1101 |
+
'US/East-Indiana',
|
1102 |
+
'US/Eastern',
|
1103 |
+
'US/Hawaii',
|
1104 |
+
'US/Indiana-Starke',
|
1105 |
+
'US/Michigan',
|
1106 |
+
'US/Mountain',
|
1107 |
+
'US/Pacific',
|
1108 |
+
'US/Samoa',
|
1109 |
+
'UTC',
|
1110 |
+
'Universal',
|
1111 |
+
'W-SU',
|
1112 |
+
'WET',
|
1113 |
+
'Zulu']
|
1114 |
+
all_timezones = LazyList(
|
1115 |
+
tz for tz in _all_timezones_unchecked if resource_exists(tz))
|
1116 |
+
|
1117 |
+
all_timezones_set = LazySet(all_timezones)
|
1118 |
+
common_timezones = \
|
1119 |
+
['Africa/Abidjan',
|
1120 |
+
'Africa/Accra',
|
1121 |
+
'Africa/Addis_Ababa',
|
1122 |
+
'Africa/Algiers',
|
1123 |
+
'Africa/Asmara',
|
1124 |
+
'Africa/Bamako',
|
1125 |
+
'Africa/Bangui',
|
1126 |
+
'Africa/Banjul',
|
1127 |
+
'Africa/Bissau',
|
1128 |
+
'Africa/Blantyre',
|
1129 |
+
'Africa/Brazzaville',
|
1130 |
+
'Africa/Bujumbura',
|
1131 |
+
'Africa/Cairo',
|
1132 |
+
'Africa/Casablanca',
|
1133 |
+
'Africa/Ceuta',
|
1134 |
+
'Africa/Conakry',
|
1135 |
+
'Africa/Dakar',
|
1136 |
+
'Africa/Dar_es_Salaam',
|
1137 |
+
'Africa/Djibouti',
|
1138 |
+
'Africa/Douala',
|
1139 |
+
'Africa/El_Aaiun',
|
1140 |
+
'Africa/Freetown',
|
1141 |
+
'Africa/Gaborone',
|
1142 |
+
'Africa/Harare',
|
1143 |
+
'Africa/Johannesburg',
|
1144 |
+
'Africa/Juba',
|
1145 |
+
'Africa/Kampala',
|
1146 |
+
'Africa/Khartoum',
|
1147 |
+
'Africa/Kigali',
|
1148 |
+
'Africa/Kinshasa',
|
1149 |
+
'Africa/Lagos',
|
1150 |
+
'Africa/Libreville',
|
1151 |
+
'Africa/Lome',
|
1152 |
+
'Africa/Luanda',
|
1153 |
+
'Africa/Lubumbashi',
|
1154 |
+
'Africa/Lusaka',
|
1155 |
+
'Africa/Malabo',
|
1156 |
+
'Africa/Maputo',
|
1157 |
+
'Africa/Maseru',
|
1158 |
+
'Africa/Mbabane',
|
1159 |
+
'Africa/Mogadishu',
|
1160 |
+
'Africa/Monrovia',
|
1161 |
+
'Africa/Nairobi',
|
1162 |
+
'Africa/Ndjamena',
|
1163 |
+
'Africa/Niamey',
|
1164 |
+
'Africa/Nouakchott',
|
1165 |
+
'Africa/Ouagadougou',
|
1166 |
+
'Africa/Porto-Novo',
|
1167 |
+
'Africa/Sao_Tome',
|
1168 |
+
'Africa/Tripoli',
|
1169 |
+
'Africa/Tunis',
|
1170 |
+
'Africa/Windhoek',
|
1171 |
+
'America/Adak',
|
1172 |
+
'America/Anchorage',
|
1173 |
+
'America/Anguilla',
|
1174 |
+
'America/Antigua',
|
1175 |
+
'America/Araguaina',
|
1176 |
+
'America/Argentina/Buenos_Aires',
|
1177 |
+
'America/Argentina/Catamarca',
|
1178 |
+
'America/Argentina/Cordoba',
|
1179 |
+
'America/Argentina/Jujuy',
|
1180 |
+
'America/Argentina/La_Rioja',
|
1181 |
+
'America/Argentina/Mendoza',
|
1182 |
+
'America/Argentina/Rio_Gallegos',
|
1183 |
+
'America/Argentina/Salta',
|
1184 |
+
'America/Argentina/San_Juan',
|
1185 |
+
'America/Argentina/San_Luis',
|
1186 |
+
'America/Argentina/Tucuman',
|
1187 |
+
'America/Argentina/Ushuaia',
|
1188 |
+
'America/Aruba',
|
1189 |
+
'America/Asuncion',
|
1190 |
+
'America/Atikokan',
|
1191 |
+
'America/Bahia',
|
1192 |
+
'America/Bahia_Banderas',
|
1193 |
+
'America/Barbados',
|
1194 |
+
'America/Belem',
|
1195 |
+
'America/Belize',
|
1196 |
+
'America/Blanc-Sablon',
|
1197 |
+
'America/Boa_Vista',
|
1198 |
+
'America/Bogota',
|
1199 |
+
'America/Boise',
|
1200 |
+
'America/Cambridge_Bay',
|
1201 |
+
'America/Campo_Grande',
|
1202 |
+
'America/Cancun',
|
1203 |
+
'America/Caracas',
|
1204 |
+
'America/Cayenne',
|
1205 |
+
'America/Cayman',
|
1206 |
+
'America/Chicago',
|
1207 |
+
'America/Chihuahua',
|
1208 |
+
'America/Ciudad_Juarez',
|
1209 |
+
'America/Costa_Rica',
|
1210 |
+
'America/Creston',
|
1211 |
+
'America/Cuiaba',
|
1212 |
+
'America/Curacao',
|
1213 |
+
'America/Danmarkshavn',
|
1214 |
+
'America/Dawson',
|
1215 |
+
'America/Dawson_Creek',
|
1216 |
+
'America/Denver',
|
1217 |
+
'America/Detroit',
|
1218 |
+
'America/Dominica',
|
1219 |
+
'America/Edmonton',
|
1220 |
+
'America/Eirunepe',
|
1221 |
+
'America/El_Salvador',
|
1222 |
+
'America/Fort_Nelson',
|
1223 |
+
'America/Fortaleza',
|
1224 |
+
'America/Glace_Bay',
|
1225 |
+
'America/Goose_Bay',
|
1226 |
+
'America/Grand_Turk',
|
1227 |
+
'America/Grenada',
|
1228 |
+
'America/Guadeloupe',
|
1229 |
+
'America/Guatemala',
|
1230 |
+
'America/Guayaquil',
|
1231 |
+
'America/Guyana',
|
1232 |
+
'America/Halifax',
|
1233 |
+
'America/Havana',
|
1234 |
+
'America/Hermosillo',
|
1235 |
+
'America/Indiana/Indianapolis',
|
1236 |
+
'America/Indiana/Knox',
|
1237 |
+
'America/Indiana/Marengo',
|
1238 |
+
'America/Indiana/Petersburg',
|
1239 |
+
'America/Indiana/Tell_City',
|
1240 |
+
'America/Indiana/Vevay',
|
1241 |
+
'America/Indiana/Vincennes',
|
1242 |
+
'America/Indiana/Winamac',
|
1243 |
+
'America/Inuvik',
|
1244 |
+
'America/Iqaluit',
|
1245 |
+
'America/Jamaica',
|
1246 |
+
'America/Juneau',
|
1247 |
+
'America/Kentucky/Louisville',
|
1248 |
+
'America/Kentucky/Monticello',
|
1249 |
+
'America/Kralendijk',
|
1250 |
+
'America/La_Paz',
|
1251 |
+
'America/Lima',
|
1252 |
+
'America/Los_Angeles',
|
1253 |
+
'America/Lower_Princes',
|
1254 |
+
'America/Maceio',
|
1255 |
+
'America/Managua',
|
1256 |
+
'America/Manaus',
|
1257 |
+
'America/Marigot',
|
1258 |
+
'America/Martinique',
|
1259 |
+
'America/Matamoros',
|
1260 |
+
'America/Mazatlan',
|
1261 |
+
'America/Menominee',
|
1262 |
+
'America/Merida',
|
1263 |
+
'America/Metlakatla',
|
1264 |
+
'America/Mexico_City',
|
1265 |
+
'America/Miquelon',
|
1266 |
+
'America/Moncton',
|
1267 |
+
'America/Monterrey',
|
1268 |
+
'America/Montevideo',
|
1269 |
+
'America/Montserrat',
|
1270 |
+
'America/Nassau',
|
1271 |
+
'America/New_York',
|
1272 |
+
'America/Nome',
|
1273 |
+
'America/Noronha',
|
1274 |
+
'America/North_Dakota/Beulah',
|
1275 |
+
'America/North_Dakota/Center',
|
1276 |
+
'America/North_Dakota/New_Salem',
|
1277 |
+
'America/Nuuk',
|
1278 |
+
'America/Ojinaga',
|
1279 |
+
'America/Panama',
|
1280 |
+
'America/Paramaribo',
|
1281 |
+
'America/Phoenix',
|
1282 |
+
'America/Port-au-Prince',
|
1283 |
+
'America/Port_of_Spain',
|
1284 |
+
'America/Porto_Velho',
|
1285 |
+
'America/Puerto_Rico',
|
1286 |
+
'America/Punta_Arenas',
|
1287 |
+
'America/Rankin_Inlet',
|
1288 |
+
'America/Recife',
|
1289 |
+
'America/Regina',
|
1290 |
+
'America/Resolute',
|
1291 |
+
'America/Rio_Branco',
|
1292 |
+
'America/Santarem',
|
1293 |
+
'America/Santiago',
|
1294 |
+
'America/Santo_Domingo',
|
1295 |
+
'America/Sao_Paulo',
|
1296 |
+
'America/Scoresbysund',
|
1297 |
+
'America/Sitka',
|
1298 |
+
'America/St_Barthelemy',
|
1299 |
+
'America/St_Johns',
|
1300 |
+
'America/St_Kitts',
|
1301 |
+
'America/St_Lucia',
|
1302 |
+
'America/St_Thomas',
|
1303 |
+
'America/St_Vincent',
|
1304 |
+
'America/Swift_Current',
|
1305 |
+
'America/Tegucigalpa',
|
1306 |
+
'America/Thule',
|
1307 |
+
'America/Tijuana',
|
1308 |
+
'America/Toronto',
|
1309 |
+
'America/Tortola',
|
1310 |
+
'America/Vancouver',
|
1311 |
+
'America/Whitehorse',
|
1312 |
+
'America/Winnipeg',
|
1313 |
+
'America/Yakutat',
|
1314 |
+
'Antarctica/Casey',
|
1315 |
+
'Antarctica/Davis',
|
1316 |
+
'Antarctica/DumontDUrville',
|
1317 |
+
'Antarctica/Macquarie',
|
1318 |
+
'Antarctica/Mawson',
|
1319 |
+
'Antarctica/McMurdo',
|
1320 |
+
'Antarctica/Palmer',
|
1321 |
+
'Antarctica/Rothera',
|
1322 |
+
'Antarctica/Syowa',
|
1323 |
+
'Antarctica/Troll',
|
1324 |
+
'Antarctica/Vostok',
|
1325 |
+
'Arctic/Longyearbyen',
|
1326 |
+
'Asia/Aden',
|
1327 |
+
'Asia/Almaty',
|
1328 |
+
'Asia/Amman',
|
1329 |
+
'Asia/Anadyr',
|
1330 |
+
'Asia/Aqtau',
|
1331 |
+
'Asia/Aqtobe',
|
1332 |
+
'Asia/Ashgabat',
|
1333 |
+
'Asia/Atyrau',
|
1334 |
+
'Asia/Baghdad',
|
1335 |
+
'Asia/Bahrain',
|
1336 |
+
'Asia/Baku',
|
1337 |
+
'Asia/Bangkok',
|
1338 |
+
'Asia/Barnaul',
|
1339 |
+
'Asia/Beirut',
|
1340 |
+
'Asia/Bishkek',
|
1341 |
+
'Asia/Brunei',
|
1342 |
+
'Asia/Chita',
|
1343 |
+
'Asia/Choibalsan',
|
1344 |
+
'Asia/Colombo',
|
1345 |
+
'Asia/Damascus',
|
1346 |
+
'Asia/Dhaka',
|
1347 |
+
'Asia/Dili',
|
1348 |
+
'Asia/Dubai',
|
1349 |
+
'Asia/Dushanbe',
|
1350 |
+
'Asia/Famagusta',
|
1351 |
+
'Asia/Gaza',
|
1352 |
+
'Asia/Hebron',
|
1353 |
+
'Asia/Ho_Chi_Minh',
|
1354 |
+
'Asia/Hong_Kong',
|
1355 |
+
'Asia/Hovd',
|
1356 |
+
'Asia/Irkutsk',
|
1357 |
+
'Asia/Jakarta',
|
1358 |
+
'Asia/Jayapura',
|
1359 |
+
'Asia/Jerusalem',
|
1360 |
+
'Asia/Kabul',
|
1361 |
+
'Asia/Kamchatka',
|
1362 |
+
'Asia/Karachi',
|
1363 |
+
'Asia/Kathmandu',
|
1364 |
+
'Asia/Khandyga',
|
1365 |
+
'Asia/Kolkata',
|
1366 |
+
'Asia/Krasnoyarsk',
|
1367 |
+
'Asia/Kuala_Lumpur',
|
1368 |
+
'Asia/Kuching',
|
1369 |
+
'Asia/Kuwait',
|
1370 |
+
'Asia/Macau',
|
1371 |
+
'Asia/Magadan',
|
1372 |
+
'Asia/Makassar',
|
1373 |
+
'Asia/Manila',
|
1374 |
+
'Asia/Muscat',
|
1375 |
+
'Asia/Nicosia',
|
1376 |
+
'Asia/Novokuznetsk',
|
1377 |
+
'Asia/Novosibirsk',
|
1378 |
+
'Asia/Omsk',
|
1379 |
+
'Asia/Oral',
|
1380 |
+
'Asia/Phnom_Penh',
|
1381 |
+
'Asia/Pontianak',
|
1382 |
+
'Asia/Pyongyang',
|
1383 |
+
'Asia/Qatar',
|
1384 |
+
'Asia/Qostanay',
|
1385 |
+
'Asia/Qyzylorda',
|
1386 |
+
'Asia/Riyadh',
|
1387 |
+
'Asia/Sakhalin',
|
1388 |
+
'Asia/Samarkand',
|
1389 |
+
'Asia/Seoul',
|
1390 |
+
'Asia/Shanghai',
|
1391 |
+
'Asia/Singapore',
|
1392 |
+
'Asia/Srednekolymsk',
|
1393 |
+
'Asia/Taipei',
|
1394 |
+
'Asia/Tashkent',
|
1395 |
+
'Asia/Tbilisi',
|
1396 |
+
'Asia/Tehran',
|
1397 |
+
'Asia/Thimphu',
|
1398 |
+
'Asia/Tokyo',
|
1399 |
+
'Asia/Tomsk',
|
1400 |
+
'Asia/Ulaanbaatar',
|
1401 |
+
'Asia/Urumqi',
|
1402 |
+
'Asia/Ust-Nera',
|
1403 |
+
'Asia/Vientiane',
|
1404 |
+
'Asia/Vladivostok',
|
1405 |
+
'Asia/Yakutsk',
|
1406 |
+
'Asia/Yangon',
|
1407 |
+
'Asia/Yekaterinburg',
|
1408 |
+
'Asia/Yerevan',
|
1409 |
+
'Atlantic/Azores',
|
1410 |
+
'Atlantic/Bermuda',
|
1411 |
+
'Atlantic/Canary',
|
1412 |
+
'Atlantic/Cape_Verde',
|
1413 |
+
'Atlantic/Faroe',
|
1414 |
+
'Atlantic/Madeira',
|
1415 |
+
'Atlantic/Reykjavik',
|
1416 |
+
'Atlantic/South_Georgia',
|
1417 |
+
'Atlantic/St_Helena',
|
1418 |
+
'Atlantic/Stanley',
|
1419 |
+
'Australia/Adelaide',
|
1420 |
+
'Australia/Brisbane',
|
1421 |
+
'Australia/Broken_Hill',
|
1422 |
+
'Australia/Darwin',
|
1423 |
+
'Australia/Eucla',
|
1424 |
+
'Australia/Hobart',
|
1425 |
+
'Australia/Lindeman',
|
1426 |
+
'Australia/Lord_Howe',
|
1427 |
+
'Australia/Melbourne',
|
1428 |
+
'Australia/Perth',
|
1429 |
+
'Australia/Sydney',
|
1430 |
+
'Canada/Atlantic',
|
1431 |
+
'Canada/Central',
|
1432 |
+
'Canada/Eastern',
|
1433 |
+
'Canada/Mountain',
|
1434 |
+
'Canada/Newfoundland',
|
1435 |
+
'Canada/Pacific',
|
1436 |
+
'Europe/Amsterdam',
|
1437 |
+
'Europe/Andorra',
|
1438 |
+
'Europe/Astrakhan',
|
1439 |
+
'Europe/Athens',
|
1440 |
+
'Europe/Belgrade',
|
1441 |
+
'Europe/Berlin',
|
1442 |
+
'Europe/Bratislava',
|
1443 |
+
'Europe/Brussels',
|
1444 |
+
'Europe/Bucharest',
|
1445 |
+
'Europe/Budapest',
|
1446 |
+
'Europe/Busingen',
|
1447 |
+
'Europe/Chisinau',
|
1448 |
+
'Europe/Copenhagen',
|
1449 |
+
'Europe/Dublin',
|
1450 |
+
'Europe/Gibraltar',
|
1451 |
+
'Europe/Guernsey',
|
1452 |
+
'Europe/Helsinki',
|
1453 |
+
'Europe/Isle_of_Man',
|
1454 |
+
'Europe/Istanbul',
|
1455 |
+
'Europe/Jersey',
|
1456 |
+
'Europe/Kaliningrad',
|
1457 |
+
'Europe/Kirov',
|
1458 |
+
'Europe/Kyiv',
|
1459 |
+
'Europe/Lisbon',
|
1460 |
+
'Europe/Ljubljana',
|
1461 |
+
'Europe/London',
|
1462 |
+
'Europe/Luxembourg',
|
1463 |
+
'Europe/Madrid',
|
1464 |
+
'Europe/Malta',
|
1465 |
+
'Europe/Mariehamn',
|
1466 |
+
'Europe/Minsk',
|
1467 |
+
'Europe/Monaco',
|
1468 |
+
'Europe/Moscow',
|
1469 |
+
'Europe/Oslo',
|
1470 |
+
'Europe/Paris',
|
1471 |
+
'Europe/Podgorica',
|
1472 |
+
'Europe/Prague',
|
1473 |
+
'Europe/Riga',
|
1474 |
+
'Europe/Rome',
|
1475 |
+
'Europe/Samara',
|
1476 |
+
'Europe/San_Marino',
|
1477 |
+
'Europe/Sarajevo',
|
1478 |
+
'Europe/Saratov',
|
1479 |
+
'Europe/Simferopol',
|
1480 |
+
'Europe/Skopje',
|
1481 |
+
'Europe/Sofia',
|
1482 |
+
'Europe/Stockholm',
|
1483 |
+
'Europe/Tallinn',
|
1484 |
+
'Europe/Tirane',
|
1485 |
+
'Europe/Ulyanovsk',
|
1486 |
+
'Europe/Vaduz',
|
1487 |
+
'Europe/Vatican',
|
1488 |
+
'Europe/Vienna',
|
1489 |
+
'Europe/Vilnius',
|
1490 |
+
'Europe/Volgograd',
|
1491 |
+
'Europe/Warsaw',
|
1492 |
+
'Europe/Zagreb',
|
1493 |
+
'Europe/Zurich',
|
1494 |
+
'GMT',
|
1495 |
+
'Indian/Antananarivo',
|
1496 |
+
'Indian/Chagos',
|
1497 |
+
'Indian/Christmas',
|
1498 |
+
'Indian/Cocos',
|
1499 |
+
'Indian/Comoro',
|
1500 |
+
'Indian/Kerguelen',
|
1501 |
+
'Indian/Mahe',
|
1502 |
+
'Indian/Maldives',
|
1503 |
+
'Indian/Mauritius',
|
1504 |
+
'Indian/Mayotte',
|
1505 |
+
'Indian/Reunion',
|
1506 |
+
'Pacific/Apia',
|
1507 |
+
'Pacific/Auckland',
|
1508 |
+
'Pacific/Bougainville',
|
1509 |
+
'Pacific/Chatham',
|
1510 |
+
'Pacific/Chuuk',
|
1511 |
+
'Pacific/Easter',
|
1512 |
+
'Pacific/Efate',
|
1513 |
+
'Pacific/Fakaofo',
|
1514 |
+
'Pacific/Fiji',
|
1515 |
+
'Pacific/Funafuti',
|
1516 |
+
'Pacific/Galapagos',
|
1517 |
+
'Pacific/Gambier',
|
1518 |
+
'Pacific/Guadalcanal',
|
1519 |
+
'Pacific/Guam',
|
1520 |
+
'Pacific/Honolulu',
|
1521 |
+
'Pacific/Kanton',
|
1522 |
+
'Pacific/Kiritimati',
|
1523 |
+
'Pacific/Kosrae',
|
1524 |
+
'Pacific/Kwajalein',
|
1525 |
+
'Pacific/Majuro',
|
1526 |
+
'Pacific/Marquesas',
|
1527 |
+
'Pacific/Midway',
|
1528 |
+
'Pacific/Nauru',
|
1529 |
+
'Pacific/Niue',
|
1530 |
+
'Pacific/Norfolk',
|
1531 |
+
'Pacific/Noumea',
|
1532 |
+
'Pacific/Pago_Pago',
|
1533 |
+
'Pacific/Palau',
|
1534 |
+
'Pacific/Pitcairn',
|
1535 |
+
'Pacific/Pohnpei',
|
1536 |
+
'Pacific/Port_Moresby',
|
1537 |
+
'Pacific/Rarotonga',
|
1538 |
+
'Pacific/Saipan',
|
1539 |
+
'Pacific/Tahiti',
|
1540 |
+
'Pacific/Tarawa',
|
1541 |
+
'Pacific/Tongatapu',
|
1542 |
+
'Pacific/Wake',
|
1543 |
+
'Pacific/Wallis',
|
1544 |
+
'US/Alaska',
|
1545 |
+
'US/Arizona',
|
1546 |
+
'US/Central',
|
1547 |
+
'US/Eastern',
|
1548 |
+
'US/Hawaii',
|
1549 |
+
'US/Mountain',
|
1550 |
+
'US/Pacific',
|
1551 |
+
'UTC']
|
1552 |
+
common_timezones = LazyList(
|
1553 |
+
tz for tz in common_timezones if tz in all_timezones)
|
1554 |
+
|
1555 |
+
common_timezones_set = LazySet(common_timezones)
|
llmeval-env/lib/python3.10/site-packages/pytz/exceptions.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''
|
2 |
+
Custom exceptions raised by pytz.
|
3 |
+
'''
|
4 |
+
|
5 |
+
__all__ = [
|
6 |
+
'UnknownTimeZoneError', 'InvalidTimeError', 'AmbiguousTimeError',
|
7 |
+
'NonExistentTimeError',
|
8 |
+
]
|
9 |
+
|
10 |
+
|
11 |
+
class Error(Exception):
|
12 |
+
'''Base class for all exceptions raised by the pytz library'''
|
13 |
+
|
14 |
+
|
15 |
+
class UnknownTimeZoneError(KeyError, Error):
|
16 |
+
'''Exception raised when pytz is passed an unknown timezone.
|
17 |
+
|
18 |
+
>>> isinstance(UnknownTimeZoneError(), LookupError)
|
19 |
+
True
|
20 |
+
|
21 |
+
This class is actually a subclass of KeyError to provide backwards
|
22 |
+
compatibility with code relying on the undocumented behavior of earlier
|
23 |
+
pytz releases.
|
24 |
+
|
25 |
+
>>> isinstance(UnknownTimeZoneError(), KeyError)
|
26 |
+
True
|
27 |
+
|
28 |
+
And also a subclass of pytz.exceptions.Error, as are other pytz
|
29 |
+
exceptions.
|
30 |
+
|
31 |
+
>>> isinstance(UnknownTimeZoneError(), Error)
|
32 |
+
True
|
33 |
+
|
34 |
+
'''
|
35 |
+
pass
|
36 |
+
|
37 |
+
|
38 |
+
class InvalidTimeError(Error):
|
39 |
+
'''Base class for invalid time exceptions.'''
|
40 |
+
|
41 |
+
|
42 |
+
class AmbiguousTimeError(InvalidTimeError):
|
43 |
+
'''Exception raised when attempting to create an ambiguous wallclock time.
|
44 |
+
|
45 |
+
At the end of a DST transition period, a particular wallclock time will
|
46 |
+
occur twice (once before the clocks are set back, once after). Both
|
47 |
+
possibilities may be correct, unless further information is supplied.
|
48 |
+
|
49 |
+
See DstTzInfo.normalize() for more info
|
50 |
+
'''
|
51 |
+
|
52 |
+
|
53 |
+
class NonExistentTimeError(InvalidTimeError):
|
54 |
+
'''Exception raised when attempting to create a wallclock time that
|
55 |
+
cannot exist.
|
56 |
+
|
57 |
+
At the start of a DST transition period, the wallclock time jumps forward.
|
58 |
+
The instants jumped over never occur.
|
59 |
+
'''
|
llmeval-env/lib/python3.10/site-packages/pytz/lazy.py
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from threading import RLock
|
2 |
+
try:
|
3 |
+
from collections.abc import Mapping as DictMixin
|
4 |
+
except ImportError: # Python < 3.3
|
5 |
+
try:
|
6 |
+
from UserDict import DictMixin # Python 2
|
7 |
+
except ImportError: # Python 3.0-3.3
|
8 |
+
from collections import Mapping as DictMixin
|
9 |
+
|
10 |
+
|
11 |
+
# With lazy loading, we might end up with multiple threads triggering
|
12 |
+
# it at the same time. We need a lock.
|
13 |
+
_fill_lock = RLock()
|
14 |
+
|
15 |
+
|
16 |
+
class LazyDict(DictMixin):
|
17 |
+
"""Dictionary populated on first use."""
|
18 |
+
data = None
|
19 |
+
|
20 |
+
def __getitem__(self, key):
|
21 |
+
if self.data is None:
|
22 |
+
_fill_lock.acquire()
|
23 |
+
try:
|
24 |
+
if self.data is None:
|
25 |
+
self._fill()
|
26 |
+
finally:
|
27 |
+
_fill_lock.release()
|
28 |
+
return self.data[key.upper()]
|
29 |
+
|
30 |
+
def __contains__(self, key):
|
31 |
+
if self.data is None:
|
32 |
+
_fill_lock.acquire()
|
33 |
+
try:
|
34 |
+
if self.data is None:
|
35 |
+
self._fill()
|
36 |
+
finally:
|
37 |
+
_fill_lock.release()
|
38 |
+
return key in self.data
|
39 |
+
|
40 |
+
def __iter__(self):
|
41 |
+
if self.data is None:
|
42 |
+
_fill_lock.acquire()
|
43 |
+
try:
|
44 |
+
if self.data is None:
|
45 |
+
self._fill()
|
46 |
+
finally:
|
47 |
+
_fill_lock.release()
|
48 |
+
return iter(self.data)
|
49 |
+
|
50 |
+
def __len__(self):
|
51 |
+
if self.data is None:
|
52 |
+
_fill_lock.acquire()
|
53 |
+
try:
|
54 |
+
if self.data is None:
|
55 |
+
self._fill()
|
56 |
+
finally:
|
57 |
+
_fill_lock.release()
|
58 |
+
return len(self.data)
|
59 |
+
|
60 |
+
def keys(self):
|
61 |
+
if self.data is None:
|
62 |
+
_fill_lock.acquire()
|
63 |
+
try:
|
64 |
+
if self.data is None:
|
65 |
+
self._fill()
|
66 |
+
finally:
|
67 |
+
_fill_lock.release()
|
68 |
+
return self.data.keys()
|
69 |
+
|
70 |
+
|
71 |
+
class LazyList(list):
|
72 |
+
"""List populated on first use."""
|
73 |
+
|
74 |
+
_props = [
|
75 |
+
'__str__', '__repr__', '__unicode__',
|
76 |
+
'__hash__', '__sizeof__', '__cmp__',
|
77 |
+
'__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__',
|
78 |
+
'append', 'count', 'index', 'extend', 'insert', 'pop', 'remove',
|
79 |
+
'reverse', 'sort', '__add__', '__radd__', '__iadd__', '__mul__',
|
80 |
+
'__rmul__', '__imul__', '__contains__', '__len__', '__nonzero__',
|
81 |
+
'__getitem__', '__setitem__', '__delitem__', '__iter__',
|
82 |
+
'__reversed__', '__getslice__', '__setslice__', '__delslice__']
|
83 |
+
|
84 |
+
def __new__(cls, fill_iter=None):
|
85 |
+
|
86 |
+
if fill_iter is None:
|
87 |
+
return list()
|
88 |
+
|
89 |
+
# We need a new class as we will be dynamically messing with its
|
90 |
+
# methods.
|
91 |
+
class LazyList(list):
|
92 |
+
pass
|
93 |
+
|
94 |
+
fill_iter = [fill_iter]
|
95 |
+
|
96 |
+
def lazy(name):
|
97 |
+
def _lazy(self, *args, **kw):
|
98 |
+
_fill_lock.acquire()
|
99 |
+
try:
|
100 |
+
if len(fill_iter) > 0:
|
101 |
+
list.extend(self, fill_iter.pop())
|
102 |
+
for method_name in cls._props:
|
103 |
+
delattr(LazyList, method_name)
|
104 |
+
finally:
|
105 |
+
_fill_lock.release()
|
106 |
+
return getattr(list, name)(self, *args, **kw)
|
107 |
+
return _lazy
|
108 |
+
|
109 |
+
for name in cls._props:
|
110 |
+
setattr(LazyList, name, lazy(name))
|
111 |
+
|
112 |
+
new_list = LazyList()
|
113 |
+
return new_list
|
114 |
+
|
115 |
+
# Not all versions of Python declare the same magic methods.
|
116 |
+
# Filter out properties that don't exist in this version of Python
|
117 |
+
# from the list.
|
118 |
+
LazyList._props = [prop for prop in LazyList._props if hasattr(list, prop)]
|
119 |
+
|
120 |
+
|
121 |
+
class LazySet(set):
|
122 |
+
"""Set populated on first use."""
|
123 |
+
|
124 |
+
_props = (
|
125 |
+
'__str__', '__repr__', '__unicode__',
|
126 |
+
'__hash__', '__sizeof__', '__cmp__',
|
127 |
+
'__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__',
|
128 |
+
'__contains__', '__len__', '__nonzero__',
|
129 |
+
'__getitem__', '__setitem__', '__delitem__', '__iter__',
|
130 |
+
'__sub__', '__and__', '__xor__', '__or__',
|
131 |
+
'__rsub__', '__rand__', '__rxor__', '__ror__',
|
132 |
+
'__isub__', '__iand__', '__ixor__', '__ior__',
|
133 |
+
'add', 'clear', 'copy', 'difference', 'difference_update',
|
134 |
+
'discard', 'intersection', 'intersection_update', 'isdisjoint',
|
135 |
+
'issubset', 'issuperset', 'pop', 'remove',
|
136 |
+
'symmetric_difference', 'symmetric_difference_update',
|
137 |
+
'union', 'update')
|
138 |
+
|
139 |
+
def __new__(cls, fill_iter=None):
|
140 |
+
|
141 |
+
if fill_iter is None:
|
142 |
+
return set()
|
143 |
+
|
144 |
+
class LazySet(set):
|
145 |
+
pass
|
146 |
+
|
147 |
+
fill_iter = [fill_iter]
|
148 |
+
|
149 |
+
def lazy(name):
|
150 |
+
def _lazy(self, *args, **kw):
|
151 |
+
_fill_lock.acquire()
|
152 |
+
try:
|
153 |
+
if len(fill_iter) > 0:
|
154 |
+
for i in fill_iter.pop():
|
155 |
+
set.add(self, i)
|
156 |
+
for method_name in cls._props:
|
157 |
+
delattr(LazySet, method_name)
|
158 |
+
finally:
|
159 |
+
_fill_lock.release()
|
160 |
+
return getattr(set, name)(self, *args, **kw)
|
161 |
+
return _lazy
|
162 |
+
|
163 |
+
for name in cls._props:
|
164 |
+
setattr(LazySet, name, lazy(name))
|
165 |
+
|
166 |
+
new_set = LazySet()
|
167 |
+
return new_set
|
168 |
+
|
169 |
+
# Not all versions of Python declare the same magic methods.
|
170 |
+
# Filter out properties that don't exist in this version of Python
|
171 |
+
# from the list.
|
172 |
+
LazySet._props = [prop for prop in LazySet._props if hasattr(set, prop)]
|
llmeval-env/lib/python3.10/site-packages/pytz/reference.py
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''
|
2 |
+
Reference tzinfo implementations from the Python docs.
|
3 |
+
Used for testing against as they are only correct for the years
|
4 |
+
1987 to 2006. Do not use these for real code.
|
5 |
+
'''
|
6 |
+
|
7 |
+
from datetime import tzinfo, timedelta, datetime
|
8 |
+
from pytz import HOUR, ZERO, UTC
|
9 |
+
|
10 |
+
__all__ = [
|
11 |
+
'FixedOffset',
|
12 |
+
'LocalTimezone',
|
13 |
+
'USTimeZone',
|
14 |
+
'Eastern',
|
15 |
+
'Central',
|
16 |
+
'Mountain',
|
17 |
+
'Pacific',
|
18 |
+
'UTC'
|
19 |
+
]
|
20 |
+
|
21 |
+
|
22 |
+
# A class building tzinfo objects for fixed-offset time zones.
|
23 |
+
# Note that FixedOffset(0, "UTC") is a different way to build a
|
24 |
+
# UTC tzinfo object.
|
25 |
+
class FixedOffset(tzinfo):
|
26 |
+
"""Fixed offset in minutes east from UTC."""
|
27 |
+
|
28 |
+
def __init__(self, offset, name):
|
29 |
+
self.__offset = timedelta(minutes=offset)
|
30 |
+
self.__name = name
|
31 |
+
|
32 |
+
def utcoffset(self, dt):
|
33 |
+
return self.__offset
|
34 |
+
|
35 |
+
def tzname(self, dt):
|
36 |
+
return self.__name
|
37 |
+
|
38 |
+
def dst(self, dt):
|
39 |
+
return ZERO
|
40 |
+
|
41 |
+
|
42 |
+
import time as _time
|
43 |
+
|
44 |
+
STDOFFSET = timedelta(seconds=-_time.timezone)
|
45 |
+
if _time.daylight:
|
46 |
+
DSTOFFSET = timedelta(seconds=-_time.altzone)
|
47 |
+
else:
|
48 |
+
DSTOFFSET = STDOFFSET
|
49 |
+
|
50 |
+
DSTDIFF = DSTOFFSET - STDOFFSET
|
51 |
+
|
52 |
+
|
53 |
+
# A class capturing the platform's idea of local time.
|
54 |
+
class LocalTimezone(tzinfo):
|
55 |
+
|
56 |
+
def utcoffset(self, dt):
|
57 |
+
if self._isdst(dt):
|
58 |
+
return DSTOFFSET
|
59 |
+
else:
|
60 |
+
return STDOFFSET
|
61 |
+
|
62 |
+
def dst(self, dt):
|
63 |
+
if self._isdst(dt):
|
64 |
+
return DSTDIFF
|
65 |
+
else:
|
66 |
+
return ZERO
|
67 |
+
|
68 |
+
def tzname(self, dt):
|
69 |
+
return _time.tzname[self._isdst(dt)]
|
70 |
+
|
71 |
+
def _isdst(self, dt):
|
72 |
+
tt = (dt.year, dt.month, dt.day,
|
73 |
+
dt.hour, dt.minute, dt.second,
|
74 |
+
dt.weekday(), 0, -1)
|
75 |
+
stamp = _time.mktime(tt)
|
76 |
+
tt = _time.localtime(stamp)
|
77 |
+
return tt.tm_isdst > 0
|
78 |
+
|
79 |
+
Local = LocalTimezone()
|
80 |
+
|
81 |
+
|
82 |
+
def first_sunday_on_or_after(dt):
|
83 |
+
days_to_go = 6 - dt.weekday()
|
84 |
+
if days_to_go:
|
85 |
+
dt += timedelta(days_to_go)
|
86 |
+
return dt
|
87 |
+
|
88 |
+
|
89 |
+
# In the US, DST starts at 2am (standard time) on the first Sunday in April.
|
90 |
+
DSTSTART = datetime(1, 4, 1, 2)
|
91 |
+
# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct.
|
92 |
+
# which is the first Sunday on or after Oct 25.
|
93 |
+
DSTEND = datetime(1, 10, 25, 1)
|
94 |
+
|
95 |
+
|
96 |
+
# A complete implementation of current DST rules for major US time zones.
|
97 |
+
class USTimeZone(tzinfo):
|
98 |
+
|
99 |
+
def __init__(self, hours, reprname, stdname, dstname):
|
100 |
+
self.stdoffset = timedelta(hours=hours)
|
101 |
+
self.reprname = reprname
|
102 |
+
self.stdname = stdname
|
103 |
+
self.dstname = dstname
|
104 |
+
|
105 |
+
def __repr__(self):
|
106 |
+
return self.reprname
|
107 |
+
|
108 |
+
def tzname(self, dt):
|
109 |
+
if self.dst(dt):
|
110 |
+
return self.dstname
|
111 |
+
else:
|
112 |
+
return self.stdname
|
113 |
+
|
114 |
+
def utcoffset(self, dt):
|
115 |
+
return self.stdoffset + self.dst(dt)
|
116 |
+
|
117 |
+
def dst(self, dt):
|
118 |
+
if dt is None or dt.tzinfo is None:
|
119 |
+
# An exception may be sensible here, in one or both cases.
|
120 |
+
# It depends on how you want to treat them. The default
|
121 |
+
# fromutc() implementation (called by the default astimezone()
|
122 |
+
# implementation) passes a datetime with dt.tzinfo is self.
|
123 |
+
return ZERO
|
124 |
+
assert dt.tzinfo is self
|
125 |
+
|
126 |
+
# Find first Sunday in April & the last in October.
|
127 |
+
start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
|
128 |
+
end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
|
129 |
+
|
130 |
+
# Can't compare naive to aware objects, so strip the timezone from
|
131 |
+
# dt first.
|
132 |
+
if start <= dt.replace(tzinfo=None) < end:
|
133 |
+
return HOUR
|
134 |
+
else:
|
135 |
+
return ZERO
|
136 |
+
|
137 |
+
Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
|
138 |
+
Central = USTimeZone(-6, "Central", "CST", "CDT")
|
139 |
+
Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
|
140 |
+
Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
|
llmeval-env/lib/python3.10/site-packages/pytz/tzfile.py
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''
|
2 |
+
$Id: tzfile.py,v 1.8 2004/06/03 00:15:24 zenzen Exp $
|
3 |
+
'''
|
4 |
+
|
5 |
+
from datetime import datetime
|
6 |
+
from struct import unpack, calcsize
|
7 |
+
|
8 |
+
from pytz.tzinfo import StaticTzInfo, DstTzInfo, memorized_ttinfo
|
9 |
+
from pytz.tzinfo import memorized_datetime, memorized_timedelta
|
10 |
+
|
11 |
+
|
12 |
+
def _byte_string(s):
|
13 |
+
"""Cast a string or byte string to an ASCII byte string."""
|
14 |
+
return s.encode('ASCII')
|
15 |
+
|
16 |
+
_NULL = _byte_string('\0')
|
17 |
+
|
18 |
+
|
19 |
+
def _std_string(s):
|
20 |
+
"""Cast a string or byte string to an ASCII string."""
|
21 |
+
return str(s.decode('ASCII'))
|
22 |
+
|
23 |
+
|
24 |
+
def build_tzinfo(zone, fp):
|
25 |
+
head_fmt = '>4s c 15x 6l'
|
26 |
+
head_size = calcsize(head_fmt)
|
27 |
+
(magic, format, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt,
|
28 |
+
typecnt, charcnt) = unpack(head_fmt, fp.read(head_size))
|
29 |
+
|
30 |
+
# Make sure it is a tzfile(5) file
|
31 |
+
assert magic == _byte_string('TZif'), 'Got magic %s' % repr(magic)
|
32 |
+
|
33 |
+
# Read out the transition times, localtime indices and ttinfo structures.
|
34 |
+
data_fmt = '>%(timecnt)dl %(timecnt)dB %(ttinfo)s %(charcnt)ds' % dict(
|
35 |
+
timecnt=timecnt, ttinfo='lBB' * typecnt, charcnt=charcnt)
|
36 |
+
data_size = calcsize(data_fmt)
|
37 |
+
data = unpack(data_fmt, fp.read(data_size))
|
38 |
+
|
39 |
+
# make sure we unpacked the right number of values
|
40 |
+
assert len(data) == 2 * timecnt + 3 * typecnt + 1
|
41 |
+
transitions = [memorized_datetime(trans)
|
42 |
+
for trans in data[:timecnt]]
|
43 |
+
lindexes = list(data[timecnt:2 * timecnt])
|
44 |
+
ttinfo_raw = data[2 * timecnt:-1]
|
45 |
+
tznames_raw = data[-1]
|
46 |
+
del data
|
47 |
+
|
48 |
+
# Process ttinfo into separate structs
|
49 |
+
ttinfo = []
|
50 |
+
tznames = {}
|
51 |
+
i = 0
|
52 |
+
while i < len(ttinfo_raw):
|
53 |
+
# have we looked up this timezone name yet?
|
54 |
+
tzname_offset = ttinfo_raw[i + 2]
|
55 |
+
if tzname_offset not in tznames:
|
56 |
+
nul = tznames_raw.find(_NULL, tzname_offset)
|
57 |
+
if nul < 0:
|
58 |
+
nul = len(tznames_raw)
|
59 |
+
tznames[tzname_offset] = _std_string(
|
60 |
+
tznames_raw[tzname_offset:nul])
|
61 |
+
ttinfo.append((ttinfo_raw[i],
|
62 |
+
bool(ttinfo_raw[i + 1]),
|
63 |
+
tznames[tzname_offset]))
|
64 |
+
i += 3
|
65 |
+
|
66 |
+
# Now build the timezone object
|
67 |
+
if len(ttinfo) == 1 or len(transitions) == 0:
|
68 |
+
ttinfo[0][0], ttinfo[0][2]
|
69 |
+
cls = type(zone, (StaticTzInfo,), dict(
|
70 |
+
zone=zone,
|
71 |
+
_utcoffset=memorized_timedelta(ttinfo[0][0]),
|
72 |
+
_tzname=ttinfo[0][2]))
|
73 |
+
else:
|
74 |
+
# Early dates use the first standard time ttinfo
|
75 |
+
i = 0
|
76 |
+
while ttinfo[i][1]:
|
77 |
+
i += 1
|
78 |
+
if ttinfo[i] == ttinfo[lindexes[0]]:
|
79 |
+
transitions[0] = datetime.min
|
80 |
+
else:
|
81 |
+
transitions.insert(0, datetime.min)
|
82 |
+
lindexes.insert(0, i)
|
83 |
+
|
84 |
+
# calculate transition info
|
85 |
+
transition_info = []
|
86 |
+
for i in range(len(transitions)):
|
87 |
+
inf = ttinfo[lindexes[i]]
|
88 |
+
utcoffset = inf[0]
|
89 |
+
if not inf[1]:
|
90 |
+
dst = 0
|
91 |
+
else:
|
92 |
+
for j in range(i - 1, -1, -1):
|
93 |
+
prev_inf = ttinfo[lindexes[j]]
|
94 |
+
if not prev_inf[1]:
|
95 |
+
break
|
96 |
+
dst = inf[0] - prev_inf[0] # dst offset
|
97 |
+
|
98 |
+
# Bad dst? Look further. DST > 24 hours happens when
|
99 |
+
# a timzone has moved across the international dateline.
|
100 |
+
if dst <= 0 or dst > 3600 * 3:
|
101 |
+
for j in range(i + 1, len(transitions)):
|
102 |
+
stdinf = ttinfo[lindexes[j]]
|
103 |
+
if not stdinf[1]:
|
104 |
+
dst = inf[0] - stdinf[0]
|
105 |
+
if dst > 0:
|
106 |
+
break # Found a useful std time.
|
107 |
+
|
108 |
+
tzname = inf[2]
|
109 |
+
|
110 |
+
# Round utcoffset and dst to the nearest minute or the
|
111 |
+
# datetime library will complain. Conversions to these timezones
|
112 |
+
# might be up to plus or minus 30 seconds out, but it is
|
113 |
+
# the best we can do.
|
114 |
+
utcoffset = int((utcoffset + 30) // 60) * 60
|
115 |
+
dst = int((dst + 30) // 60) * 60
|
116 |
+
transition_info.append(memorized_ttinfo(utcoffset, dst, tzname))
|
117 |
+
|
118 |
+
cls = type(zone, (DstTzInfo,), dict(
|
119 |
+
zone=zone,
|
120 |
+
_utc_transition_times=transitions,
|
121 |
+
_transition_info=transition_info))
|
122 |
+
|
123 |
+
return cls()
|
124 |
+
|
125 |
+
if __name__ == '__main__':
|
126 |
+
import os.path
|
127 |
+
from pprint import pprint
|
128 |
+
base = os.path.join(os.path.dirname(__file__), 'zoneinfo')
|
129 |
+
tz = build_tzinfo('Australia/Melbourne',
|
130 |
+
open(os.path.join(base, 'Australia', 'Melbourne'), 'rb'))
|
131 |
+
tz = build_tzinfo('US/Eastern',
|
132 |
+
open(os.path.join(base, 'US', 'Eastern'), 'rb'))
|
133 |
+
pprint(tz._utc_transition_times)
|
llmeval-env/lib/python3.10/site-packages/pytz/tzinfo.py
ADDED
@@ -0,0 +1,580 @@
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''Base classes and helpers for building zone specific tzinfo classes'''
|
2 |
+
|
3 |
+
from datetime import datetime, timedelta, tzinfo
|
4 |
+
from bisect import bisect_right
|
5 |
+
try:
|
6 |
+
set
|
7 |
+
except NameError:
|
8 |
+
from sets import Set as set
|
9 |
+
|
10 |
+
import pytz
|
11 |
+
from pytz.exceptions import AmbiguousTimeError, NonExistentTimeError
|
12 |
+
|
13 |
+
__all__ = []
|
14 |
+
|
15 |
+
_timedelta_cache = {}
|
16 |
+
|
17 |
+
|
18 |
+
def memorized_timedelta(seconds):
|
19 |
+
'''Create only one instance of each distinct timedelta'''
|
20 |
+
try:
|
21 |
+
return _timedelta_cache[seconds]
|
22 |
+
except KeyError:
|
23 |
+
delta = timedelta(seconds=seconds)
|
24 |
+
_timedelta_cache[seconds] = delta
|
25 |
+
return delta
|
26 |
+
|
27 |
+
|
28 |
+
_epoch = datetime(1970, 1, 1, 0, 0) # datetime.utcfromtimestamp(0)
|
29 |
+
_datetime_cache = {0: _epoch}
|
30 |
+
|
31 |
+
|
32 |
+
def memorized_datetime(seconds):
|
33 |
+
'''Create only one instance of each distinct datetime'''
|
34 |
+
try:
|
35 |
+
return _datetime_cache[seconds]
|
36 |
+
except KeyError:
|
37 |
+
# NB. We can't just do datetime.fromtimestamp(seconds, tz=timezone.utc).replace(tzinfo=None)
|
38 |
+
# as this fails with negative values under Windows (Bug #90096)
|
39 |
+
dt = _epoch + timedelta(seconds=seconds)
|
40 |
+
_datetime_cache[seconds] = dt
|
41 |
+
return dt
|
42 |
+
|
43 |
+
|
44 |
+
_ttinfo_cache = {}
|
45 |
+
|
46 |
+
|
47 |
+
def memorized_ttinfo(*args):
|
48 |
+
'''Create only one instance of each distinct tuple'''
|
49 |
+
try:
|
50 |
+
return _ttinfo_cache[args]
|
51 |
+
except KeyError:
|
52 |
+
ttinfo = (
|
53 |
+
memorized_timedelta(args[0]),
|
54 |
+
memorized_timedelta(args[1]),
|
55 |
+
args[2]
|
56 |
+
)
|
57 |
+
_ttinfo_cache[args] = ttinfo
|
58 |
+
return ttinfo
|
59 |
+
|
60 |
+
|
61 |
+
_notime = memorized_timedelta(0)
|
62 |
+
|
63 |
+
|
64 |
+
def _to_seconds(td):
|
65 |
+
'''Convert a timedelta to seconds'''
|
66 |
+
return td.seconds + td.days * 24 * 60 * 60
|
67 |
+
|
68 |
+
|
69 |
+
class BaseTzInfo(tzinfo):
|
70 |
+
# Overridden in subclass
|
71 |
+
_utcoffset = None
|
72 |
+
_tzname = None
|
73 |
+
zone = None
|
74 |
+
|
75 |
+
def __str__(self):
|
76 |
+
return self.zone
|
77 |
+
|
78 |
+
|
79 |
+
class StaticTzInfo(BaseTzInfo):
|
80 |
+
'''A timezone that has a constant offset from UTC
|
81 |
+
|
82 |
+
These timezones are rare, as most locations have changed their
|
83 |
+
offset at some point in their history
|
84 |
+
'''
|
85 |
+
def fromutc(self, dt):
|
86 |
+
'''See datetime.tzinfo.fromutc'''
|
87 |
+
if dt.tzinfo is not None and dt.tzinfo is not self:
|
88 |
+
raise ValueError('fromutc: dt.tzinfo is not self')
|
89 |
+
return (dt + self._utcoffset).replace(tzinfo=self)
|
90 |
+
|
91 |
+
def utcoffset(self, dt, is_dst=None):
|
92 |
+
'''See datetime.tzinfo.utcoffset
|
93 |
+
|
94 |
+
is_dst is ignored for StaticTzInfo, and exists only to
|
95 |
+
retain compatibility with DstTzInfo.
|
96 |
+
'''
|
97 |
+
return self._utcoffset
|
98 |
+
|
99 |
+
def dst(self, dt, is_dst=None):
|
100 |
+
'''See datetime.tzinfo.dst
|
101 |
+
|
102 |
+
is_dst is ignored for StaticTzInfo, and exists only to
|
103 |
+
retain compatibility with DstTzInfo.
|
104 |
+
'''
|
105 |
+
return _notime
|
106 |
+
|
107 |
+
def tzname(self, dt, is_dst=None):
|
108 |
+
'''See datetime.tzinfo.tzname
|
109 |
+
|
110 |
+
is_dst is ignored for StaticTzInfo, and exists only to
|
111 |
+
retain compatibility with DstTzInfo.
|
112 |
+
'''
|
113 |
+
return self._tzname
|
114 |
+
|
115 |
+
def localize(self, dt, is_dst=False):
|
116 |
+
'''Convert naive time to local time'''
|
117 |
+
if dt.tzinfo is not None:
|
118 |
+
raise ValueError('Not naive datetime (tzinfo is already set)')
|
119 |
+
return dt.replace(tzinfo=self)
|
120 |
+
|
121 |
+
def normalize(self, dt, is_dst=False):
|
122 |
+
'''Correct the timezone information on the given datetime.
|
123 |
+
|
124 |
+
This is normally a no-op, as StaticTzInfo timezones never have
|
125 |
+
ambiguous cases to correct:
|
126 |
+
|
127 |
+
>>> from pytz import timezone
|
128 |
+
>>> gmt = timezone('GMT')
|
129 |
+
>>> isinstance(gmt, StaticTzInfo)
|
130 |
+
True
|
131 |
+
>>> dt = datetime(2011, 5, 8, 1, 2, 3, tzinfo=gmt)
|
132 |
+
>>> gmt.normalize(dt) is dt
|
133 |
+
True
|
134 |
+
|
135 |
+
The supported method of converting between timezones is to use
|
136 |
+
datetime.astimezone(). Currently normalize() also works:
|
137 |
+
|
138 |
+
>>> la = timezone('America/Los_Angeles')
|
139 |
+
>>> dt = la.localize(datetime(2011, 5, 7, 1, 2, 3))
|
140 |
+
>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
|
141 |
+
>>> gmt.normalize(dt).strftime(fmt)
|
142 |
+
'2011-05-07 08:02:03 GMT (+0000)'
|
143 |
+
'''
|
144 |
+
if dt.tzinfo is self:
|
145 |
+
return dt
|
146 |
+
if dt.tzinfo is None:
|
147 |
+
raise ValueError('Naive time - no tzinfo set')
|
148 |
+
return dt.astimezone(self)
|
149 |
+
|
150 |
+
def __repr__(self):
|
151 |
+
return '<StaticTzInfo %r>' % (self.zone,)
|
152 |
+
|
153 |
+
def __reduce__(self):
|
154 |
+
# Special pickle to zone remains a singleton and to cope with
|
155 |
+
# database changes.
|
156 |
+
return pytz._p, (self.zone,)
|
157 |
+
|
158 |
+
|
159 |
+
class DstTzInfo(BaseTzInfo):
|
160 |
+
'''A timezone that has a variable offset from UTC
|
161 |
+
|
162 |
+
The offset might change if daylight saving time comes into effect,
|
163 |
+
or at a point in history when the region decides to change their
|
164 |
+
timezone definition.
|
165 |
+
'''
|
166 |
+
# Overridden in subclass
|
167 |
+
|
168 |
+
# Sorted list of DST transition times, UTC
|
169 |
+
_utc_transition_times = None
|
170 |
+
|
171 |
+
# [(utcoffset, dstoffset, tzname)] corresponding to
|
172 |
+
# _utc_transition_times entries
|
173 |
+
_transition_info = None
|
174 |
+
|
175 |
+
zone = None
|
176 |
+
|
177 |
+
# Set in __init__
|
178 |
+
|
179 |
+
_tzinfos = None
|
180 |
+
_dst = None # DST offset
|
181 |
+
|
182 |
+
def __init__(self, _inf=None, _tzinfos=None):
|
183 |
+
if _inf:
|
184 |
+
self._tzinfos = _tzinfos
|
185 |
+
self._utcoffset, self._dst, self._tzname = _inf
|
186 |
+
else:
|
187 |
+
_tzinfos = {}
|
188 |
+
self._tzinfos = _tzinfos
|
189 |
+
self._utcoffset, self._dst, self._tzname = (
|
190 |
+
self._transition_info[0])
|
191 |
+
_tzinfos[self._transition_info[0]] = self
|
192 |
+
for inf in self._transition_info[1:]:
|
193 |
+
if inf not in _tzinfos:
|
194 |
+
_tzinfos[inf] = self.__class__(inf, _tzinfos)
|
195 |
+
|
196 |
+
def fromutc(self, dt):
|
197 |
+
'''See datetime.tzinfo.fromutc'''
|
198 |
+
if (dt.tzinfo is not None and
|
199 |
+
getattr(dt.tzinfo, '_tzinfos', None) is not self._tzinfos):
|
200 |
+
raise ValueError('fromutc: dt.tzinfo is not self')
|
201 |
+
dt = dt.replace(tzinfo=None)
|
202 |
+
idx = max(0, bisect_right(self._utc_transition_times, dt) - 1)
|
203 |
+
inf = self._transition_info[idx]
|
204 |
+
return (dt + inf[0]).replace(tzinfo=self._tzinfos[inf])
|
205 |
+
|
206 |
+
def normalize(self, dt):
|
207 |
+
'''Correct the timezone information on the given datetime
|
208 |
+
|
209 |
+
If date arithmetic crosses DST boundaries, the tzinfo
|
210 |
+
is not magically adjusted. This method normalizes the
|
211 |
+
tzinfo to the correct one.
|
212 |
+
|
213 |
+
To test, first we need to do some setup
|
214 |
+
|
215 |
+
>>> from pytz import timezone
|
216 |
+
>>> utc = timezone('UTC')
|
217 |
+
>>> eastern = timezone('US/Eastern')
|
218 |
+
>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
|
219 |
+
|
220 |
+
We next create a datetime right on an end-of-DST transition point,
|
221 |
+
the instant when the wallclocks are wound back one hour.
|
222 |
+
|
223 |
+
>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
|
224 |
+
>>> loc_dt = utc_dt.astimezone(eastern)
|
225 |
+
>>> loc_dt.strftime(fmt)
|
226 |
+
'2002-10-27 01:00:00 EST (-0500)'
|
227 |
+
|
228 |
+
Now, if we subtract a few minutes from it, note that the timezone
|
229 |
+
information has not changed.
|
230 |
+
|
231 |
+
>>> before = loc_dt - timedelta(minutes=10)
|
232 |
+
>>> before.strftime(fmt)
|
233 |
+
'2002-10-27 00:50:00 EST (-0500)'
|
234 |
+
|
235 |
+
But we can fix that by calling the normalize method
|
236 |
+
|
237 |
+
>>> before = eastern.normalize(before)
|
238 |
+
>>> before.strftime(fmt)
|
239 |
+
'2002-10-27 01:50:00 EDT (-0400)'
|
240 |
+
|
241 |
+
The supported method of converting between timezones is to use
|
242 |
+
datetime.astimezone(). Currently, normalize() also works:
|
243 |
+
|
244 |
+
>>> th = timezone('Asia/Bangkok')
|
245 |
+
>>> am = timezone('Europe/Amsterdam')
|
246 |
+
>>> dt = th.localize(datetime(2011, 5, 7, 1, 2, 3))
|
247 |
+
>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
|
248 |
+
>>> am.normalize(dt).strftime(fmt)
|
249 |
+
'2011-05-06 20:02:03 CEST (+0200)'
|
250 |
+
'''
|
251 |
+
if dt.tzinfo is None:
|
252 |
+
raise ValueError('Naive time - no tzinfo set')
|
253 |
+
|
254 |
+
# Convert dt in localtime to UTC
|
255 |
+
offset = dt.tzinfo._utcoffset
|
256 |
+
dt = dt.replace(tzinfo=None)
|
257 |
+
dt = dt - offset
|
258 |
+
# convert it back, and return it
|
259 |
+
return self.fromutc(dt)
|
260 |
+
|
261 |
+
def localize(self, dt, is_dst=False):
|
262 |
+
'''Convert naive time to local time.
|
263 |
+
|
264 |
+
This method should be used to construct localtimes, rather
|
265 |
+
than passing a tzinfo argument to a datetime constructor.
|
266 |
+
|
267 |
+
is_dst is used to determine the correct timezone in the ambigous
|
268 |
+
period at the end of daylight saving time.
|
269 |
+
|
270 |
+
>>> from pytz import timezone
|
271 |
+
>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
|
272 |
+
>>> amdam = timezone('Europe/Amsterdam')
|
273 |
+
>>> dt = datetime(2004, 10, 31, 2, 0, 0)
|
274 |
+
>>> loc_dt1 = amdam.localize(dt, is_dst=True)
|
275 |
+
>>> loc_dt2 = amdam.localize(dt, is_dst=False)
|
276 |
+
>>> loc_dt1.strftime(fmt)
|
277 |
+
'2004-10-31 02:00:00 CEST (+0200)'
|
278 |
+
>>> loc_dt2.strftime(fmt)
|
279 |
+
'2004-10-31 02:00:00 CET (+0100)'
|
280 |
+
>>> str(loc_dt2 - loc_dt1)
|
281 |
+
'1:00:00'
|
282 |
+
|
283 |
+
Use is_dst=None to raise an AmbiguousTimeError for ambiguous
|
284 |
+
times at the end of daylight saving time
|
285 |
+
|
286 |
+
>>> try:
|
287 |
+
... loc_dt1 = amdam.localize(dt, is_dst=None)
|
288 |
+
... except AmbiguousTimeError:
|
289 |
+
... print('Ambiguous')
|
290 |
+
Ambiguous
|
291 |
+
|
292 |
+
is_dst defaults to False
|
293 |
+
|
294 |
+
>>> amdam.localize(dt) == amdam.localize(dt, False)
|
295 |
+
True
|
296 |
+
|
297 |
+
is_dst is also used to determine the correct timezone in the
|
298 |
+
wallclock times jumped over at the start of daylight saving time.
|
299 |
+
|
300 |
+
>>> pacific = timezone('US/Pacific')
|
301 |
+
>>> dt = datetime(2008, 3, 9, 2, 0, 0)
|
302 |
+
>>> ploc_dt1 = pacific.localize(dt, is_dst=True)
|
303 |
+
>>> ploc_dt2 = pacific.localize(dt, is_dst=False)
|
304 |
+
>>> ploc_dt1.strftime(fmt)
|
305 |
+
'2008-03-09 02:00:00 PDT (-0700)'
|
306 |
+
>>> ploc_dt2.strftime(fmt)
|
307 |
+
'2008-03-09 02:00:00 PST (-0800)'
|
308 |
+
>>> str(ploc_dt2 - ploc_dt1)
|
309 |
+
'1:00:00'
|
310 |
+
|
311 |
+
Use is_dst=None to raise a NonExistentTimeError for these skipped
|
312 |
+
times.
|
313 |
+
|
314 |
+
>>> try:
|
315 |
+
... loc_dt1 = pacific.localize(dt, is_dst=None)
|
316 |
+
... except NonExistentTimeError:
|
317 |
+
... print('Non-existent')
|
318 |
+
Non-existent
|
319 |
+
'''
|
320 |
+
if dt.tzinfo is not None:
|
321 |
+
raise ValueError('Not naive datetime (tzinfo is already set)')
|
322 |
+
|
323 |
+
# Find the two best possibilities.
|
324 |
+
possible_loc_dt = set()
|
325 |
+
for delta in [timedelta(days=-1), timedelta(days=1)]:
|
326 |
+
loc_dt = dt + delta
|
327 |
+
idx = max(0, bisect_right(
|
328 |
+
self._utc_transition_times, loc_dt) - 1)
|
329 |
+
inf = self._transition_info[idx]
|
330 |
+
tzinfo = self._tzinfos[inf]
|
331 |
+
loc_dt = tzinfo.normalize(dt.replace(tzinfo=tzinfo))
|
332 |
+
if loc_dt.replace(tzinfo=None) == dt:
|
333 |
+
possible_loc_dt.add(loc_dt)
|
334 |
+
|
335 |
+
if len(possible_loc_dt) == 1:
|
336 |
+
return possible_loc_dt.pop()
|
337 |
+
|
338 |
+
# If there are no possibly correct timezones, we are attempting
|
339 |
+
# to convert a time that never happened - the time period jumped
|
340 |
+
# during the start-of-DST transition period.
|
341 |
+
if len(possible_loc_dt) == 0:
|
342 |
+
# If we refuse to guess, raise an exception.
|
343 |
+
if is_dst is None:
|
344 |
+
raise NonExistentTimeError(dt)
|
345 |
+
|
346 |
+
# If we are forcing the pre-DST side of the DST transition, we
|
347 |
+
# obtain the correct timezone by winding the clock forward a few
|
348 |
+
# hours.
|
349 |
+
elif is_dst:
|
350 |
+
return self.localize(
|
351 |
+
dt + timedelta(hours=6), is_dst=True) - timedelta(hours=6)
|
352 |
+
|
353 |
+
# If we are forcing the post-DST side of the DST transition, we
|
354 |
+
# obtain the correct timezone by winding the clock back.
|
355 |
+
else:
|
356 |
+
return self.localize(
|
357 |
+
dt - timedelta(hours=6),
|
358 |
+
is_dst=False) + timedelta(hours=6)
|
359 |
+
|
360 |
+
# If we get this far, we have multiple possible timezones - this
|
361 |
+
# is an ambiguous case occurring during the end-of-DST transition.
|
362 |
+
|
363 |
+
# If told to be strict, raise an exception since we have an
|
364 |
+
# ambiguous case
|
365 |
+
if is_dst is None:
|
366 |
+
raise AmbiguousTimeError(dt)
|
367 |
+
|
368 |
+
# Filter out the possiblilities that don't match the requested
|
369 |
+
# is_dst
|
370 |
+
filtered_possible_loc_dt = [
|
371 |
+
p for p in possible_loc_dt if bool(p.tzinfo._dst) == is_dst
|
372 |
+
]
|
373 |
+
|
374 |
+
# Hopefully we only have one possibility left. Return it.
|
375 |
+
if len(filtered_possible_loc_dt) == 1:
|
376 |
+
return filtered_possible_loc_dt[0]
|
377 |
+
|
378 |
+
if len(filtered_possible_loc_dt) == 0:
|
379 |
+
filtered_possible_loc_dt = list(possible_loc_dt)
|
380 |
+
|
381 |
+
# If we get this far, we have in a wierd timezone transition
|
382 |
+
# where the clocks have been wound back but is_dst is the same
|
383 |
+
# in both (eg. Europe/Warsaw 1915 when they switched to CET).
|
384 |
+
# At this point, we just have to guess unless we allow more
|
385 |
+
# hints to be passed in (such as the UTC offset or abbreviation),
|
386 |
+
# but that is just getting silly.
|
387 |
+
#
|
388 |
+
# Choose the earliest (by UTC) applicable timezone if is_dst=True
|
389 |
+
# Choose the latest (by UTC) applicable timezone if is_dst=False
|
390 |
+
# i.e., behave like end-of-DST transition
|
391 |
+
dates = {} # utc -> local
|
392 |
+
for local_dt in filtered_possible_loc_dt:
|
393 |
+
utc_time = (
|
394 |
+
local_dt.replace(tzinfo=None) - local_dt.tzinfo._utcoffset)
|
395 |
+
assert utc_time not in dates
|
396 |
+
dates[utc_time] = local_dt
|
397 |
+
return dates[[min, max][not is_dst](dates)]
|
398 |
+
|
399 |
+
def utcoffset(self, dt, is_dst=None):
|
400 |
+
'''See datetime.tzinfo.utcoffset
|
401 |
+
|
402 |
+
The is_dst parameter may be used to remove ambiguity during DST
|
403 |
+
transitions.
|
404 |
+
|
405 |
+
>>> from pytz import timezone
|
406 |
+
>>> tz = timezone('America/St_Johns')
|
407 |
+
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
408 |
+
|
409 |
+
>>> str(tz.utcoffset(ambiguous, is_dst=False))
|
410 |
+
'-1 day, 20:30:00'
|
411 |
+
|
412 |
+
>>> str(tz.utcoffset(ambiguous, is_dst=True))
|
413 |
+
'-1 day, 21:30:00'
|
414 |
+
|
415 |
+
>>> try:
|
416 |
+
... tz.utcoffset(ambiguous)
|
417 |
+
... except AmbiguousTimeError:
|
418 |
+
... print('Ambiguous')
|
419 |
+
Ambiguous
|
420 |
+
|
421 |
+
'''
|
422 |
+
if dt is None:
|
423 |
+
return None
|
424 |
+
elif dt.tzinfo is not self:
|
425 |
+
dt = self.localize(dt, is_dst)
|
426 |
+
return dt.tzinfo._utcoffset
|
427 |
+
else:
|
428 |
+
return self._utcoffset
|
429 |
+
|
430 |
+
def dst(self, dt, is_dst=None):
|
431 |
+
'''See datetime.tzinfo.dst
|
432 |
+
|
433 |
+
The is_dst parameter may be used to remove ambiguity during DST
|
434 |
+
transitions.
|
435 |
+
|
436 |
+
>>> from pytz import timezone
|
437 |
+
>>> tz = timezone('America/St_Johns')
|
438 |
+
|
439 |
+
>>> normal = datetime(2009, 9, 1)
|
440 |
+
|
441 |
+
>>> str(tz.dst(normal))
|
442 |
+
'1:00:00'
|
443 |
+
>>> str(tz.dst(normal, is_dst=False))
|
444 |
+
'1:00:00'
|
445 |
+
>>> str(tz.dst(normal, is_dst=True))
|
446 |
+
'1:00:00'
|
447 |
+
|
448 |
+
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
449 |
+
|
450 |
+
>>> str(tz.dst(ambiguous, is_dst=False))
|
451 |
+
'0:00:00'
|
452 |
+
>>> str(tz.dst(ambiguous, is_dst=True))
|
453 |
+
'1:00:00'
|
454 |
+
>>> try:
|
455 |
+
... tz.dst(ambiguous)
|
456 |
+
... except AmbiguousTimeError:
|
457 |
+
... print('Ambiguous')
|
458 |
+
Ambiguous
|
459 |
+
|
460 |
+
'''
|
461 |
+
if dt is None:
|
462 |
+
return None
|
463 |
+
elif dt.tzinfo is not self:
|
464 |
+
dt = self.localize(dt, is_dst)
|
465 |
+
return dt.tzinfo._dst
|
466 |
+
else:
|
467 |
+
return self._dst
|
468 |
+
|
469 |
+
def tzname(self, dt, is_dst=None):
|
470 |
+
'''See datetime.tzinfo.tzname
|
471 |
+
|
472 |
+
The is_dst parameter may be used to remove ambiguity during DST
|
473 |
+
transitions.
|
474 |
+
|
475 |
+
>>> from pytz import timezone
|
476 |
+
>>> tz = timezone('America/St_Johns')
|
477 |
+
|
478 |
+
>>> normal = datetime(2009, 9, 1)
|
479 |
+
|
480 |
+
>>> tz.tzname(normal)
|
481 |
+
'NDT'
|
482 |
+
>>> tz.tzname(normal, is_dst=False)
|
483 |
+
'NDT'
|
484 |
+
>>> tz.tzname(normal, is_dst=True)
|
485 |
+
'NDT'
|
486 |
+
|
487 |
+
>>> ambiguous = datetime(2009, 10, 31, 23, 30)
|
488 |
+
|
489 |
+
>>> tz.tzname(ambiguous, is_dst=False)
|
490 |
+
'NST'
|
491 |
+
>>> tz.tzname(ambiguous, is_dst=True)
|
492 |
+
'NDT'
|
493 |
+
>>> try:
|
494 |
+
... tz.tzname(ambiguous)
|
495 |
+
... except AmbiguousTimeError:
|
496 |
+
... print('Ambiguous')
|
497 |
+
Ambiguous
|
498 |
+
'''
|
499 |
+
if dt is None:
|
500 |
+
return self.zone
|
501 |
+
elif dt.tzinfo is not self:
|
502 |
+
dt = self.localize(dt, is_dst)
|
503 |
+
return dt.tzinfo._tzname
|
504 |
+
else:
|
505 |
+
return self._tzname
|
506 |
+
|
507 |
+
def __repr__(self):
|
508 |
+
if self._dst:
|
509 |
+
dst = 'DST'
|
510 |
+
else:
|
511 |
+
dst = 'STD'
|
512 |
+
if self._utcoffset > _notime:
|
513 |
+
return '<DstTzInfo %r %s+%s %s>' % (
|
514 |
+
self.zone, self._tzname, self._utcoffset, dst
|
515 |
+
)
|
516 |
+
else:
|
517 |
+
return '<DstTzInfo %r %s%s %s>' % (
|
518 |
+
self.zone, self._tzname, self._utcoffset, dst
|
519 |
+
)
|
520 |
+
|
521 |
+
def __reduce__(self):
|
522 |
+
# Special pickle to zone remains a singleton and to cope with
|
523 |
+
# database changes.
|
524 |
+
return pytz._p, (
|
525 |
+
self.zone,
|
526 |
+
_to_seconds(self._utcoffset),
|
527 |
+
_to_seconds(self._dst),
|
528 |
+
self._tzname
|
529 |
+
)
|
530 |
+
|
531 |
+
|
532 |
+
def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
|
533 |
+
"""Factory function for unpickling pytz tzinfo instances.
|
534 |
+
|
535 |
+
This is shared for both StaticTzInfo and DstTzInfo instances, because
|
536 |
+
database changes could cause a zones implementation to switch between
|
537 |
+
these two base classes and we can't break pickles on a pytz version
|
538 |
+
upgrade.
|
539 |
+
"""
|
540 |
+
# Raises a KeyError if zone no longer exists, which should never happen
|
541 |
+
# and would be a bug.
|
542 |
+
tz = pytz.timezone(zone)
|
543 |
+
|
544 |
+
# A StaticTzInfo - just return it
|
545 |
+
if utcoffset is None:
|
546 |
+
return tz
|
547 |
+
|
548 |
+
# This pickle was created from a DstTzInfo. We need to
|
549 |
+
# determine which of the list of tzinfo instances for this zone
|
550 |
+
# to use in order to restore the state of any datetime instances using
|
551 |
+
# it correctly.
|
552 |
+
utcoffset = memorized_timedelta(utcoffset)
|
553 |
+
dstoffset = memorized_timedelta(dstoffset)
|
554 |
+
try:
|
555 |
+
return tz._tzinfos[(utcoffset, dstoffset, tzname)]
|
556 |
+
except KeyError:
|
557 |
+
# The particular state requested in this timezone no longer exists.
|
558 |
+
# This indicates a corrupt pickle, or the timezone database has been
|
559 |
+
# corrected violently enough to make this particular
|
560 |
+
# (utcoffset,dstoffset) no longer exist in the zone, or the
|
561 |
+
# abbreviation has been changed.
|
562 |
+
pass
|
563 |
+
|
564 |
+
# See if we can find an entry differing only by tzname. Abbreviations
|
565 |
+
# get changed from the initial guess by the database maintainers to
|
566 |
+
# match reality when this information is discovered.
|
567 |
+
for localized_tz in tz._tzinfos.values():
|
568 |
+
if (localized_tz._utcoffset == utcoffset and
|
569 |
+
localized_tz._dst == dstoffset):
|
570 |
+
return localized_tz
|
571 |
+
|
572 |
+
# This (utcoffset, dstoffset) information has been removed from the
|
573 |
+
# zone. Add it back. This might occur when the database maintainers have
|
574 |
+
# corrected incorrect information. datetime instances using this
|
575 |
+
# incorrect information will continue to do so, exactly as they were
|
576 |
+
# before being pickled. This is purely an overly paranoid safety net - I
|
577 |
+
# doubt this will ever been needed in real life.
|
578 |
+
inf = (utcoffset, dstoffset, tzname)
|
579 |
+
tz._tzinfos[inf] = tz.__class__(inf, tz._tzinfos)
|
580 |
+
return tz._tzinfos[inf]
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/CST6CDT
ADDED
Binary file (2.31 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Cuba
ADDED
Binary file (2.42 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/EET
ADDED
Binary file (1.91 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/EST
ADDED
Binary file (114 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Egypt
ADDED
Binary file (2.4 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Factory
ADDED
Binary file (116 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GB
ADDED
Binary file (3.66 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GB-Eire
ADDED
Binary file (3.66 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GMT
ADDED
Binary file (114 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/GMT0
ADDED
Binary file (114 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/HST
ADDED
Binary file (115 Bytes). View file
|
|
llmeval-env/lib/python3.10/site-packages/pytz/zoneinfo/Hongkong
ADDED
Binary file (1.23 kB). View file
|
|