private/timezone.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * private/timezone.h - Timezone handling for time interpretation
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2010 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 2.1,
00014  * as published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  */
00025 
00026 #if !defined(_SPANDSP_PRIVATE_TIMEZONE_H_)
00027 #define _SPANDSP_PRIVATE_TIMEZONE_H_
00028 
00029 #define TZ_MAX_CHARS            50      /* Maximum number of abbreviation characters */
00030 
00031 #define TZ_MAX_LEAPS            50      /* Maximum number of leap second corrections */
00032 
00033 #define TZNAME_MAX              255
00034 
00035 /* The TZ_MAX_TIMES value below is enough to handle a bit more than a
00036  * year's worth of solar time (corrected daily to the nearest second) or
00037  * 138 years of Pacific Presidential Election time
00038  * (where there are three time zone transitions every fourth year). */
00039 #define TZ_MAX_TIMES            370
00040 
00041 #if !defined(NOSOLAR)
00042 #define TZ_MAX_TYPES            256     /* Limited by what (unsigned char)'s can hold */
00043 #else
00044 /* Must be at least 14 for Europe/Riga as of Jan 12 1995,
00045  * as noted by Earl Chew <earl@hpato.aus.hp.com>. */
00046 #define TZ_MAX_TYPES            20      /* Maximum number of local time types */
00047 #endif
00048 
00049 #define TZ_BIGGEST(a, b)        (((a) > (b)) ? (a) : (b))
00050 
00051 /* Time type information */
00052 struct tz_ttinfo_s
00053 {
00054     int32_t gmtoff;             /* UTC offset in seconds */
00055     int isdst;                  /* Used to set tm_isdst */
00056     int abbrind;                /* Abbreviation list index */
00057     int ttisstd;                /* TRUE if transition is std time */
00058     int ttisgmt;                /* TRUE if transition is UTC */
00059 };
00060 
00061 /* Leap second information */
00062 struct tz_lsinfo_s
00063 {
00064     time_t trans;               /* Transition time */
00065     int32_t corr;               /* Correction to apply */
00066 };
00067 
00068 struct tz_state_s
00069 {
00070     int leapcnt;
00071     int timecnt;
00072     int typecnt;
00073     int charcnt;
00074     time_t ats[TZ_MAX_TIMES];
00075     uint8_t types[TZ_MAX_TIMES];
00076     struct tz_ttinfo_s ttis[TZ_MAX_TYPES];
00077     char chars[TZ_BIGGEST(TZ_MAX_CHARS + 1, (2*(TZNAME_MAX + 1)))];
00078     struct tz_lsinfo_s lsis[TZ_MAX_LEAPS];
00079 };
00080 
00081 struct tz_s
00082 {
00083     struct tz_state_s state;
00084     char lcl_tzname[TZNAME_MAX + 1];
00085     int lcl_is_set;
00086     const char *tzname[2];
00087 };
00088 
00089 #endif
00090 /*- End of file ------------------------------------------------------------*/

Generated on Thu Dec 9 21:11:51 2010 for spandsp by  doxygen 1.5.9