Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe81985

Browse files
Merge pull request matplotlib#25972 from meeseeksmachine/auto-backport-of-pr-25918-on-v3.7.x
Backport PR matplotlib#25918 on branch v3.7.x (migrate from utcfromtimestamp to fromtimestamp)
2 parents 48891e5 + a4e00c7 commit fe81985

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Removals
77
These methods convert from unix timestamps to matplotlib floats, but are not
88
used internally to Matplotlib, and should not be needed by end users. To
99
convert 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

1313
Locator and Formatter wrapper methods

‎doc/conf.py‎

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

2323
import matplotlib
2424

25+
from datetime import timezone
2526
from datetime import datetime
2627
import time
2728

@@ -36,8 +37,8 @@
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

‎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
@@ -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()

‎lib/matplotlib/backends/backend_ps.py‎

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

‎lib/matplotlib/backends/backend_svg.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /