File: tzdata

package info (click to toggle)
python-tz 2025.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,396 kB
  • sloc: ansic: 7,826; python: 2,414; awk: 1,067; makefile: 921; sh: 693
file content (68 lines) | stat: -rw-r--r-- 2,755 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Description: Use system zone information from the tzdata package
Author: Kurt Roeckx <kurt@roeckx.be>
Author: Hilko Bengen <bengen@debian.org>
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416202
Forwarded: not-needed
Last-Update: 2025-03-26

Index: python-tz-2025.2/src/pytz/__init__.py
===================================================================
--- python-tz-2025.2.orig/src/pytz/__init__.py
+++ python-tz-2025.2/src/pytz/__init__.py
@@ -11,6 +11,8 @@ on how to use these modules.
 import sys
 import datetime
 import os.path
+import pathlib
+import zoneinfo
 
 from pytz.exceptions import AmbiguousTimeError
 from pytz.exceptions import InvalidTimeError
@@ -92,7 +94,7 @@ def open_resource(name):
     if zoneinfo_dir is not None:
         filename = os.path.join(zoneinfo_dir, *name_parts)
     else:
-        filename = os.path.join(os.path.dirname(__file__),
+        filename = os.path.join('/usr','share',
                                 'zoneinfo', *name_parts)
         if not os.path.exists(filename):
             # http://bugs.launchpad.net/bugs/383171 - we avoid using this
@@ -202,7 +204,7 @@ def _case_insensitive_zone_lookup(zone):
     """case-insensitively matching timezone, else return zone unchanged"""
     global _all_timezones_lower_to_standard
     if _all_timezones_lower_to_standard is None:
-        _all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in _all_timezones_unchecked)  # noqa
+        _all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones)  # noqa
     return _all_timezones_lower_to_standard.get(zone.lower()) or zone  # noqa
 
 
@@ -511,6 +513,15 @@ def _test():
     import pytz
     return doctest.testmod(pytz)
 
+def _read_timezones_from_zone_tab() -> set[str]:
+    timezones = set()
+    zone_tab = pathlib.Path("/usr/share/zoneinfo/zone1970.tab")
+    for line in zone_tab.read_text(encoding="utf-8").splitlines():
+        if line.startswith("#"):
+            continue
+        timezones.add(line.split("\t")[2])
+    return timezones
+
 
 if __name__ == '__main__':
     _test()
Index: python-tz-2025.2/src/pytz/tzfile.py
===================================================================
--- python-tz-2025.2.orig/src/pytz/tzfile.py
+++ python-tz-2025.2/src/pytz/tzfile.py
@@ -125,7 +125,8 @@ def build_tzinfo(zone, fp):
 if __name__ == '__main__':
     import os.path
     from pprint import pprint
-    base = os.path.join(os.path.dirname(__file__), 'zoneinfo')
+    # Patched in Debian, use the system zoninfo from the tzdata package
+    base = '/usr/share/zoneinfo'
     tz = build_tzinfo('Australia/Melbourne',
                       open(os.path.join(base, 'Australia', 'Melbourne'), 'rb'))
     tz = build_tzinfo('US/Eastern',