Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d10a21e

Browse files
author
Alexis Bienvenüe
committed
Use explicit date formatting for PS backend timestamp, instead of asctime
1 parent 5b405cc commit d10a21e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/matplotlib/backends/backend_ps.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import six
99
from six.moves import StringIO
1010

11-
import glob, math, os, shutil, sys, time
11+
import glob, math, os, shutil, sys, time, datetime
1212
def _fn_name(): return sys._getframe(1).f_code.co_name
1313
import io
1414

@@ -1091,7 +1091,8 @@ def print_figure_impl():
10911091
# See https://reproducible-builds.org/specs/source-date-epoch/
10921092
source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
10931093
if source_date_epoch:
1094-
source_date = time.asctime(time.gmtime(int(source_date_epoch)))
1094+
source_date = datetime.datetime.utcfromtimestamp(
1095+
int(source_date_epoch) ).strftime("%a %b %e %T %Y")
10951096
else:
10961097
source_date = time.ctime()
10971098
print("%%CreationDate: "+source_date, file=fh)
@@ -1281,7 +1282,8 @@ def write(self, *kl, **kwargs):
12811282
# See https://reproducible-builds.org/specs/source-date-epoch/
12821283
source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
12831284
if source_date_epoch:
1284-
source_date = time.asctime(time.gmtime(int(source_date_epoch)))
1285+
source_date = datetime.datetime.utcfromtimestamp(
1286+
int(source_date_epoch) ).strftime("%a %b %e %T %Y")
12851287
else:
12861288
source_date = time.ctime()
12871289
print("%%CreationDate: "+source_date, file=fh)

0 commit comments

Comments
 (0)