Skip to content

Commit

Permalink
Added paragraph about wall time and absolute time
Browse files Browse the repository at this point in the history
  • Loading branch information
hau887 committed Sep 25, 2023
1 parent 296d419 commit 60c9139
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/relativedelta.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,22 @@ 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
>>> 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
>>> summer_time = winter_time + relativedelta.relativedelta(days=1)
2023-03-12 02:55:00-07:00
# wall time (in hours)
>>> (summer_time - winter_time).days * 24.0
24.0
# absolute time (converting to UTC timestamp)
>>> (summer_time.timestamp() - winter_time.timestamp())/3600
23.0

0 comments on commit 60c9139

Please sign in to comment.