File: timeutils.rst

package info (click to toggle)
python-boltons 21.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,280 kB
  • sloc: python: 12,144; makefile: 159; sh: 7
file content (51 lines) | stat: -rw-r--r-- 1,604 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
``timeutils`` - ``datetime`` additions
======================================

.. automodule:: boltons.timeutils

.. autofunction:: daterange
.. autofunction:: isoparse
.. autofunction:: parse_timedelta
.. autofunction:: strpdate
.. autofunction:: total_seconds
.. autofunction:: dt_to_timestamp

.. autofunction:: relative_time
.. autofunction:: decimal_relative_time

General timezones
-----------------

By default, :class:`datetime.datetime` objects are "naïve", meaning
they lack attached timezone information. These objects can be useful
for many operations, but many operations require timezone-aware
datetimes.

The two most important timezones in programming are Coordinated
Universal Time (`UTC`_) and the local timezone of the host running
your code. Boltons provides two :class:`datetime.tzinfo` subtypes for
working with them:

.. _UTC: https://en.wikipedia.org/wiki/Coordinated_Universal_Time

.. autoattribute:: boltons.timeutils.UTC
.. autodata:: boltons.timeutils.LocalTZ

.. autoclass:: boltons.timeutils.ConstantTZInfo

US timezones
------------

These four US timezones were implemented in the :mod:`datetime`
documentation and have been reproduced here in boltons for
convenience. More in-depth support is provided by `dateutil`_ and `pytz`_.

.. _dateutil: https://dateutil.readthedocs.io/en/stable/index.html
.. _pytz: https://pypi.python.org/pypi/pytz

.. autoattribute:: boltons.timeutils.Eastern
.. autoattribute:: boltons.timeutils.Central
.. autoattribute:: boltons.timeutils.Mountain
.. autoattribute:: boltons.timeutils.Pacific

.. autoclass:: boltons.timeutils.USTimeZone