14887Schin /***********************************************************************
24887Schin * *
34887Schin * This software is part of the ast package *
4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property *
54887Schin * and is licensed under the *
64887Schin * Common Public License, Version 1.0 *
78462SApril.Chin@Sun.COM * by AT&T Intellectual Property *
84887Schin * *
94887Schin * A copy of the License is available at *
104887Schin * http://www.opensource.org/licenses/cpl1.0.txt *
114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
124887Schin * *
134887Schin * Information and Software Systems Research *
144887Schin * AT&T Research *
154887Schin * Florham Park NJ *
164887Schin * *
174887Schin * Glenn Fowler <gsf@research.att.com> *
184887Schin * David Korn <dgk@research.att.com> *
194887Schin * Phong Vo <kpv@research.att.com> *
204887Schin * *
214887Schin ***********************************************************************/
224887Schin #pragma prototyped
234887Schin /*
244887Schin * Glenn Fowler
254887Schin * AT&T Research
264887Schin *
274887Schin * time_t conversion support
284887Schin */
294887Schin
304887Schin #include <tm.h>
314887Schin
324887Schin /*
334887Schin * use one of the 14 equivalent calendar years to determine
344887Schin * daylight savings time for future years beyond the range
3510898Sroland.mainz@nrubsig.org * of the local system (via tmxtm())
364887Schin */
374887Schin
384887Schin static const short equiv[] =
394887Schin {
404887Schin 2006, 2012,
414887Schin 2001, 2024,
424887Schin 2002, 2008,
434887Schin 2003, 2020,
444887Schin 2009, 2004,
454887Schin 2010, 2016,
464887Schin 2005, 2000,
474887Schin };
484887Schin
494887Schin /*
504887Schin * return the circa 2000 equivalent calendar year for tm
514887Schin */
524887Schin
534887Schin int
tmequiv(Tm_t * tm)544887Schin tmequiv(Tm_t* tm)
554887Schin {
564887Schin return tm->tm_year < (2038 - 1900) ? (tm->tm_year + 1900) : equiv[tm->tm_wday + tmisleapyear(tm->tm_year)];
574887Schin }
58