1 #################################################################
3 # win32tzlist.pl -- compare Windows timezone information
5 # Copyright (c) 2008-2012, PostgreSQL Global Development Group
7 # src/tools/win32tzlist.pl
8 #################################################################
11 # This script compares the timezone information in the Windows registry
12 # with that in src/bin/initdb/findtimezone.c. A list of changes will be
13 # written to stdout - no attempt is made to automatically edit the file.
15 # Run the script from the top-level PG source directory.
23 my $tzfile = 'src/bin/initdb/findtimezone.c';
26 # Fetch all timezones in the registry
29 $HKEY_LOCAL_MACHINE->Open(
30 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", $basekey)
34 $basekey->GetKeys(\@subkeys);
38 foreach my $keyname (@subkeys)
43 $basekey->Open($keyname, $subkey) or die $!;
44 $subkey->GetValues(\%vals) or die $!;
47 die "Incomplete timezone data for $keyname!\n"
48 unless ($vals{Std} && $vals{Dlt} && $vals{Display});
50 { 'std' => $vals{Std}->[2],
51 'dlt' => $vals{Dlt}->[2],
52 'display' => clean_displayname($vals{Display}->[2]), };
58 # Fetch all timezones currently in the file
61 open(TZFILE, "<$tzfile") or die "Could not open $tzfile!\n";
68 # Attempt to locate and extract the complete win32_tzmap struct
69 $pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs
70 or die "Could not locate struct win32_tzmap in $tzfile!";
73 # Extract each individual record from the struct
75 m/{\s+"([^"]+)",\s+"([^"]+)",\s+"([^"]+)",?\s+},\s+\/\*(.+?)\*\//gs)
81 'display' => clean_displayname($4), };
85 # Look for anything that has changed
89 for my $sys (@system_zones)
92 for my $file (@file_zones)
94 if ($sys->{std} eq $file->{std})
97 if ($sys->{dlt} ne $file->{dlt})
100 "Timezone $sys->{std}, changed name of daylight zone!\n";
102 if ($sys->{display} ne $file->{display})
105 "Timezone $sys->{std} changed displayname ('$sys->{display}' from '$file->{display}')!\n";
118 print "\n\nOther than that, add the following timezones:\n";
122 "\t{\n\t\t\"$z->{std}\", \"$z->{dlt}\",\n\t\t\"FIXME\"\n\t},\t\t\t\t\t\t\t/* $z->{display} */\n";
126 sub clean_displayname