mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
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.
This commit is contained in:
@ -181,6 +181,8 @@ static int max_year;
|
||||
static zic_t min_time;
|
||||
static int min_year;
|
||||
static int noise;
|
||||
static int print_abbrevs;
|
||||
static zic_t print_cutoff;
|
||||
static const char *rfilename;
|
||||
static int rlinenum;
|
||||
static const char *progname;
|
||||
@ -457,7 +459,7 @@ static void
|
||||
usage(FILE *stream, int status)
|
||||
{
|
||||
(void) fprintf(stream, _("%s: usage is %s \
|
||||
[ --version ] [ --help ] [ -v ] [ -l localtime ] [ -p posixrules ] \\\n\
|
||||
[ --version ] [ --help ] [ -v ] [ -P ] [ -l localtime ] [ -p posixrules ] \\\n\
|
||||
\t[ -d directory ] [ -L leapseconds ] [ -y yearistype ] [ filename ... ]\n\
|
||||
\n\
|
||||
Report bugs to tz@elsie.nci.nih.gov.\n"),
|
||||
@ -498,7 +500,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
usage(stdout, EXIT_SUCCESS);
|
||||
}
|
||||
while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF && c != -1)
|
||||
while ((c = getopt(argc, argv, "d:l:p:L:vPsy:")) != EOF && c != -1)
|
||||
switch (c)
|
||||
{
|
||||
default:
|
||||
@ -561,6 +563,10 @@ main(int argc, char *argv[])
|
||||
case 'v':
|
||||
noise = TRUE;
|
||||
break;
|
||||
case 'P':
|
||||
print_abbrevs = TRUE;
|
||||
print_cutoff = time(NULL);
|
||||
break;
|
||||
case 's':
|
||||
(void) printf("%s: -s ignored\n", progname);
|
||||
break;
|
||||
@ -1780,6 +1786,21 @@ writezone(const char *name, const char *string)
|
||||
puttzcode(gmtoffs[i], fp);
|
||||
(void) putc(isdsts[i], fp);
|
||||
(void) putc((unsigned char) indmap[abbrinds[i]], fp);
|
||||
|
||||
/* Print current timezone abbreviations if requested */
|
||||
if (print_abbrevs && pass == 2 &&
|
||||
(ats[i] >= print_cutoff || i == typecnt - 1))
|
||||
{
|
||||
char *thisabbrev = &thischars[indmap[abbrinds[i]]];
|
||||
|
||||
/* filter out assorted junk entries */
|
||||
if (strcmp(thisabbrev, GRANDPARENTED) != 0 &&
|
||||
strcmp(thisabbrev, "zzz") != 0)
|
||||
fprintf(stdout, "%s\t%ld%s\n",
|
||||
thisabbrev,
|
||||
gmtoffs[i],
|
||||
isdsts[i] ? "\tD" : "");
|
||||
}
|
||||
}
|
||||
if (thischarcnt != 0)
|
||||
(void) fwrite((void *) thischars,
|
||||
|
Reference in New Issue
Block a user