14
0
forked from pool/python-Babel
Files
python-Babel/reproducible.patch
Markéta Machová d504784754 Accepting request 1295211 from home:bmwiedemann:reproducible:test
Add reproducible.patch to normalize date in .po (boo#1047218)

not sure how easy it is to get upstream.
There is some poor interaction of this variable with freeze_gun tests.

OBS-URL: https://build.opensuse.org/request/show/1295211
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Babel?expand=0&rev=91
2025-07-26 05:15:02 +00:00

25 lines
902 B
Diff

diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py
index f84a5bd..786d1a4 100644
--- a/babel/messages/catalog.py
+++ b/babel/messages/catalog.py
@@ -11,6 +11,8 @@ from __future__ import annotations
import datetime
import re
+import time
+import os
from collections.abc import Iterable, Iterator
from copy import copy
from difflib import SequenceMatcher
@@ -385,7 +387,9 @@ class Catalog:
self.charset = charset or 'utf-8'
if creation_date is None:
- creation_date = datetime.datetime.now(LOCALTZ)
+ creation_date = datetime.datetime.utcfromtimestamp(
+ int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
+ )
elif isinstance(creation_date, datetime.datetime) and not creation_date.tzinfo:
creation_date = creation_date.replace(tzinfo=LOCALTZ)
self.creation_date = creation_date