Skip to content

Commit 64a4246

Browse files
Update dates.tex
1 parent 0357fd0 commit 64a4246

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎tex/prose/dates.tex‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ \subsection{Time Zone Handling}
2525

2626
Matplotlib's date converters, locators, and formatters are time-zone aware. If no time zone is specified, Matplotlib uses \code{rcParams['timezone']}, which is \code{'UTC'} by default. You can choose the time zone used for tick labels by passing an IANA time-zone name to a formatter, as in \code{mdates.DateFormatter('\%H:\%M \%Z', tz = 'America/New\_York')}. The underlying observations do not move; only their displayed clock times change.
2727

28-
It is important to distinguish conversion from localization. A time-zone-aware timestamp identifies an unambiguous instant and can be converted for different audiences. A naive timestamp has no such information. With pandas, \code{tz\_localize()} attaches a time zone to naive dates, while \code{tz\_convert()} converts dates that are already time-zone aware. Localize only when you know which time zone the recorded clock times represent. Otherwise, the same numbers can be assigned to the wrong instant.
28+
It is important to distinguish conversion from localization. A time-zone-aware timestamp identifies an unambiguous instant and can be converted for different audiences while a naive timestamp contains no such information. With pandas, \code{tz\_localize()} attaches a time zone to naive dates, while \code{tz\_convert()} converts dates that are already time-zone aware. Localize only when you know which time zone the recorded clock times represent. Otherwise, the same numbers can be assigned to the wrong instant.
2929

30-
Named zones are preferable to fixed offsets because their rules account for daylight-saving transitions. Python's standard-library \link{https://docs.python.org/3/library/zoneinfo.html}{\code{zoneinfo}} module supplies \code{tzinfo} objects for these zones. For plotting, a zone name or \code{tzinfo} object can be passed to Matplotlib's \link{https://matplotlib.org/stable/api/dates_api.html}{date locators and formatters}. The practical rule is simple: store an unambiguous time, commonly in UTC, and convert it only when choosing how the audience should read the axis.
30+
Named zones are better than fixed offsets because their rules account for daylight-saving transitions. Python's standard-library \link{https://docs.python.org/3/library/zoneinfo.html}{\code{zoneinfo}} module supplies \code{tzinfo} objects for these zones. For plotting, a zone name or \code{tzinfo} object can be passed to Matplotlib's \link{https://matplotlib.org/stable/api/dates_api.html}{date locators and formatters}. Best practice is to store an unambiguous time, commonly in UTC, and convert it only when choosing how the audience should read the axis.
3131

3232
\section{Ticks and Formatting}
3333

0 commit comments

Comments
 (0)