33d9f9e08d
Changes affecting API The 'zic' command now outputs a dummy transition when far-future data can't be summarized using a TZ string, and uses a 402-year window rather than a 400-year window. For the current data, this affects only the Asia/Tehran file. It does not affect any of the time stamps that this file represents, so zdump outputs the same information as before. (Thanks to Andrew Main (Zefram).) The 'date' command has a new '-r' option, which lets you specify the integer time to display, a la FreeBSD. The 'tzselect' command has two new options '-c' and '-n', which lets you select a zone based on latitude and longitude. The 'zic' command's '-v' option now warns about constructs that require the new version-3 binary file format. (Thanks to Arthur David Olson for the suggestion.) Support for floating-point time_t has been removed. It was always dicey, and POSIX no longer requires it. (Thanks to Eric Blake for suggesting to the POSIX committee to remove it, and thanks to Alan Barrett, Clive D.W. Feather, Andy Heninger, Arthur David Olson, and Alois Treindl, for reporting bugs and elucidating some of the corners of the old floating-point implementation.) The signatures of 'offtime', 'timeoff', and 'gtime' have been changed back to the old practice of using 'long' to represent UT offsets. This had been inadvertently and mistakenly changed to 'int_fast32_t'. (Thanks to Christos Zoulos.) The code avoids undefined behavior on integer overflow in some more places, including gmtime, localtime, mktime and zdump. Changes affecting the zdump utility zdump now outputs "UT" when referring to Universal Time, not "UTC". "UTC" does not make sense for time stamps that predate the introduction of UTC, whereas "UT", a more-generic term, does. (Thanks to Steve Allen for clarifying UT vs UTC.) Data changes affecting behavior of tzselect and similar programs Country code BQ is now called the more-common name "Caribbean Netherlands" rather than the more-official "Bonaire, St Eustatius & Saba". Remove from zone.tab the names America/Montreal, America/Shiprock, and Antarctica/South_Pole, as they are equivalent to existing same-country-code zones for post-1970 time stamps. The data for these names are unchanged, so the names continue to work as before. Changes affecting code internals zic -c now runs way faster on 64-bit hosts when given large numbers. zic now uses vfprintf to avoid allocating and freeing some memory. tzselect now computes the list of continents from the data, rather than have it hard-coded. Minor changes pacify GCC 4.7.3 and GCC 4.8.1. Changes affecting the build procedure The 'leapseconds' file is now generated automatically from a new file 'leap-seconds.list', which is a copy of <ftp://time.nist.gov/pub/leap-seconds.list>. A new source file 'leapseconds.awk' implements this. The goal is simplification of the future maintenance of 'leapseconds'. When building the 'posix' or 'right' subdirectories, if the subdirectory would be a copy of the default subdirectory, it is now made a symbolic link if that is supported. This saves about 2 MB of file system space. The links America/Shiprock and Antarctica/South_Pole have been moved to the 'backward' file. This affects only nondefault builds that omit 'backward'. Changes affecting documentation and commentary Changes to the 'tzfile' man page It now mentions that the binary file format may be extended in future versions by appending data. It now refers to the 'zdump' and 'zic' man pages. Changes to the 'zic' man page It lists conditions that elicit a warning with '-v'. It says that the behavior is unspecified when duplicate names are given, or if the source of one link is the target of another. Its examples are updated to match the latest data. The definition of white space has been clarified slightly. (Thanks to Michael Deckers.) Changes to the 'Theory' file There is a new section about the accuracy of the tz database, describing the many ways that errors can creep in, and explaining why so many of the pre-1970 time stamps are wrong or misleading (thanks to Steve Allen, Lester Caine, and Garrett Wollman for discussions that contributed to this). The 'Theory' file describes LMT better (this follows a suggestion by Guy Harris). It refers to the 2013 edition of POSIX rather than the 2004 edition. It's mentioned that excluding 'backward' should not affect the other data, and it suggests at least one zone.tab name per inhabited country (thanks to Stephen Colebourne). Some longstanding restrictions on names are documented, e.g., 'America/New_York' precludes 'America/New_York/Bronx'. It gives more reasons for the 1970 cutoff. It now mentions which time_t variants are supported, such as signed integer time_t. (Thanks to Paul Goyette for reporting typos in an experimental version of this change.) (Thanks to Philip Newton for correcting typos in these changes.) Documentation and commentary is more careful to distinguish UT in general from UTC in particular. (Thanks to Steve Allen.) Add a better source for the Zurich 1894 transition. (Thanks to Pierre-Yves Berger.) Update shapefile citations in tz-link.htm. (Thanks to Guy Harris.)
179 lines
5.2 KiB
C
179 lines
5.2 KiB
C
/* $NetBSD: tzfile.h,v 1.12 2013/09/20 19:06:54 christos Exp $ */
|
|
|
|
#ifndef TZFILE_H
|
|
#define TZFILE_H
|
|
|
|
/*
|
|
** This file is in the public domain, so clarified as of
|
|
** 1996-06-05 by Arthur David Olson.
|
|
*/
|
|
|
|
/*
|
|
** This header is for use ONLY with the time conversion code.
|
|
** There is no guarantee that it will remain unchanged,
|
|
** or that it will remain at all.
|
|
** Do NOT copy it to any system include directory.
|
|
** Thank you!
|
|
*/
|
|
|
|
/*
|
|
** Information about time zone files.
|
|
*/
|
|
|
|
#ifndef TZDIR /* Time zone object file directory */
|
|
#define TZDIR "/usr/share/zoneinfo"
|
|
#endif /* !defined TZDIR */
|
|
|
|
#ifndef TZDEFAULT
|
|
#define TZDEFAULT "/etc/localtime"
|
|
#endif /* !defined TZDEFAULT */
|
|
|
|
#ifndef TZDEFRULES
|
|
#define TZDEFRULES "posixrules"
|
|
#endif /* !defined TZDEFRULES */
|
|
|
|
/*
|
|
** Each file begins with. . .
|
|
*/
|
|
|
|
#define TZ_MAGIC "TZif"
|
|
|
|
struct tzhead {
|
|
char tzh_magic[4]; /* TZ_MAGIC */
|
|
char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */
|
|
char tzh_reserved[15]; /* reserved--must be zero */
|
|
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
|
|
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
|
|
char tzh_leapcnt[4]; /* coded number of leap seconds */
|
|
char tzh_timecnt[4]; /* coded number of transition times */
|
|
char tzh_typecnt[4]; /* coded number of local time types */
|
|
char tzh_charcnt[4]; /* coded number of abbr. chars */
|
|
};
|
|
|
|
/*
|
|
** . . .followed by. . .
|
|
**
|
|
** tzh_timecnt (char [4])s coded transition times a la time(2)
|
|
** tzh_timecnt (unsigned char)s types of local time starting at above
|
|
** tzh_typecnt repetitions of
|
|
** one (char [4]) coded UT offset in seconds
|
|
** one (unsigned char) used to set tm_isdst
|
|
** one (unsigned char) that's an abbreviation list index
|
|
** tzh_charcnt (char)s '\0'-terminated zone abbreviations
|
|
** tzh_leapcnt repetitions of
|
|
** one (char [4]) coded leap second transition times
|
|
** one (char [4]) total correction after above
|
|
** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
|
|
** time is standard time, if FALSE,
|
|
** transition time is wall clock time
|
|
** if absent, transition times are
|
|
** assumed to be wall clock time
|
|
** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
|
|
** time is UT, if FALSE,
|
|
** transition time is local time
|
|
** if absent, transition times are
|
|
** assumed to be local time
|
|
*/
|
|
|
|
/*
|
|
** If tzh_version is '2' or greater, the above is followed by a second instance
|
|
** of tzhead and a second instance of the data in which each coded transition
|
|
** time uses 8 rather than 4 chars,
|
|
** then a POSIX-TZ-environment-variable-style string for use in handling
|
|
** instants after the last transition time stored in the file
|
|
** (with nothing between the newlines if there is no POSIX representation for
|
|
** such instants).
|
|
**
|
|
** If tz_version is '3' or greater, the above is extended as follows.
|
|
** First, the POSIX TZ string's hour offset may range from -167
|
|
** through 167 as compared to the POSIX-required 0 through 24.
|
|
** Second, its DST start time may be January 1 at 00:00 and its stop
|
|
** time December 31 at 24:00 plus the difference between DST and
|
|
** standard time, indicating DST all year.
|
|
*/
|
|
|
|
/*
|
|
** In the current implementation, "tzset()" refuses to deal with files that
|
|
** exceed any of the limits below.
|
|
*/
|
|
|
|
#ifndef TZ_MAX_TIMES
|
|
#define TZ_MAX_TIMES 1200
|
|
#endif /* !defined TZ_MAX_TIMES */
|
|
|
|
#ifndef TZ_MAX_TYPES
|
|
#ifndef NOSOLAR
|
|
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
|
|
#endif /* !defined NOSOLAR */
|
|
#ifdef NOSOLAR
|
|
/*
|
|
** Must be at least 14 for Europe/Riga as of Jan 12 1995,
|
|
** as noted by Earl Chew.
|
|
*/
|
|
#define TZ_MAX_TYPES 20 /* Maximum number of local time types */
|
|
#endif /* !defined NOSOLAR */
|
|
#endif /* !defined TZ_MAX_TYPES */
|
|
|
|
#ifndef TZ_MAX_CHARS
|
|
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
|
|
/* (limited by what unsigned chars can hold) */
|
|
#endif /* !defined TZ_MAX_CHARS */
|
|
|
|
#ifndef TZ_MAX_LEAPS
|
|
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
|
|
#endif /* !defined TZ_MAX_LEAPS */
|
|
|
|
#define SECSPERMIN 60
|
|
#define MINSPERHOUR 60
|
|
#define HOURSPERDAY 24
|
|
#define DAYSPERWEEK 7
|
|
#define DAYSPERNYEAR 365
|
|
#define DAYSPERLYEAR 366
|
|
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
|
|
#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
|
|
#define MONSPERYEAR 12
|
|
|
|
#define TM_SUNDAY 0
|
|
#define TM_MONDAY 1
|
|
#define TM_TUESDAY 2
|
|
#define TM_WEDNESDAY 3
|
|
#define TM_THURSDAY 4
|
|
#define TM_FRIDAY 5
|
|
#define TM_SATURDAY 6
|
|
|
|
#define TM_JANUARY 0
|
|
#define TM_FEBRUARY 1
|
|
#define TM_MARCH 2
|
|
#define TM_APRIL 3
|
|
#define TM_MAY 4
|
|
#define TM_JUNE 5
|
|
#define TM_JULY 6
|
|
#define TM_AUGUST 7
|
|
#define TM_SEPTEMBER 8
|
|
#define TM_OCTOBER 9
|
|
#define TM_NOVEMBER 10
|
|
#define TM_DECEMBER 11
|
|
|
|
#define TM_YEAR_BASE 1900
|
|
|
|
#define EPOCH_YEAR 1970
|
|
#define EPOCH_WDAY TM_THURSDAY
|
|
|
|
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
|
|
|
/*
|
|
** Since everything in isleap is modulo 400 (or a factor of 400), we know that
|
|
** isleap(y) == isleap(y % 400)
|
|
** and so
|
|
** isleap(a + b) == isleap((a + b) % 400)
|
|
** or
|
|
** isleap(a + b) == isleap(a % 400 + b % 400)
|
|
** This is true even if % means modulo rather than Fortran remainder
|
|
** (which is allowed by C89 but not C99).
|
|
** We use this to avoid addition overflow problems.
|
|
*/
|
|
|
|
#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
|
|
|
|
#endif /* !defined TZFILE_H */
|