Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added paragraph about wall time and absolute time #1308

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/relativedelta.rst
Expand Up @@ -218,3 +218,19 @@ We can use the non-leap year day to ignore this:

>>> date(2000, 1, 1)+relativedelta(nlyearday=260)
datetime.date(2000, 9, 17)

Remember: relativedelta.relativedelta provides the calendar time delta, Wall Time, not Absolute Time.
Wall Time is the time on the clock: adding or subrtracting time changes time on a specified number of minutes, hours,
days, weeks, etc. Absolute Time counts switching of time regions, change of the winter time to summer time, etc.
Example around 03/11/2023, day of the switch to summer time:

.. doctest:: relativedelta

>>> winter_time = datetime(2023, 3, 11, 2, 55, 0, tzinfo=tz.gettz('America/Los_Angeles'))
2023-03-11 02:55:00-08:00
>>> summer_time = winter_time + relativedelta.relativedelta(days=1)
2023-03-12 02:55:00-07:00
>>> (summer_time - winter_time).days * 24.0
24.0
>>> (summer_time.timestamp() - winter_time.timestamp())/3600
23.0