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