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 2323
2424import matplotlib
2525
26+ from datetime import timezone
2627from datetime import datetime
2728import time
2829
@@ -73,8 +74,8 @@ def _parse_skip_subdirs_file():
7374
7475# Parse year using SOURCE_DATE_EPOCH, falling back to current time.
7576# https://reproducible-builds.org/specs/source-date-epoch/
76- sourceyear = datetime .utcfromtimestamp (
77- int (os .environ .get ('SOURCE_DATE_EPOCH' , time .time ()))).year
77+ sourceyear = datetime .fromtimestamp (
78+ int (os .environ .get ('SOURCE_DATE_EPOCH' , time .time ())), timezone . utc ).year
7879
7980# If your extensions are in another directory, add it here. If the directory
8081# 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
@@ -148,7 +149,7 @@ def _create_pdf_info_dict(backend, metadata):
148149 # See https://reproducible-builds.org/specs/source-date-epoch/
149150 source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
150151 if source_date_epoch :
151- source_date = datetime .utcfromtimestamp (int (source_date_epoch ))
152+ source_date = datetime .fromtimestamp (int (source_date_epoch ), timezone . utc )
152153 source_date = source_date .replace (tzinfo = UTC )
153154 else :
154155 source_date = datetime .today ()
Original file line number Diff line number Diff line change @@ -826,8 +826,9 @@ def _print_ps(
826826 # See https://reproducible-builds.org/specs/source-date-epoch/
827827 source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
828828 dsc_comments ["CreationDate" ] = (
829- datetime .datetime .utcfromtimestamp (
830- int (source_date_epoch )).strftime ("%a %b %d %H:%M:%S %Y" )
829+ datetime .datetime .fromtimestamp (
830+ int (source_date_epoch ),
831+ datetime .timezone .utc ).strftime ("%a %b %d %H:%M:%S %Y" )
831832 if source_date_epoch
832833 else time .ctime ())
833834 dsc_comments = "\n " .join (
Original file line number Diff line number Diff line change @@ -380,7 +380,7 @@ def _write_metadata(self, metadata):
380380 # See https://reproducible-builds.org/specs/source-date-epoch/
381381 date = os .getenv ("SOURCE_DATE_EPOCH" )
382382 if date :
383- date = datetime .datetime .utcfromtimestamp (int (date ))
383+ date = datetime .datetime .fromtimestamp (int (date ), datetime . timezone . utc )
384384 metadata ['Date' ] = date .replace (tzinfo = UTC ).isoformat ()
385385 else :
386386 metadata ['Date' ] = datetime .datetime .today ().isoformat ()
You can’t perform that action at this time.
0 commit comments