Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6960277

Browse files
committed
Semi-automatically detect changes in timezone abbreviations.
Add an option to zic.c to dump out all non-obsolete timezone abbreviations defined in the Olson database. Comparing this list to its previous state will clue us in when something happens that we may need to account for in the tznames/ time zone abbreviation lists. The README file's previous exhortation to "just grep for differences" was completely useless advice, in my now-considerable experience; but maybe this will be a bit more useful. As a starting point I built the same list from the tzdata files as they existed in 2006, which is committed here as known_abbrevs.txt. Comparison indeed turned up quite a few changes we had neglected to account for, which I will commit separately.
1 parent b7f8465 commit 6960277

File tree

5 files changed

+241
-8
lines changed

5 files changed

+241
-8
lines changed

src/timezone/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/zic
2+
/abbrevs.txt

src/timezone/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ ifeq (,$(with_system_tzdata))
5555
endif
5656
$(MAKE) -C tznames $@
5757

58+
abbrevs.txt: zic $(TZDATAFILES)
59+
mkdir junkdir
60+
$(ZIC) -P -d junkdir -p '$(POSIXRULES)' $(TZDATAFILES) | LANG=C sort | uniq >abbrevs.txt
61+
rm -rf junkdir
62+
5863
installdirs:
5964
$(MKDIR_P) '$(DESTDIR)$(datadir)'
6065

@@ -65,4 +70,4 @@ endif
6570
$(MAKE) -C tznames $@
6671

6772
clean distclean maintainer-clean:
68-
rm -f zic$(X) $(ZICOBJS)
73+
rm -f zic$(X) $(ZICOBJS) abbrevs.txt

src/timezone/README

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ Since time zone rules change frequently in some parts of the world,
2222
we should endeavor to update the data files before each PostgreSQL
2323
release.
2424

25-
At each update, we should check if time zone offsets have changed.
26-
Just search for the current or previous year and see what has changed.
27-
Sometimes a country changes its time zone offsets, for example Georgia
28-
in 2004. Just grepping in the zic database files for 2004 is enough to
29-
spot such a change. Then the files under tznames/ should be updated.
25+
While the files under data/ can just be duplicated when updating, manual
26+
effort is needed to update the time zone abbreviation lists under tznames/.
27+
These need to be changed whenever new abbreviations are invented or the
28+
UTC offset associated with an existing abbreviation changes. To detect
29+
if this has happened, after installing new files under data/ do
30+
gmake abbrevs.txt
31+
which will produce a file showing all abbreviations that are in current
32+
use according to the data/ files. Compare this to known_abbrevs.txt,
33+
which is the list that existed last time the tznames/ files were updated.
34+
Update tznames/ as seems appropriate, then replace known_abbrevs.txt
35+
in the same commit.
3036

3137
When there has been a new release of Windows (probably including Service
3238
Packs), the list of matching timezones need to be updated. Run the

