xref: /illumos-gate/usr/src/head/tzfile.h (revision 80868c5387b92f32fe0e8ea709e36cb535287e03)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*80868c53Srobbin  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef _TZFILE_H
317c478bd9Sstevel@tonic-gate #define	_TZFILE_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * A part of this file comes from public domain source, so
377c478bd9Sstevel@tonic-gate  * clarified as of June 5, 1996 by Arthur David Olson
387c478bd9Sstevel@tonic-gate  * (arthur_david_olson@nih.gov).
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <sys/types.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * WARNING:
457c478bd9Sstevel@tonic-gate  * The interfaces defined in this header file are for Sun private use only.
467c478bd9Sstevel@tonic-gate  * The contents of this file are subject to change without notice for the
477c478bd9Sstevel@tonic-gate  * future releases.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /* For further information, see ctime(3C) and zic(1M) man pages. */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * This file is in the public domain, so clarified as of
547c478bd9Sstevel@tonic-gate  * June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * This header is for use ONLY with the time conversion code.
597c478bd9Sstevel@tonic-gate  * There is no guarantee that it will remain unchanged,
607c478bd9Sstevel@tonic-gate  * or that it will remain at all.
617c478bd9Sstevel@tonic-gate  * Do NOT copy it to any system include directory.
627c478bd9Sstevel@tonic-gate  * Thank you!
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate 
65*80868c53Srobbin /* static char	tzfilehid[] = "@(#)tzfile.h	7.17"; */
66*80868c53Srobbin 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * Note: Despite warnings from the authors of this code, Solaris has
697c478bd9Sstevel@tonic-gate  * placed this header file in the system include directory.  This was
707c478bd9Sstevel@tonic-gate  * probably done in order to build both zic and zdump which are in
717c478bd9Sstevel@tonic-gate  * separate source directories, but both use this file.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
757c478bd9Sstevel@tonic-gate extern "C" {
767c478bd9Sstevel@tonic-gate #endif
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * Information about time zone files.
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #ifndef TZDIR
837c478bd9Sstevel@tonic-gate #define	TZDIR	"/usr/share/lib/zoneinfo" /* Time zone object file directory */
847c478bd9Sstevel@tonic-gate #endif /* !defined TZDIR */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate #ifndef TZDEFAULT
877c478bd9Sstevel@tonic-gate #define	TZDEFAULT	"localtime"
887c478bd9Sstevel@tonic-gate #endif /* !defined TZDEFAULT */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #ifndef TZDEFRULES
917c478bd9Sstevel@tonic-gate #define	TZDEFRULES	"posixrules"
927c478bd9Sstevel@tonic-gate #endif /* !defined TZDEFRULES */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Each file begins with. . .
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #define	TZ_MAGIC	"TZif"
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate struct tzhead {
1017c478bd9Sstevel@tonic-gate 	char	tzh_magic[4];		/* TZ_MAGIC */
1027c478bd9Sstevel@tonic-gate 	char	tzh_reserved[16];	/* reserved for future use */
1037c478bd9Sstevel@tonic-gate 	char	tzh_ttisgmtcnt[4];	/* coded number of trans. time flags */
1047c478bd9Sstevel@tonic-gate 	char	tzh_ttisstdcnt[4];	/* coded number of trans. time flags */
1057c478bd9Sstevel@tonic-gate 	char	tzh_leapcnt[4];		/* coded number of leap seconds */
1067c478bd9Sstevel@tonic-gate 	char	tzh_timecnt[4];		/* coded number of transition times */
1077c478bd9Sstevel@tonic-gate 	char	tzh_typecnt[4];		/* coded number of local time types */
1087c478bd9Sstevel@tonic-gate 	char	tzh_charcnt[4];		/* coded number of abbr. chars */
1097c478bd9Sstevel@tonic-gate };
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /*
1127c478bd9Sstevel@tonic-gate  * . . .followed by. . .
1137c478bd9Sstevel@tonic-gate  *
1147c478bd9Sstevel@tonic-gate  *	tzh_timecnt (char [4])s		coded transition times a la time(2)
1157c478bd9Sstevel@tonic-gate  *	tzh_timecnt (unsigned char)s	types of local time starting at above
1167c478bd9Sstevel@tonic-gate  *	tzh_typecnt repetitions of
1177c478bd9Sstevel@tonic-gate  *		one (char [4])		coded UTC offset in seconds
1187c478bd9Sstevel@tonic-gate  *		one (unsigned char)	used to set tm_isdst
1197c478bd9Sstevel@tonic-gate  *		one (unsigned char)	that's an abbreviation list index
1207c478bd9Sstevel@tonic-gate  *	tzh_charcnt (char)s		'\0'-terminated zone abbreviations
1217c478bd9Sstevel@tonic-gate  *	tzh_leapcnt repetitions of
1227c478bd9Sstevel@tonic-gate  *		one (char [4])		coded leap second transition times
1237c478bd9Sstevel@tonic-gate  *		one (char [4])		total correction after above
1247c478bd9Sstevel@tonic-gate  *	tzh_ttisstdcnt (char)s		indexed by type; if TRUE, transition
1257c478bd9Sstevel@tonic-gate  *					time is standard time, if FALSE,
1267c478bd9Sstevel@tonic-gate  *					transition time is wall clock time
1277c478bd9Sstevel@tonic-gate  *					if absent, transition times are
1287c478bd9Sstevel@tonic-gate  *					assumed to be wall clock time
1297c478bd9Sstevel@tonic-gate  *	tzh_ttisgmtcnt (char)s		indexed by type; if TRUE, transition
1307c478bd9Sstevel@tonic-gate  *					time is UTC, if FALSE,
1317c478bd9Sstevel@tonic-gate  *					transition time is local time
1327c478bd9Sstevel@tonic-gate  *					if absent, transition times are
1337c478bd9Sstevel@tonic-gate  *					assumed to be local time
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /*
1377c478bd9Sstevel@tonic-gate  * In the current implementation, "tzset()" refuses to deal with files that
1387c478bd9Sstevel@tonic-gate  * exceed any of the limits below.
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #ifndef TZ_MAX_TIMES
1427c478bd9Sstevel@tonic-gate /*
1437c478bd9Sstevel@tonic-gate  * The TZ_MAX_TIMES value below is enough to handle a bit more than a
1447c478bd9Sstevel@tonic-gate  * year's worth of solar time (corrected daily to the nearest second) or
1457c478bd9Sstevel@tonic-gate  * 138 years of Pacific Presidential Election time
1467c478bd9Sstevel@tonic-gate  * (where there are three time zone transitions every fourth year).
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate #define	TZ_MAX_TIMES	370
1497c478bd9Sstevel@tonic-gate #endif /* !defined TZ_MAX_TIMES */
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #ifndef TZ_MAX_TYPES
1527c478bd9Sstevel@tonic-gate #ifndef NOSOLAR
1537c478bd9Sstevel@tonic-gate #define	TZ_MAX_TYPES	256 /* Limited by what (unsigned char)'s can hold */
1547c478bd9Sstevel@tonic-gate #endif /* !defined NOSOLAR */
1557c478bd9Sstevel@tonic-gate #ifdef NOSOLAR
1567c478bd9Sstevel@tonic-gate /*
1577c478bd9Sstevel@tonic-gate  * Must be at least 14 for Europe/Riga as of Jan 12 1995,
1587c478bd9Sstevel@tonic-gate  * as noted by Earl Chew <earl@hpato.aus.hp.com>.
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate #define	TZ_MAX_TYPES	20	/* Maximum number of local time types */
1617c478bd9Sstevel@tonic-gate #endif /* !defined NOSOLAR */
1627c478bd9Sstevel@tonic-gate #endif /* !defined TZ_MAX_TYPES */
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate #ifndef TZ_MAX_CHARS
1657c478bd9Sstevel@tonic-gate #define	TZ_MAX_CHARS	50	/* Maximum number of abbreviation characters */
1667c478bd9Sstevel@tonic-gate 				/* (limited by what unsigned chars can hold) */
1677c478bd9Sstevel@tonic-gate #endif /* !defined TZ_MAX_CHARS */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate #ifndef TZ_MAX_LEAPS
1707c478bd9Sstevel@tonic-gate #define	TZ_MAX_LEAPS	50	/* Maximum number of leap second corrections */
1717c478bd9Sstevel@tonic-gate #endif /* !defined TZ_MAX_LEAPS */
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #define	SECSPERMIN	60
1747c478bd9Sstevel@tonic-gate #define	MINSPERHOUR	60
1757c478bd9Sstevel@tonic-gate #define	HOURSPERDAY	24
1767c478bd9Sstevel@tonic-gate #define	DAYSPERWEEK	7
1777c478bd9Sstevel@tonic-gate #define	DAYSPERNYEAR	365
1787c478bd9Sstevel@tonic-gate #define	DAYSPERLYEAR	366
1797c478bd9Sstevel@tonic-gate #define	SECSPERHOUR	(SECSPERMIN * MINSPERHOUR)
1807c478bd9Sstevel@tonic-gate #define	SECSPERDAY	((time_t)SECSPERHOUR * HOURSPERDAY)
1817c478bd9Sstevel@tonic-gate #define	MONSPERYEAR	12
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate #define	TM_SUNDAY	0
1847c478bd9Sstevel@tonic-gate #define	TM_MONDAY	1
1857c478bd9Sstevel@tonic-gate #define	TM_TUESDAY	2
1867c478bd9Sstevel@tonic-gate #define	TM_WEDNESDAY	3
1877c478bd9Sstevel@tonic-gate #define	TM_THURSDAY	4
1887c478bd9Sstevel@tonic-gate #define	TM_FRIDAY	5
1897c478bd9Sstevel@tonic-gate #define	TM_SATURDAY	6
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate #define	TM_JANUARY	0
1927c478bd9Sstevel@tonic-gate #define	TM_FEBRUARY	1
1937c478bd9Sstevel@tonic-gate #define	TM_MARCH	2
1947c478bd9Sstevel@tonic-gate #define	TM_APRIL	3
1957c478bd9Sstevel@tonic-gate #define	TM_MAY		4
1967c478bd9Sstevel@tonic-gate #define	TM_JUNE		5
1977c478bd9Sstevel@tonic-gate #define	TM_JULY		6
1987c478bd9Sstevel@tonic-gate #define	TM_AUGUST	7
1997c478bd9Sstevel@tonic-gate #define	TM_SEPTEMBER	8
2007c478bd9Sstevel@tonic-gate #define	TM_OCTOBER	9
2017c478bd9Sstevel@tonic-gate #define	TM_NOVEMBER	10
2027c478bd9Sstevel@tonic-gate #define	TM_DECEMBER	11
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate #define	TM_YEAR_BASE	1900
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #define	EPOCH_YEAR	1970
2077c478bd9Sstevel@tonic-gate #define	EPOCH_WDAY	TM_THURSDAY
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate #define	isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate #ifndef USG
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate /*
2147c478bd9Sstevel@tonic-gate  * Use of the underscored variants may cause problems if you move your code to
2157c478bd9Sstevel@tonic-gate  * certain System-V-based systems; for maximum portability, use the
2167c478bd9Sstevel@tonic-gate  * underscore-free variants.  The underscored variants are provided for
2177c478bd9Sstevel@tonic-gate  * backward compatibility only; they may disappear from future versions of
2187c478bd9Sstevel@tonic-gate  * this file.
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate #define	SECS_PER_MIN	SECSPERMIN
2227c478bd9Sstevel@tonic-gate #define	MINS_PER_HOUR	MINSPERHOUR
2237c478bd9Sstevel@tonic-gate #define	HOURS_PER_DAY	HOURSPERDAY
2247c478bd9Sstevel@tonic-gate #define	DAYS_PER_WEEK	DAYSPERWEEK
2257c478bd9Sstevel@tonic-gate #define	DAYS_PER_NYEAR	DAYSPERNYEAR
2267c478bd9Sstevel@tonic-gate #define	DAYS_PER_LYEAR	DAYSPERLYEAR
2277c478bd9Sstevel@tonic-gate #define	SECS_PER_HOUR	SECSPERHOUR
2287c478bd9Sstevel@tonic-gate #define	SECS_PER_DAY	SECSPERDAY
2297c478bd9Sstevel@tonic-gate #define	MONS_PER_YEAR	MONSPERYEAR
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate #endif /* !defined USG */
2327c478bd9Sstevel@tonic-gate 
233*80868c53Srobbin /*
234*80868c53Srobbin  * Since everything in isleap is modulo 400 (or a factor of 400), we know that
235*80868c53Srobbin  *	isleap(y) == isleap(y % 400)
236*80868c53Srobbin  * and so
237*80868c53Srobbin  *	isleap(a + b) == isleap((a + b) % 400)
238*80868c53Srobbin  * or
239*80868c53Srobbin  *	isleap(a + b) == isleap(a % 400 + b % 400)
240*80868c53Srobbin  * This is true even if % means modulo rather than Fortran remainder
241*80868c53Srobbin  * (which is allowed by C89 but not C99).
242*80868c53Srobbin  * We use this to avoid addition overflow problems.
243*80868c53Srobbin  */
244*80868c53Srobbin 
245*80868c53Srobbin #define	isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)
246*80868c53Srobbin 
2477c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2487c478bd9Sstevel@tonic-gate }
2497c478bd9Sstevel@tonic-gate #endif
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate #endif	/* _TZFILE_H */
252