mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-01-21 02:13:01 -08:00
a528f052b9
* Bump cherrypy from 18.9.0 to 18.10.0 Bumps [cherrypy](https://github.com/cherrypy/cherrypy) from 18.9.0 to 18.10.0. - [Changelog](https://github.com/cherrypy/cherrypy/blob/main/CHANGES.rst) - [Commits](https://github.com/cherrypy/cherrypy/compare/v18.9.0...v18.10.0) --- updated-dependencies: - dependency-name: cherrypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update cherrypy==18.10.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
47 lines
1012 B
Python
47 lines
1012 B
Python
"""
|
|
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
|
|
|
|
Now should be affected by freezegun.
|
|
|
|
>>> freezer = getfixture('freezer')
|
|
>>> freezer.move_to('1999-12-31 17:00:00 -0700')
|
|
>>> print(now())
|
|
2000-01-01 00:00:00+00:00
|
|
"""
|
|
|
|
import datetime as std
|
|
import functools
|
|
|
|
|
|
__all__ = ['now', 'fromtimestamp', 'datetime', 'time']
|
|
|
|
|
|
def now():
|
|
return 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)
|