migrate from utcfromtimestamp to fromtimestamp (#25918) · matplotlib/matplotlib@6df1bb3 · GitHub
Skip to content

Commit 6df1bb3

Browse files
authored
migrate from utcfromtimestamp to fromtimestamp (#25918)
closes #25912
1 parent 8293774 commit 6df1bb3

5 files changed

Lines changed: 10 additions & 7 deletions

File tree

doc/api/prev_api_changes/api_changes_3.7.0/removals.rst

Lines changed: 1 addition & 1 deletion

doc/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import matplotlib
2525

26+
from datetime import timezone
2627
from datetime import datetime
2728
import 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

lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import codecs
8+
from datetime import timezone
89
from datetime import datetime
910
from enum import Enum
1011
from 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()

lib/matplotlib/backends/backend_ps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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(

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)