MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / memorized_datetime

Function memorized_datetime

tests/test_code/py/pytz/tzinfo.py:31–40  ·  view source on GitHub ↗

Create only one instance of each distinct datetime

(seconds)

Source from the content-addressed store, hash-verified

29
30
31def memorized_datetime(seconds):
32 '''Create only one instance of each distinct datetime'''
33 try:
34 return _datetime_cache[seconds]
35 except KeyError:
36 # NB. We can't just do datetime.utcfromtimestamp(seconds) as this
37 # fails with negative values under Windows (Bug #90096)
38 dt = _epoch + timedelta(seconds=seconds)
39 _datetime_cache[seconds] = dt
40 return dt
41
42_ttinfo_cache = {}
43

Callers 1

build_tzinfoFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected