fix fix_campuszeit

This commit is contained in:
Lennart J. Kurzweg (Nx2)
2025-08-24 14:52:12 +02:00
parent bfc57081b8
commit 8be6a841d0

View File

@@ -20,22 +20,21 @@ def replace_campus_timezone(directory):
with open(filepath, 'r', encoding='utf-8') as f: with open(filepath, 'r', encoding='utf-8') as f:
content = f.read() content = f.read()
if 'TZID:Europe/Berlin' in content or 'TZID="Europe/Berlin"' in content: start_idx = content.find('BEGIN:VTIMEZONE')
# Remove VTIMEZONE block for CampusNetZeit (optional depending on needs) end_idx = content.find('END:VTIMEZONE', start_idx)
# Use a regex if multiple VTIMEZONE blocks may exist if start_idx != -1 and end_idx != -1:
start_idx = content.find('BEGIN:VTIMEZONE') content = content[:start_idx] + content[end_idx + len('END:VTIMEZONE\n'):]
end_idx = content.find('END:VTIMEZONE', start_idx)
if start_idx != -1 and end_idx != -1:
content = content[:start_idx] + content[end_idx + len('END:VTIMEZONE\n'):]
# Replace all TZID references # Replace all TZID references
content = content.replace('TZID:Europe/Berlin', 'TZID:Europe/Berlin') content = content.replace('TZID:CampusNetZeit', 'TZID:Europe/Berlin')
content = content.replace('TZID="Europe/Berlin"', 'TZID="Europe/Berlin"') content = content.replace('TZID=CampusNetZeit', 'TZID=Europe/Berlin')
content = content.replace('TZID:"CampusNetZeit"', 'TZID:"Europe/Berlin"')
content = content.replace('TZID="CampusNetZeit"', 'TZID="Europe/Berlin"')
with open(filepath, 'w', encoding='utf-8') as f: with open(filepath, 'w', encoding='utf-8') as f:
f.write(content) f.write(content)
print(f"Updated time zone in: {filename}") print(f"Updated time zone in: {filename}")
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) != 2: if len(sys.argv) != 2: