NetBSD/include/tzfile.h

180 lines
5.5 KiB
C
Raw Permalink Normal View History

Sync with tzcode2024a: Release 2024a - 2024-02-01 09:28:56 -0800 Changes to code The FROM and TO columns of Rule lines can no longer be "minimum" or an abbreviation of "minimum", because TZif files do not support DST rules that extend into the indefinite past - although these rules were supported when TZif files had only 32-bit data, this stopped working when 64-bit TZif files were introduced in 1995. This should not be a problem for realistic data, since DST was first used in the 20th century. As a transition aid, FROM columns like "minimum" are now diagnosed and then treated as if they were the year 1900; this should suffice for TZif files on old systems with only 32-bit time_t, and it is more compatible with bugs in 2023c-and-earlier localtime.c. (Problem reported by Yoshito Umaoka.) localtime and related functions no longer mishandle some timestamps that occur about 400 years after a switch to a time zone with a DST schedule. In 2023d data this problem was visible for some timestamps in November 2422, November 2822, etc. in America/Ciudad_Juarez. (Problem reported by Gilmore Davidson.) strftime %s now uses tm_gmtoff if available. (Problem and draft patch reported by Dag-Erling Smørgrav.) Changes to build procedure The leap-seconds.list file is now copied from the IERS instead of from its downstream counterpart at NIST, as the IERS version is now in the public domain too and tends to be more up-to-date. (Thanks to Martin Burnicki for liaisoning with the IERS.) Changes to documentation The strftime man page documents which struct tm members affect which conversion specs, and that tzset is called. (Problems reported by Robert Elz and Steve Summit.)
2024-02-17 17:54:47 +03:00
/* $NetBSD: tzfile.h,v 1.13 2024/02/17 14:54:47 christos Exp $ */
2015-07-11 19:40:53 +03:00
#ifndef _TZFILE_H_
#define _TZFILE_H_
1994-10-26 03:55:40 +03:00
1993-03-21 12:45:37 +03:00
/*
2015-07-11 19:40:53 +03:00
** This file is in the public domain, so clarified as of
** 1996-06-05 by Arthur David Olson.
*/
1993-03-21 12:45:37 +03:00
2015-07-11 19:40:53 +03:00
/*
** 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!
*/
1993-03-21 12:45:37 +03:00
/*
2015-07-11 19:40:53 +03:00
** Information about time zone files.
*/
#ifndef TZDIR /* Time zone object file directory */
# define TZDIR "/usr/share/zoneinfo"
2015-07-11 19:40:53 +03:00
#endif /* !defined TZDIR */
#ifndef TZDEFAULT
# define TZDEFAULT "/etc/localtime"
2015-07-11 19:40:53 +03:00
#endif /* !defined TZDEFAULT */
#ifndef TZDEFRULES
# define TZDEFRULES "posixrules"
2015-07-11 19:40:53 +03:00
#endif /* !defined TZDEFRULES */
1993-03-21 12:45:37 +03:00
2019-04-04 21:18:52 +03:00
/* See Internet RFC 8536 for more details about the following format. */
1993-03-21 12:45:37 +03:00
/*
** Each file begins with. . .
*/
2015-07-11 19:40:53 +03:00
#define TZ_MAGIC "TZif"
1993-03-21 12:45:37 +03:00
struct tzhead {
char tzh_magic[4]; /* TZ_MAGIC */
2015-07-11 19:40:53 +03:00
char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */
char tzh_reserved[15]; /* reserved; must be zero */
2019-07-03 18:49:21 +03:00
char tzh_ttisutcnt[4]; /* coded number of trans. time flags */
1993-03-21 12:45:37 +03:00
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
2015-07-11 19:40:53 +03:00
** one (char [4]) coded UT offset in seconds
1993-03-21 12:45:37 +03:00
** 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
2015-07-11 19:40:53 +03:00
** tzh_ttisstdcnt (char)s indexed by type; if 1, transition
** time is standard time, if 0,
2019-07-03 18:49:21 +03:00
** transition time is local (wall clock)
** time; if absent, transition times are
** assumed to be local time
2019-07-03 18:49:21 +03:00
** tzh_ttisutcnt (char)s indexed by type; if 1, transition
** time is UT, if 0, transition time is
** local time; if absent, transition
** times are assumed to be local time.
** When this is 1, the corresponding
** std/wall indicator must also be 1.
1993-03-21 12:45:37 +03:00
*/
/*
2015-07-11 19:40:53 +03:00
** 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
Sync with tzcode2024a: Release 2024a - 2024-02-01 09:28:56 -0800 Changes to code The FROM and TO columns of Rule lines can no longer be "minimum" or an abbreviation of "minimum", because TZif files do not support DST rules that extend into the indefinite past - although these rules were supported when TZif files had only 32-bit data, this stopped working when 64-bit TZif files were introduced in 1995. This should not be a problem for realistic data, since DST was first used in the 20th century. As a transition aid, FROM columns like "minimum" are now diagnosed and then treated as if they were the year 1900; this should suffice for TZif files on old systems with only 32-bit time_t, and it is more compatible with bugs in 2023c-and-earlier localtime.c. (Problem reported by Yoshito Umaoka.) localtime and related functions no longer mishandle some timestamps that occur about 400 years after a switch to a time zone with a DST schedule. In 2023d data this problem was visible for some timestamps in November 2422, November 2822, etc. in America/Ciudad_Juarez. (Problem reported by Gilmore Davidson.) strftime %s now uses tm_gmtoff if available. (Problem and draft patch reported by Dag-Erling Smørgrav.) Changes to build procedure The leap-seconds.list file is now copied from the IERS instead of from its downstream counterpart at NIST, as the IERS version is now in the public domain too and tends to be more up-to-date. (Thanks to Martin Burnicki for liaisoning with the IERS.) Changes to documentation The strftime man page documents which struct tm members affect which conversion specs, and that tzset is called. (Problems reported by Robert Elz and Steve Summit.)
2024-02-17 17:54:47 +03:00
** (with nothing between the newlines if there is no POSIX.1-2017
** representation for such instants).
2015-07-11 19:40:53 +03:00
**
** If tz_version is '3' or greater, the above is extended as follows.
Sync with tzcode2024a: Release 2024a - 2024-02-01 09:28:56 -0800 Changes to code The FROM and TO columns of Rule lines can no longer be "minimum" or an abbreviation of "minimum", because TZif files do not support DST rules that extend into the indefinite past - although these rules were supported when TZif files had only 32-bit data, this stopped working when 64-bit TZif files were introduced in 1995. This should not be a problem for realistic data, since DST was first used in the 20th century. As a transition aid, FROM columns like "minimum" are now diagnosed and then treated as if they were the year 1900; this should suffice for TZif files on old systems with only 32-bit time_t, and it is more compatible with bugs in 2023c-and-earlier localtime.c. (Problem reported by Yoshito Umaoka.) localtime and related functions no longer mishandle some timestamps that occur about 400 years after a switch to a time zone with a DST schedule. In 2023d data this problem was visible for some timestamps in November 2422, November 2822, etc. in America/Ciudad_Juarez. (Problem reported by Gilmore Davidson.) strftime %s now uses tm_gmtoff if available. (Problem and draft patch reported by Dag-Erling Smørgrav.) Changes to build procedure The leap-seconds.list file is now copied from the IERS instead of from its downstream counterpart at NIST, as the IERS version is now in the public domain too and tends to be more up-to-date. (Thanks to Martin Burnicki for liaisoning with the IERS.) Changes to documentation The strftime man page documents which struct tm members affect which conversion specs, and that tzset is called. (Problems reported by Robert Elz and Steve Summit.)
2024-02-17 17:54:47 +03:00
** First, the TZ string's hour offset may range from -167
2015-07-11 19:40:53 +03:00
** 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.
1993-03-21 12:45:37 +03:00
*/
/*
2015-07-11 19:40:53 +03:00
** In the current implementation, "tzset()" refuses to deal with files that
** exceed any of the limits below.
1993-03-21 12:45:37 +03:00
*/
2015-07-11 19:40:53 +03:00
#ifndef TZ_MAX_TIMES
2023-09-16 21:19:30 +03:00
/* This must be at least 242 for Europe/London with 'zic -b fat'. */
# define TZ_MAX_TIMES 2000
2015-07-11 19:40:53 +03:00
#endif /* !defined TZ_MAX_TIMES */
1993-03-21 12:45:37 +03:00
2015-07-11 19:40:53 +03:00
#ifndef TZ_MAX_TYPES
2023-09-16 21:19:30 +03:00
/* This must be at least 18 for Europe/Vilnius with 'zic -b fat'. */
# define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
2015-07-11 19:40:53 +03:00
#endif /* !defined TZ_MAX_TYPES */
1993-03-21 12:45:37 +03:00
2015-07-11 19:40:53 +03:00
#ifndef TZ_MAX_CHARS
2023-09-16 21:19:30 +03:00
/* This must be at least 40 for America/Anchorage. */
# define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
2015-07-11 19:40:53 +03:00
/* (limited by what unsigned chars can hold) */
#endif /* !defined TZ_MAX_CHARS */
1993-03-21 12:45:37 +03:00
2015-07-11 19:40:53 +03:00
#ifndef TZ_MAX_LEAPS
2023-09-16 21:19:30 +03:00
/* This must be at least 27 for leap seconds from 1972 through mid-2023.
There's a plan to discontinue leap seconds by 2035. */
# define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
2015-07-11 19:40:53 +03:00
#endif /* !defined TZ_MAX_LEAPS */
1993-03-21 12:45:37 +03:00
#define SECSPERMIN 60
#define MINSPERHOUR 60
#define HOURSPERDAY 24
#define DAYSPERWEEK 7
#define DAYSPERNYEAR 365
#define DAYSPERLYEAR 366
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
2015-07-11 19:40:53 +03:00
#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
1993-03-21 12:45:37 +03:00
#define MONSPERYEAR 12
Sync with tzcode2024a: Release 2024a - 2024-02-01 09:28:56 -0800 Changes to code The FROM and TO columns of Rule lines can no longer be "minimum" or an abbreviation of "minimum", because TZif files do not support DST rules that extend into the indefinite past - although these rules were supported when TZif files had only 32-bit data, this stopped working when 64-bit TZif files were introduced in 1995. This should not be a problem for realistic data, since DST was first used in the 20th century. As a transition aid, FROM columns like "minimum" are now diagnosed and then treated as if they were the year 1900; this should suffice for TZif files on old systems with only 32-bit time_t, and it is more compatible with bugs in 2023c-and-earlier localtime.c. (Problem reported by Yoshito Umaoka.) localtime and related functions no longer mishandle some timestamps that occur about 400 years after a switch to a time zone with a DST schedule. In 2023d data this problem was visible for some timestamps in November 2422, November 2822, etc. in America/Ciudad_Juarez. (Problem reported by Gilmore Davidson.) strftime %s now uses tm_gmtoff if available. (Problem and draft patch reported by Dag-Erling Smørgrav.) Changes to build procedure The leap-seconds.list file is now copied from the IERS instead of from its downstream counterpart at NIST, as the IERS version is now in the public domain too and tends to be more up-to-date. (Thanks to Martin Burnicki for liaisoning with the IERS.) Changes to documentation The strftime man page documents which struct tm members affect which conversion specs, and that tzset is called. (Problems reported by Robert Elz and Steve Summit.)
2024-02-17 17:54:47 +03:00
#define YEARSPERREPEAT 400
1993-03-21 12:45:37 +03:00
#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
2015-07-11 19:40:53 +03:00
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
1993-03-21 12:45:37 +03:00
/*
2015-07-11 19:40:53 +03:00
** 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.
1993-03-21 12:45:37 +03:00
*/
2015-07-11 19:40:53 +03:00
#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
1993-03-21 12:45:37 +03:00
2015-07-11 19:40:53 +03:00
#endif /* !defined _TZFILE_H_ */