python datetime .. grrr
Larry Doolittle
larry at doolittle.boa.org
Sat Feb 11 19:52:46 UTC 2023
Friends -
verilator 5.006-2 in Debian is not reproducible
https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/verilator.html
and I finally figured out why. It's timezone handling in python3 datetime.
$ cat verilator_doc.py
# Distilled from upstream verilator docs/guide/conf.py
# (post-commit 87a7881d46)
from datetime import datetime
import os
try:
# https://reproducible-builds.org/specs/source-date-epoch/
doc_now = datetime.fromtimestamp(int(os.environ["SOURCE_DATE_EPOCH"]))
print("Using SOURCE_DATE_EPOCH")
except Exception:
doc_now = datetime.now()
# Date format to ISO
today_fmt = doc_now.strftime("%F")
print(today_fmt)
$ cat repro
export SOURCE_DATE_EPOCH=$(date -d "07 Feb 2023 17:17:27 +0100" +%s)
echo $SOURCE_DATE_EPOCH
# https://tests.reproducible-builds.org/debian/index_variations.html
TZ="/usr/share/zoneinfo/Etc/GMT+12" python3 verilator_doc.py
TZ="/usr/share/zoneinfo/Etc/GMT-14" python3 verilator_doc.py
$ sh repro
1675786647
Using SOURCE_DATE_EPOCH
2023-02-07
Using SOURCE_DATE_EPOCH
2023-02-08
I've spent more than an hour RTFM and trying different ways to get
python3 datetime to ignore the local timezone when computing dates.
No joy. Surely someone here has learned how to that?
I even perused the known-issue notes at
https://tests.reproducible-builds.org/debian/index_issues.html
A related issue -- but not involving python -- shows up as Debian bug 780259.
- Larry
More information about the rb-general
mailing list