···199199 3) Fallback for missing offsets (min 1, max max_bucket) using classification + traffic.
200200 4) Distribute codes evenly across DST buckets, cap each to max_bucket.
201201 """
202202- year = datetime.utcnow().year
202202+ year = datetime.now(timezone.utc).year
203203 airport_db = airportsdata.load("IATA")
204204 # Ensure unique HTML airport entries by IATA code
205205 seen_iatas: set[str] = set()
···437437 parser.add_argument(
438438 "--max-bucket",
439439 type=int,
440440- default=3,
441441- help="Maximum number of airport codes to include per DST bucket (default: 3)",
440440+ default=10,
441441+ help="Maximum number of airport codes to include per DST bucket (default: 10)",
442442 )
443443 args = parser.parse_args(argv)
444444
+12-3
generate_tz_list.py
···11# Requires Python 3.9+ for zoneinfo
22import zoneinfo
33from datetime import datetime, timedelta, timezone
44+from functools import lru_cache
45# No unused imports found (time is used for .timestamp())
5667# Helper to get offset and DST component safely
···2425 return None
25262627# Function to find DST transitions within a year
2828+@lru_cache(maxsize=None)
2729def find_dst_transitions_accurate(tz_name: str, year: int) -> tuple[int, int, int, int]:
2830 """ Finds precise DST transition UTC timestamps for a given year.
2931 Returns (std_offset_sec, dst_offset_sec, last_start_utc_ts, last_end_utc_ts)
···171173 if city_name not in processed_zones[key_tuple]["names"]:
172174 processed_zones[key_tuple]["names"].append(city_name)
173175174174- # Convert dict values to a list and sort primarily by standard offset, then DST offset
175175- # Sort key uses the seconds offset stored in the dictionary value
176176- tz_data_list = sorted(processed_zones.values(), key=lambda x: (x["std_offset_s"], x["dst_offset_s"]))
176176+ # Convert dict values to a list and sort by std offset, then DST offset, then by DST start/end to keep consistent ordering
177177+ tz_data_list = sorted(
178178+ processed_zones.values(),
179179+ key=lambda x: (
180180+ x["std_offset_s"],
181181+ x["dst_offset_s"],
182182+ x["start_utc"],
183183+ x["end_utc"]
184184+ )
185185+ )
177186 print(f"Generated data for {len(tz_data_list)} unique offset/DST rule combinations.")
178187179188 # --- C Code Generation: Flatten name pool and tz_list entries ---
+3-3
run.sh
···5566# Function to run the timezone generation script
77generate_tz_list() {
88- echo "Generating timezone list..."
99- # python generate_tz_list.py
1010- uv run python generate_airport_tz_list.py --top 10 --max-bucket 10 --out src/c/airport_tz_list.c
88+ echo "Generating timezone lists..."
99+ uv run python generate_tz_list.py
1010+ uv run python generate_airport_tz_list.py
1111}
12121313# Function to build the project