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