File tree Expand file tree Collapse file tree 5 files changed +10
-7
lines changed
api/prev_api_changes/api_changes_3.7.0 Expand file tree Collapse file tree 5 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 77These methods convert from unix timestamps to matplotlib floats, but are not
88used internally to Matplotlib, and should not be needed by end users. To
99convert a unix timestamp to datetime, simply use
10- `datetime.datetime.utcfromtimestamp `, or to use NumPy `~numpy.datetime64 `
10+ `datetime.datetime.fromtimestamp `, or to use NumPy `~numpy.datetime64 `
1111``dt = np.datetime64(e*1e6, 'us') ``.
1212
1313Locator and Formatter wrapper methods
Original file line number Diff line number Diff line change 2222
2323import matplotlib
2424
25+ from datetime import timezone
2526from datetime import datetime
2627import time
2728
3637
3738# Parse year using SOURCE_DATE_EPOCH, falling back to current time.
3839# https://reproducible-builds.org/specs/source-date-epoch/
39- sourceyear = datetime .utcfromtimestamp (
40- int (os .environ .get ('SOURCE_DATE_EPOCH' , time .time ()))).year
40+ sourceyear = datetime .fromtimestamp (
41+ int (os .environ .get ('SOURCE_DATE_EPOCH' , time .time ())), timezone . utc ).year
4142
4243# If your extensions are in another directory, add it here. If the directory
4344# is relative to the documentation root, use os.path.abspath to make it
Original file line number Diff line number Diff line change 55"""
66
77import codecs
8+ from datetime import timezone
89from datetime import datetime
910from enum import Enum
1011from functools import total_ordering
@@ -153,7 +154,7 @@ def _create_pdf_info_dict(backend, metadata):
153154 # See https://reproducible-builds.org/specs/source-date-epoch/
154155 source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
155156 if source_date_epoch :
156- source_date = datetime .utcfromtimestamp (int (source_date_epoch ))
157+ source_date = datetime .fromtimestamp (int (source_date_epoch ), timezone . utc )
157158 source_date = source_date .replace (tzinfo = UTC )
158159 else :
159160 source_date = datetime .today ()
Original file line number Diff line number Diff line change @@ -841,8 +841,9 @@ def _print_ps(
841841 # See https://reproducible-builds.org/specs/source-date-epoch/
842842 source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
843843 dsc_comments ["CreationDate" ] = (
844- datetime .datetime .utcfromtimestamp (
845- int (source_date_epoch )).strftime ("%a %b %d %H:%M:%S %Y" )
844+ datetime .datetime .fromtimestamp (
845+ int (source_date_epoch ),
846+ datetime .timezone .utc ).strftime ("%a %b %d %H:%M:%S %Y" )
846847 if source_date_epoch
847848 else time .ctime ())
848849 dsc_comments = "\n " .join (
Original file line number Diff line number Diff line change @@ -410,7 +410,7 @@ def _write_metadata(self, metadata):
410410 # See https://reproducible-builds.org/specs/source-date-epoch/
411411 date = os .getenv ("SOURCE_DATE_EPOCH" )
412412 if date :
413- date = datetime .datetime .utcfromtimestamp (int (date ))
413+ date = datetime .datetime .fromtimestamp (int (date ), datetime . timezone . utc )
414414 metadata ['Date' ] = date .replace (tzinfo = UTC ).isoformat ()
415415 else :
416416 metadata ['Date' ] = datetime .datetime .today ().isoformat ()
You can’t perform that action at this time.
0 commit comments