12708Swollman#ifndef TZFILE_H
22708Swollman#define TZFILE_H
32708Swollman
492991Sobrien
52708Swollman/*
617209Swollman** This file is in the public domain, so clarified as of
7192625Sedwin** 1996-06-05 by Arthur David Olson.
892991Sobrien**
992991Sobrien** $FreeBSD$
1017209Swollman*/
1117209Swollman
1217209Swollman/*
132708Swollman** This header is for use ONLY with the time conversion code.
142708Swollman** There is no guarantee that it will remain unchanged,
152708Swollman** or that it will remain at all.
162708Swollman** Do NOT copy it to any system include directory.
172708Swollman** Thank you!
182708Swollman*/
192708Swollman
202708Swollman/*
212708Swollman** ID
222708Swollman*/
232708Swollman
242708Swollman#ifndef lint
252708Swollman#ifndef NOID
2617209Swollman/*
27192625Sedwinstatic char	tzfilehid[] = "@(#)tzfile.h	8.1";
2817209Swollman*/
292708Swollman#endif /* !defined NOID */
302708Swollman#endif /* !defined lint */
312708Swollman
322708Swollman/*
332708Swollman** Information about time zone files.
342708Swollman*/
352708Swollman
362708Swollman#ifndef TZDIR
372713Swollman#define TZDIR	"/usr/share/zoneinfo" /* Time zone object file directory */
382708Swollman#endif /* !defined TZDIR */
392708Swollman
402708Swollman#ifndef TZDEFAULT
412713Swollman#define TZDEFAULT	"/etc/localtime"
422708Swollman#endif /* !defined TZDEFAULT */
432708Swollman
442708Swollman#ifndef TZDEFRULES
452708Swollman#define TZDEFRULES	"posixrules"
462708Swollman#endif /* !defined TZDEFRULES */
472708Swollman
482708Swollman/*
492708Swollman** Each file begins with. . .
502708Swollman*/
512708Swollman
5242989Swollman#define	TZ_MAGIC	"TZif"
5342989Swollman
542708Swollmanstruct tzhead {
55192625Sedwin	char	tzh_magic[4];		/* TZ_MAGIC */
56192625Sedwin	char	tzh_version[1];		/* '\0' or '2' as of 2005 */
57192625Sedwin	char	tzh_reserved[15];	/* reserved--must be zero */
589936Swollman	char	tzh_ttisgmtcnt[4];	/* coded number of trans. time flags */
592708Swollman	char	tzh_ttisstdcnt[4];	/* coded number of trans. time flags */
602708Swollman	char	tzh_leapcnt[4];		/* coded number of leap seconds */
612708Swollman	char	tzh_timecnt[4];		/* coded number of transition times */
622708Swollman	char	tzh_typecnt[4];		/* coded number of local time types */
632708Swollman	char	tzh_charcnt[4];		/* coded number of abbr. chars */
642708Swollman};
652708Swollman
662708Swollman/*
672708Swollman** . . .followed by. . .
682708Swollman**
692708Swollman**	tzh_timecnt (char [4])s		coded transition times a la time(2)
702708Swollman**	tzh_timecnt (unsigned char)s	types of local time starting at above
712708Swollman**	tzh_typecnt repetitions of
7242989Swollman**		one (char [4])		coded UTC offset in seconds
732708Swollman**		one (unsigned char)	used to set tm_isdst
742708Swollman**		one (unsigned char)	that's an abbreviation list index
752708Swollman**	tzh_charcnt (char)s		'\0'-terminated zone abbreviations
762708Swollman**	tzh_leapcnt repetitions of
772708Swollman**		one (char [4])		coded leap second transition times
782708Swollman**		one (char [4])		total correction after above
792708Swollman**	tzh_ttisstdcnt (char)s		indexed by type; if TRUE, transition
802708Swollman**					time is standard time, if FALSE,
812708Swollman**					transition time is wall clock time
822708Swollman**					if absent, transition times are
832708Swollman**					assumed to be wall clock time
849936Swollman**	tzh_ttisgmtcnt (char)s		indexed by type; if TRUE, transition
8542989Swollman**					time is UTC, if FALSE,
869936Swollman**					transition time is local time
879936Swollman**					if absent, transition times are
889936Swollman**					assumed to be local time
892708Swollman*/
902708Swollman
912708Swollman/*
92192625Sedwin** If tzh_version is '2' or greater, the above is followed by a second instance
93192625Sedwin** of tzhead and a second instance of the data in which each coded transition
94192625Sedwin** time uses 8 rather than 4 chars,
95192625Sedwin** then a POSIX-TZ-environment-variable-style string for use in handling
96192625Sedwin** instants after the last transition time stored in the file
97192625Sedwin** (with nothing between the newlines if there is no POSIX representation for
98192625Sedwin** such instants).
99192625Sedwin*/
100192625Sedwin
101192625Sedwin/*
1022708Swollman** In the current implementation, "tzset()" refuses to deal with files that
1032708Swollman** exceed any of the limits below.
1042708Swollman*/
1052708Swollman
1062708Swollman#ifndef TZ_MAX_TIMES
107192625Sedwin#define TZ_MAX_TIMES	1200
1082708Swollman#endif /* !defined TZ_MAX_TIMES */
1092708Swollman
1102708Swollman#ifndef TZ_MAX_TYPES
1112708Swollman#ifndef NOSOLAR
1122708Swollman#define TZ_MAX_TYPES	256 /* Limited by what (unsigned char)'s can hold */
1132708Swollman#endif /* !defined NOSOLAR */
1142708Swollman#ifdef NOSOLAR
1159936Swollman/*
1169936Swollman** Must be at least 14 for Europe/Riga as of Jan 12 1995,
117192625Sedwin** as noted by Earl Chew.
1189936Swollman*/
1199936Swollman#define TZ_MAX_TYPES	20	/* Maximum number of local time types */
1202708Swollman#endif /* !defined NOSOLAR */
1212708Swollman#endif /* !defined TZ_MAX_TYPES */
1222708Swollman
1232708Swollman#ifndef TZ_MAX_CHARS
1242708Swollman#define TZ_MAX_CHARS	50	/* Maximum number of abbreviation characters */
1252708Swollman				/* (limited by what unsigned chars can hold) */
1262708Swollman#endif /* !defined TZ_MAX_CHARS */
1272708Swollman
1282708Swollman#ifndef TZ_MAX_LEAPS
1292708Swollman#define TZ_MAX_LEAPS	50	/* Maximum number of leap second corrections */
1302708Swollman#endif /* !defined TZ_MAX_LEAPS */
1312708Swollman
1322708Swollman#define SECSPERMIN	60
1332708Swollman#define MINSPERHOUR	60
1342708Swollman#define HOURSPERDAY	24
1352708Swollman#define DAYSPERWEEK	7
1362708Swollman#define DAYSPERNYEAR	365
1372708Swollman#define DAYSPERLYEAR	366
1382708Swollman#define SECSPERHOUR	(SECSPERMIN * MINSPERHOUR)
1392708Swollman#define SECSPERDAY	((long) SECSPERHOUR * HOURSPERDAY)
1402708Swollman#define MONSPERYEAR	12
1412708Swollman
1422708Swollman#define TM_SUNDAY	0
1432708Swollman#define TM_MONDAY	1
1442708Swollman#define TM_TUESDAY	2
1452708Swollman#define TM_WEDNESDAY	3
1462708Swollman#define TM_THURSDAY	4
1472708Swollman#define TM_FRIDAY	5
1482708Swollman#define TM_SATURDAY	6
1492708Swollman
1502708Swollman#define TM_JANUARY	0
1512708Swollman#define TM_FEBRUARY	1
1522708Swollman#define TM_MARCH	2
1532708Swollman#define TM_APRIL	3
1542708Swollman#define TM_MAY		4
1552708Swollman#define TM_JUNE		5
1562708Swollman#define TM_JULY		6
1572708Swollman#define TM_AUGUST	7
1582708Swollman#define TM_SEPTEMBER	8
1592708Swollman#define TM_OCTOBER	9
1602708Swollman#define TM_NOVEMBER	10
1612708Swollman#define TM_DECEMBER	11
1622708Swollman
1632708Swollman#define TM_YEAR_BASE	1900
1642708Swollman
1652708Swollman#define EPOCH_YEAR	1970
1662708Swollman#define EPOCH_WDAY	TM_THURSDAY
1672708Swollman
16817209Swollman#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
1692708Swollman
1702708Swollman/*
171192625Sedwin** Since everything in isleap is modulo 400 (or a factor of 400), we know that
172192625Sedwin**	isleap(y) == isleap(y % 400)
173192625Sedwin** and so
174192625Sedwin**	isleap(a + b) == isleap((a + b) % 400)
175192625Sedwin** or
176192625Sedwin**	isleap(a + b) == isleap(a % 400 + b % 400)
177192625Sedwin** This is true even if % means modulo rather than Fortran remainder
178192625Sedwin** (which is allowed by C89 but not C99).
179192625Sedwin** We use this to avoid addition overflow problems.
1802708Swollman*/
1812708Swollman
182192625Sedwin#define isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)
1832708Swollman
1842708Swollman#endif /* !defined TZFILE_H */
185