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