mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 15:32:38 -07:00
Add tempora-1.14.1
This commit is contained in:
parent
ceeeea94ba
commit
bc81f19715
5 changed files with 1123 additions and 0 deletions
39
lib/tempora/utc.py
Normal file
39
lib/tempora/utc.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
"""
|
||||
Facilities for common time operations in UTC.
|
||||
|
||||
Inspired by the `utc project <https://pypi.org/project/utc>`_.
|
||||
|
||||
>>> dt = now()
|
||||
>>> dt == fromtimestamp(dt.timestamp())
|
||||
True
|
||||
>>> dt.tzinfo
|
||||
datetime.timezone.utc
|
||||
|
||||
>>> from time import time as timestamp
|
||||
>>> now().timestamp() - timestamp() < 0.1
|
||||
True
|
||||
|
||||
>>> (now() - fromtimestamp(timestamp())).total_seconds() < 0.1
|
||||
True
|
||||
|
||||
>>> datetime(2018, 6, 26, 0).tzinfo
|
||||
datetime.timezone.utc
|
||||
|
||||
>>> time(0, 0).tzinfo
|
||||
datetime.timezone.utc
|
||||
"""
|
||||
|
||||
import datetime as std
|
||||
import functools
|
||||
|
||||
|
||||
__all__ = ['now', 'fromtimestamp', 'datetime', 'time']
|
||||
|
||||
|
||||
now = functools.partial(std.datetime.now, std.timezone.utc)
|
||||
fromtimestamp = functools.partial(
|
||||
std.datetime.fromtimestamp,
|
||||
tz=std.timezone.utc,
|
||||
)
|
||||
datetime = functools.partial(std.datetime, tzinfo=std.timezone.utc)
|
||||
time = functools.partial(std.time, tzinfo=std.timezone.utc)
|
Loading…
Add table
Add a link
Reference in a new issue