src/timezone/known_abbrevs.txt

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
ACT -18000
2+
ADDT -7200 D
3+
ADT -10800 D
4+
ADT 14400 D
5+
AFT 16200
6+
AKST -32400
7+
ALMST 25200 D
8+
AMT -14400
9+
AMT 14400
10+
ANAT 39600
11+
APT -10800 D
12+
AQTT 14400
13+
AQTT 18000
14+
ART -10800
15+
AST -14400
16+
AST 10800
17+
AWT -10800 D
18+
AZOT -3600
19+
AZST 18000 D
20+
BDT 21600
21+
BEAT 9000
22+
BEAUT 9885
23+
BNT 28800
24+
BOT -14400
25+
BRT -10800
26+
BTT 21600
27+
CAST 10800 D
28+
CAT 7200
29+
CCT 23400
30+
CDT -14400 D
31+
CDT -18000 D
32+
CDT 32400 D
33+
CEST 7200 D
34+
CET 3600
35+
CHAST 45900
36+
CHOST 36000 D
37+
CIT 28800
38+
CKHST -34200 D
39+
CLT -14400
40+
COT -18000
41+
CPT -18000 D
42+
CST -21600
43+
CST 28800
44+
CST 34200
45+
CVT -3600
46+
CWT -18000 D
47+
CXT 25200
48+
ChST 36000
49+
DAVT 25200
50+
DDUT 36000
51+
EAST -21600
52+
EAT 10800
53+
ECT -18000
54+
EDT -14400 D
55+
EEST 10800 D
56+
EET 7200
57+
EGST 0 D
58+
EPT -14400 D
59+
EST -18000
60+
EST 36000
61+
FJT 43200
62+
FKT -10800
63+
FNT -7200
64+
GALT -21600
65+
GAMT -32400
66+
GEST 14400 D
67+
GFT -10800
68+
GILT 43200
69+
GMT 0
70+
GMT+1 -3600
71+
GMT+10 -36000
72+
GMT+11 -39600
73+
GMT+12 -43200
74+
GMT+2 -7200
75+
GMT+3 -10800
76+
GMT+4 -14400
77+
GMT+5 -18000
78+
GMT+6 -21600
79+
GMT+7 -25200
80+
GMT+8 -28800
81+
GMT+9 -32400
82+
GMT-1 3600
83+
GMT-10 36000
84+
GMT-11 39600
85+
GMT-12 43200
86+
GMT-13 46800
87+
GMT-14 50400
88+
GMT-2 7200
89+
GMT-3 10800
90+
GMT-4 14400
91+
GMT-5 18000
92+
GMT-6 21600
93+
GMT-7 25200
94+
GMT-8 28800
95+
GMT-9 32400
96+
GST -7200
97+
GST 14400
98+
GYT -14400
99+
HAST -36000
100+
HKT 28800
101+
HOVST 28800 D
102+
HST -36000
103+
ICT 25200
104+
ICT 28800
105+
IDDT 14400 D
106+
IOT 21600
107+
IRDT 16200 D
108+
IRKT 25200
109+
IST 23400 D
110+
JST 32400
111+
KDT 36000 D
112+
KGST 21600 D
113+
KOST 43200
114+
KRAT 21600
115+
KST 28800
116+
LHST 39600 D
117+
LINT 50400
118+
LKT 21600
119+
MAGT 36000
120+
MART -34200
121+
MAWT 21600
122+
MDDT -18000 D
123+
MDT -21600 D
124+
MET 3600
125+
MHT 43200
126+
MMT 23400
127+
MPT -21600 D
128+
MST -25200
129+
MUT 14400
130+
MVT 18000
131+
MWT -21600 D
132+
MYT 28800
133+
NCT 39600
134+
NDDT -5400 D
135+
NFT 41400
136+
NOVST 25200 D
137+
NPT 20700
138+
NRT 43200
139+
NUT -39600
140+
NZST 43200
141+
OMST 18000
142+
ORAT 18000
143+
PET -18000
144+
PETT 39600
145+
PGT 36000
146+
PHOT 46800
147+
PKT 18000
148+
PMDT -7200 D
149+
PONT 39600
150+
PPT -25200 D
151+
PST -28800
152+
PWT -25200 D
153+
PWT 32400
154+
PYST -10800 D
155+
QYZT 21600
156+
RET 14400
157+
ROTT -10800
158+
SAKT 36000
159+
SAMT 14400
160+
SAST 10800 D
161+
SAST 7200
162+
SBT 39600
163+
SCT 14400
164+
SGT 28800
165+
SRT -10800
166+
SST -39600
167+
SYOT 10800
168+
TAHT -36000
169+
TFT 18000
170+
TJT 18000
171+
TKT -36000
172+
TMT 18000
173+
TOST 50400 D
174+
TRUT 36000
175+
TVT 43200
176+
UCT 0
177+
ULAST 32400 D
178+
UTC 0
179+
UYHST -9000 D
180+
UZT 18000
181+
VET -14400
182+
VLAST 32400
183+
VOST 21600
184+
VUT 39600
185+
WAKT 43200
186+
WARST -10800 D
187+
WART -14400
188+
WAST 7200 D
189+
WAT -3600
190+
WAT 0
191+
WAT 3600
192+
WEST 3600 D
193+
WET 0
194+
WFT 43200
195+
WGST -7200 D
196+
WIT 25200
197+
WST -39600
198+
WST 28800
199+
YAKT 28800
200+
YEKT 18000

src/timezone/zic.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ static int max_year;
181181
static zic_t min_time;
182182
static int min_year;
183183
static int noise;
184+
static int print_abbrevs;
185+
static zic_t print_cutoff;
184186
static const char *rfilename;
185187
static int rlinenum;
186188
static const char *progname;
@@ -457,7 +459,7 @@ static void
457459
usage(FILE *stream, int status)
458460
{
459461
(void) fprintf(stream, _("%s: usage is %s \
460-
[ --version ] [ --help ] [ -v ] [ -l localtime ] [ -p posixrules ] \\\n\
462+
[ --version ] [ --help ] [ -v ] [ -P ] [ -l localtime ] [ -p posixrules ] \\\n\
461463
\t[ -d directory ] [ -L leapseconds ] [ -y yearistype ] [ filename ... ]\n\
462464
\n\
463465
Report bugs to tz@elsie.nci.nih.gov.\n"),
@@ -498,7 +500,7 @@ main(int argc, char *argv[])
498500
{
499501
usage(stdout, EXIT_SUCCESS);
500502
}
501-
while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF && c != -1)
503+
while ((c = getopt(argc, argv, "d:l:p:L:vPsy:")) != EOF && c != -1)
502504
switch (c)
503505
{
504506
default:
@@ -561,6 +563,10 @@ main(int argc, char *argv[])
561563
case 'v':
562564
noise = TRUE;
563565
break;
566+
case 'P':
567+
print_abbrevs = TRUE;
568+
print_cutoff = time(NULL);
569+
break;
564570
case 's':
565571
(void) printf("%s: -s ignored\n", progname);
566572
break;
@@ -1780,6 +1786,21 @@ writezone(const char *name, const char *string)
17801786
puttzcode(gmtoffs[i], fp);
17811787
(void) putc(isdsts[i], fp);
17821788
(void) putc((unsigned char) indmap[abbrinds[i]], fp);
1789+
1790+
/* Print current timezone abbreviations if requested */
1791+
if (print_abbrevs && pass == 2 &&
1792+
(ats[i] >= print_cutoff || i == typecnt - 1))
1793+
{
1794+
char *thisabbrev = &thischars[indmap[abbrinds[i]]];
1795+
1796+
/* filter out assorted junk entries */
1797+
if (strcmp(thisabbrev, GRANDPARENTED) != 0 &&
1798+
strcmp(thisabbrev, "zzz") != 0)
1799+
fprintf(stdout, "%s\t%ld%s\n",
1800+
thisabbrev,
1801+
gmtoffs[i],
1802+
isdsts[i] ? "\tD" : "");
1803+
}
17831804
}
17841805
if (thischarcnt != 0)
17851806
(void) fwrite((void *) thischars,

0 commit comments

Comments
 (0)