Commit 0a19fb42 authored by Bruce Momjian's avatar Bruce Momjian

Pgindent timezone file, per request from Tom.

parent 63bd0db1
...@@ -5,54 +5,63 @@ ...@@ -5,54 +5,63 @@
#define nonzero(n) (((n) == 0) ? 1 : (n)) #define nonzero(n) (((n) == 0) ? 1 : (n))
char *imalloc(const int n) char *
imalloc(const int n)
{ {
return malloc((size_t) nonzero(n)); return malloc((size_t) nonzero(n));
} }
char *icalloc(int nelem, int elsize) char *
icalloc(int nelem, int elsize)
{ {
if (nelem == 0 || elsize == 0) if (nelem == 0 || elsize == 0)
nelem = elsize = 1; nelem = elsize = 1;
return calloc((size_t) nelem, (size_t) elsize); return calloc((size_t) nelem, (size_t) elsize);
} }
void *irealloc(void *pointer, const int size) void *
irealloc(void *pointer, const int size)
{ {
if (pointer == NULL) if (pointer == NULL)
return imalloc(size); return imalloc(size);
return realloc((void *) pointer, (size_t) nonzero(size)); return realloc((void *) pointer, (size_t) nonzero(size));
} }
char *icatalloc(char *old, const char *new) char *
icatalloc(char *old, const char *new)
{ {
register char * result; register char *result;
register int oldsize, newsize; register int oldsize,
newsize;
newsize = (new == NULL) ? 0 : strlen(new); newsize = (new == NULL) ? 0 : strlen(new);
if (old == NULL) if (old == NULL)
oldsize = 0; oldsize = 0;
else if (newsize == 0) else if (newsize == 0)
return old; return old;
else oldsize = strlen(old); else
oldsize = strlen(old);
if ((result = irealloc(old, oldsize + newsize + 1)) != NULL) if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
if (new != NULL) if (new != NULL)
(void) strcpy(result + oldsize, new); (void) strcpy(result + oldsize, new);
return result; return result;
} }
char *icpyalloc(const char *string) char *
icpyalloc(const char *string)
{ {
return icatalloc((char *) NULL, string); return icatalloc((char *) NULL, string);
} }
void ifree(char *p) void
ifree(char *p)
{ {
if (p != NULL) if (p != NULL)
(void) free(p); (void) free(p);
} }
void icfree(char *p) void
icfree(char *p)
{ {
if (p != NULL) if (p != NULL)
(void) free(p); (void) free(p);
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.10 2004/05/21 05:08:06 tgl Exp $ * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.11 2004/05/21 12:30:25 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -45,36 +45,46 @@ pg_TZDIR(void) ...@@ -45,36 +45,46 @@ pg_TZDIR(void)
* set in our own library). * set in our own library).
*/ */
#define T_YEAR (60*60*24*365) #define T_YEAR (60*60*24*365)
#define T_MONTH (60*60*24*30) #define T_MONTH (60*60*24*30)
struct tztry { struct tztry
time_t std_t,dst_t; {
char std_time[TZ_STRLEN_MAX+1],dst_time[TZ_STRLEN_MAX+1]; time_t std_t,
int std_ofs,dst_ofs; dst_t;
struct tm std_tm, dst_tm; char std_time[TZ_STRLEN_MAX + 1],
dst_time[TZ_STRLEN_MAX + 1];
int std_ofs,
dst_ofs;
struct tm std_tm,
dst_tm;
}; };
static bool compare_tm(struct tm *s, struct pg_tm *p) { static bool
if (s->tm_sec != p->tm_sec || compare_tm(struct tm * s, struct pg_tm * p)
s->tm_min != p->tm_min || {
s->tm_hour != p->tm_hour || if (s->tm_sec != p->tm_sec ||
s->tm_mday != p->tm_mday || s->tm_min != p->tm_min ||
s->tm_mon != p->tm_mon || s->tm_hour != p->tm_hour ||
s->tm_year != p->tm_year || s->tm_mday != p->tm_mday ||
s->tm_wday != p->tm_wday || s->tm_mon != p->tm_mon ||
s->tm_yday != p->tm_yday || s->tm_year != p->tm_year ||
s->tm_wday != p->tm_wday ||
s->tm_yday != p->tm_yday ||
s->tm_isdst != p->tm_isdst) s->tm_isdst != p->tm_isdst)
return false; return false;
return true; return true;
} }
static bool try_timezone(char *tzname, struct tztry *tt, bool checkdst) { static bool
try_timezone(char *tzname, struct tztry * tt, bool checkdst)
{
struct pg_tm *pgtm; struct pg_tm *pgtm;
if (!pg_tzset(tzname)) if (!pg_tzset(tzname))
return false; /* If this timezone couldn't be picked at all */ return false; /* If this timezone couldn't be picked at
* all */
/* Verify standard time */ /* Verify standard time */
pgtm = pg_localtime(&(tt->std_t)); pgtm = pg_localtime(&(tt->std_t));
if (!pgtm) if (!pgtm)
...@@ -95,7 +105,9 @@ static bool try_timezone(char *tzname, struct tztry *tt, bool checkdst) { ...@@ -95,7 +105,9 @@ static bool try_timezone(char *tzname, struct tztry *tt, bool checkdst) {
return true; return true;
} }
static int get_timezone_offset(struct tm *tm) { static int
get_timezone_offset(struct tm * tm)
{
#if defined(HAVE_STRUCT_TM_TM_ZONE) #if defined(HAVE_STRUCT_TM_TM_ZONE)
return tm->tm_gmtoff; return tm->tm_gmtoff;
#elif defined(HAVE_INT_TIMEZONE) #elif defined(HAVE_INT_TIMEZONE)
...@@ -113,12 +125,15 @@ static int get_timezone_offset(struct tm *tm) { ...@@ -113,12 +125,15 @@ static int get_timezone_offset(struct tm *tm) {
#ifdef WIN32 #ifdef WIN32
#define TZABBREV(tz) win32_get_timezone_abbrev(tz) #define TZABBREV(tz) win32_get_timezone_abbrev(tz)
static char *win32_get_timezone_abbrev(char *tz) { static char *
static char w32tzabbr[TZ_STRLEN_MAX+1]; win32_get_timezone_abbrev(char *tz)
int l = 0; {
char *c; static char w32tzabbr[TZ_STRLEN_MAX + 1];
int l = 0;
char *c;
for (c = tz; *c; c++) { for (c = tz; *c; c++)
{
if (isupper(*c)) if (isupper(*c))
w32tzabbr[l++] = *c; w32tzabbr[l++] = *c;
} }
...@@ -140,47 +155,50 @@ static char *win32_get_timezone_abbrev(char *tz) { ...@@ -140,47 +155,50 @@ static char *win32_get_timezone_abbrev(char *tz) {
static char * static char *
identify_system_timezone(void) identify_system_timezone(void)
{ {
static char __tzbuf[TZ_STRLEN_MAX+1]; static char __tzbuf[TZ_STRLEN_MAX + 1];
bool std_found=false, bool std_found = false,
dst_found=false; dst_found = false;
time_t tnow = time(NULL); time_t tnow = time(NULL);
time_t t; time_t t;
struct tztry tt; struct tztry tt;
char cbuf[TZ_STRLEN_MAX+1]; char cbuf[TZ_STRLEN_MAX + 1];
/* Initialize OS timezone library */ /* Initialize OS timezone library */
tzset(); tzset();
memset(&tt, 0, sizeof(tt)); memset(&tt, 0, sizeof(tt));
for (t = tnow; t < tnow+T_YEAR; t += T_MONTH) {
struct tm *tm = localtime(&t);
if (tm->tm_isdst == 0 && !std_found) { for (t = tnow; t < tnow + T_YEAR; t += T_MONTH)
{
struct tm *tm = localtime(&t);
if (tm->tm_isdst == 0 && !std_found)
{
/* Standard time */ /* Standard time */
memcpy(&tt.std_tm, tm, sizeof(struct tm)); memcpy(&tt.std_tm, tm, sizeof(struct tm));
memset(cbuf,0,sizeof(cbuf)); memset(cbuf, 0, sizeof(cbuf));
strftime(cbuf, sizeof(cbuf)-1, "%Z", tm); /* zone abbr */ strftime(cbuf, sizeof(cbuf) - 1, "%Z", tm); /* zone abbr */
strcpy(tt.std_time, TZABBREV(cbuf)); strcpy(tt.std_time, TZABBREV(cbuf));
tt.std_ofs = get_timezone_offset(tm); tt.std_ofs = get_timezone_offset(tm);
tt.std_t = t; tt.std_t = t;
std_found = true; std_found = true;
} }
else if (tm->tm_isdst == 1 && !dst_found) { else if (tm->tm_isdst == 1 && !dst_found)
{
/* Daylight time */ /* Daylight time */
memcpy(&tt.dst_tm, tm, sizeof(struct tm)); memcpy(&tt.dst_tm, tm, sizeof(struct tm));
memset(cbuf,0,sizeof(cbuf)); memset(cbuf, 0, sizeof(cbuf));
strftime(cbuf, sizeof(cbuf)-1, "%Z", tm); /* zone abbr */ strftime(cbuf, sizeof(cbuf) - 1, "%Z", tm); /* zone abbr */
strcpy(tt.dst_time, TZABBREV(cbuf)); strcpy(tt.dst_time, TZABBREV(cbuf));
tt.dst_ofs = get_timezone_offset(tm); tt.dst_ofs = get_timezone_offset(tm);
tt.dst_t = t; tt.dst_t = t;
dst_found = true; dst_found = true;
} }
if (std_found && dst_found) if (std_found && dst_found)
break; /* Got both standard and daylight */ break; /* Got both standard and daylight */
} }
if (!std_found) if (!std_found)
{ {
/* Failed to determine TZ! */ /* Failed to determine TZ! */
ereport(LOG, ereport(LOG,
...@@ -189,24 +207,25 @@ identify_system_timezone(void) ...@@ -189,24 +207,25 @@ identify_system_timezone(void)
return NULL; /* go to GMT */ return NULL; /* go to GMT */
} }
if (dst_found) { if (dst_found)
{
/* Try STD<ofs>DST */ /* Try STD<ofs>DST */
sprintf(__tzbuf,"%s%d%s",tt.std_time,-tt.std_ofs/3600,tt.dst_time); sprintf(__tzbuf, "%s%d%s", tt.std_time, -tt.std_ofs / 3600, tt.dst_time);
if (try_timezone(__tzbuf, &tt, dst_found)) if (try_timezone(__tzbuf, &tt, dst_found))
return __tzbuf; return __tzbuf;
} }
/* Try just the STD timezone */ /* Try just the STD timezone */
strcpy(__tzbuf,tt.std_time); strcpy(__tzbuf, tt.std_time);
if (try_timezone(__tzbuf, &tt, dst_found)) if (try_timezone(__tzbuf, &tt, dst_found))
return __tzbuf; return __tzbuf;
/* Did not find the timezone. Fallback to try a GMT zone. */ /* Did not find the timezone. Fallback to try a GMT zone. */
sprintf(__tzbuf,"Etc/GMT%s%d", sprintf(__tzbuf, "Etc/GMT%s%d",
(-tt.std_ofs<0)?"+":"",tt.std_ofs/3600); (-tt.std_ofs < 0) ? "+" : "", tt.std_ofs / 3600);
ereport(LOG, ereport(LOG,
(errmsg("could not recognize system timezone, defaulting to \"%s\"", (errmsg("could not recognize system timezone, defaulting to \"%s\"",
__tzbuf), __tzbuf),
errhint("You can specify the correct timezone in postgresql.conf."))); errhint("You can specify the correct timezone in postgresql.conf.")));
return __tzbuf; return __tzbuf;
} }
...@@ -223,7 +242,7 @@ identify_system_timezone(void) ...@@ -223,7 +242,7 @@ identify_system_timezone(void)
bool bool
tz_acceptable(void) tz_acceptable(void)
{ {
struct pg_tm tt; struct pg_tm tt;
time_t time2000; time_t time2000;
/* /*
...@@ -255,7 +274,7 @@ tz_acceptable(void) ...@@ -255,7 +274,7 @@ tz_acceptable(void)
const char * const char *
select_default_timezone(void) select_default_timezone(void)
{ {
char *def_tz; char *def_tz;
def_tz = getenv("TZ"); def_tz = getenv("TZ");
if (def_tz && pg_tzset(def_tz) && tz_acceptable()) if (def_tz && pg_tzset(def_tz) && tz_acceptable())
...@@ -280,9 +299,12 @@ select_default_timezone(void) ...@@ -280,9 +299,12 @@ select_default_timezone(void)
* This is called after initial loading of postgresql.conf. If no TimeZone * This is called after initial loading of postgresql.conf. If no TimeZone
* setting was found therein, we try to derive one from the environment. * setting was found therein, we try to derive one from the environment.
*/ */
void pg_timezone_initialize(void) { void
pg_timezone_initialize(void)
{
/* Do we need to try to figure the timezone? */ /* Do we need to try to figure the timezone? */
if (strcmp(GetConfigOption("timezone"), "UNKNOWN") == 0) { if (strcmp(GetConfigOption("timezone"), "UNKNOWN") == 0)
{
const char *def_tz; const char *def_tz;
/* Select setting */ /* Select setting */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/timezone/pgtz.h,v 1.7 2004/05/21 05:08:06 tgl Exp $ * $PostgreSQL: pgsql/src/timezone/pgtz.h,v 1.8 2004/05/21 12:30:25 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
#define TZ_STRLEN_MAX 255 #define TZ_STRLEN_MAX 255
extern char *pg_TZDIR(void); extern char *pg_TZDIR(void);
#endif /* _PGTZ_H */ #endif /* _PGTZ_H */
...@@ -14,19 +14,19 @@ ...@@ -14,19 +14,19 @@
** Thank you! ** Thank you!
*/ */
#include <limits.h> /* for CHAR_BIT */ #include <limits.h> /* for CHAR_BIT */
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */ #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
#include <unistd.h> /* for F_OK and R_OK */ #include <unistd.h> /* for F_OK and R_OK */
#include "pgtime.h" #include "pgtime.h"
#ifndef WIFEXITED #ifndef WIFEXITED
#define WIFEXITED(status) (((status) & 0xff) == 0) #define WIFEXITED(status) (((status) & 0xff) == 0)
#endif /* !defined WIFEXITED */ #endif /* !defined WIFEXITED */
#ifndef WEXITSTATUS #ifndef WEXITSTATUS
#define WEXITSTATUS(status) (((status) >> 8) & 0xff) #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
#endif /* !defined WEXITSTATUS */ #endif /* !defined WEXITSTATUS */
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9) #define is_digit(c) ((unsigned)(c) - '0' <= 9)
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#ifndef EXIT_SUCCESS #ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0 #define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */ #endif /* !defined EXIT_SUCCESS */
/* /*
** SunOS 4.1.1 headers lack EXIT_FAILURE. ** SunOS 4.1.1 headers lack EXIT_FAILURE.
...@@ -45,28 +45,29 @@ ...@@ -45,28 +45,29 @@
#ifndef EXIT_FAILURE #ifndef EXIT_FAILURE
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
#endif /* !defined EXIT_FAILURE */ #endif /* !defined EXIT_FAILURE */
/* /*
** SunOS 4.1.1 libraries lack remove. ** SunOS 4.1.1 libraries lack remove.
*/ */
#ifndef remove #ifndef remove
extern int unlink (const char * filename); extern int unlink(const char *filename);
#define remove unlink #define remove unlink
#endif /* !defined remove */ #endif /* !defined remove */
/* /*
* Private function declarations. * Private function declarations.
*/ */
extern char *icalloc (int nelem, int elsize); extern char *icalloc(int nelem, int elsize);
extern char *icatalloc (char *old, const char *new); extern char *icatalloc(char *old, const char *new);
extern char *icpyalloc (const char *string); extern char *icpyalloc(const char *string);
extern char *imalloc (int n); extern char *imalloc(int n);
extern void *irealloc (void *pointer, int size); extern void *irealloc(void *pointer, int size);
extern void icfree (char *pointer); extern void icfree(char *pointer);
extern void ifree (char *pointer); extern void ifree(char *pointer);
extern char *scheck (const char *string, const char *format); extern char *scheck(const char *string, const char *format);
/* /*
...@@ -75,19 +76,19 @@ extern char *scheck (const char *string, const char *format); ...@@ -75,19 +76,19 @@ extern char *scheck (const char *string, const char *format);
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#endif /* !defined TRUE */ #endif /* !defined TRUE */
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif /* !defined FALSE */ #endif /* !defined FALSE */
#ifndef TYPE_BIT #ifndef TYPE_BIT
#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
#endif /* !defined TYPE_BIT */ #endif /* !defined TYPE_BIT */
#ifndef TYPE_SIGNED #ifndef TYPE_SIGNED
#define TYPE_SIGNED(type) (((type) -1) < 0) #define TYPE_SIGNED(type) (((type) -1) < 0)
#endif /* !defined TYPE_SIGNED */ #endif /* !defined TYPE_SIGNED */
#ifndef INT_STRLEN_MAXIMUM #ifndef INT_STRLEN_MAXIMUM
/* /*
...@@ -97,8 +98,8 @@ extern char *scheck (const char *string, const char *format); ...@@ -97,8 +98,8 @@ extern char *scheck (const char *string, const char *format);
** add one more for a minus sign if the type is signed. ** add one more for a minus sign if the type is signed.
*/ */
#define INT_STRLEN_MAXIMUM(type) \ #define INT_STRLEN_MAXIMUM(type) \
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */ #endif /* !defined INT_STRLEN_MAXIMUM */
#define _(msgid) (msgid) #define _(msgid) (msgid)
...@@ -106,4 +107,4 @@ extern char *scheck (const char *string, const char *format); ...@@ -106,4 +107,4 @@ extern char *scheck (const char *string, const char *format);
** UNIX was a registered trademark of The Open Group in 2003. ** UNIX was a registered trademark of The Open Group in 2003.
*/ */
#endif /* !defined PRIVATE_H */ #endif /* !defined PRIVATE_H */
...@@ -3,15 +3,16 @@ ...@@ -3,15 +3,16 @@
#include "private.h" #include "private.h"
char *scheck(const char *string, const char *format) char *
scheck(const char *string, const char *format)
{ {
register char * fbuf; register char *fbuf;
register const char * fp; register const char *fp;
register char * tp; register char *tp;
register int c; register int c;
register char * result; register char *result;
char dummy; char dummy;
static char nada; static char nada;
result = &nada; result = &nada;
if (string == NULL || format == NULL) if (string == NULL || format == NULL)
...@@ -21,10 +22,12 @@ char *scheck(const char *string, const char *format) ...@@ -21,10 +22,12 @@ char *scheck(const char *string, const char *format)
return result; return result;
fp = format; fp = format;
tp = fbuf; tp = fbuf;
while ((*tp++ = c = *fp++) != '\0') { while ((*tp++ = c = *fp++) != '\0')
{
if (c != '%') if (c != '%')
continue; continue;
if (*fp == '%') { if (*fp == '%')
{
*tp++ = *fp++; *tp++ = *fp++;
continue; continue;
} }
...@@ -36,8 +39,9 @@ char *scheck(const char *string, const char *format) ...@@ -36,8 +39,9 @@ char *scheck(const char *string, const char *format)
if (*fp == 'l' || *fp == 'h') if (*fp == 'l' || *fp == 'h')
*tp++ = *fp++; *tp++ = *fp++;
else if (*fp == '[') else if (*fp == '[')
do *tp++ = *fp++; do
while (*fp != '\0' && *fp != ']'); *tp++ = *fp++;
while (*fp != '\0' && *fp != ']');
if ((*tp++ = *fp++) == '\0') if ((*tp++ = *fp++) == '\0')
break; break;
} }
......
This diff is collapsed.
...@@ -26,17 +26,20 @@ ...@@ -26,17 +26,20 @@
** Each file begins with. . . ** Each file begins with. . .
*/ */
#define TZ_MAGIC "TZif" #define TZ_MAGIC "TZif"
struct tzhead { struct tzhead
char tzh_magic[4]; /* TZ_MAGIC */ {
char tzh_reserved[16]; /* reserved for future use */ char tzh_magic[4]; /* TZ_MAGIC */
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ char tzh_reserved[16]; /* reserved for future use */
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ char tzh_ttisgmtcnt[4]; /* coded number of trans. time
char tzh_leapcnt[4]; /* coded number of leap seconds */ * flags */
char tzh_timecnt[4]; /* coded number of transition times */ char tzh_ttisstdcnt[4]; /* coded number of trans. time
char tzh_typecnt[4]; /* coded number of local time types */ * flags */
char tzh_charcnt[4]; /* coded number of abbr. chars */ char tzh_leapcnt[4]; /* coded number of leap seconds */
char tzh_timecnt[4]; /* coded number of transition times */
char tzh_typecnt[4]; /* coded number of local time types */
char tzh_charcnt[4]; /* coded number of abbr. chars */
}; };
/* /*
...@@ -46,8 +49,8 @@ struct tzhead { ...@@ -46,8 +49,8 @@ struct tzhead {
** tzh_timecnt (unsigned char)s types of local time starting at above ** tzh_timecnt (unsigned char)s types of local time starting at above
** tzh_typecnt repetitions of ** tzh_typecnt repetitions of
** one (char [4]) coded UTC offset in seconds ** one (char [4]) coded UTC offset in seconds
** one (unsigned char) used to set tm_isdst ** one (unsigned char) used to set tm_isdst
** one (unsigned char) that's an abbreviation list index ** one (unsigned char) that's an abbreviation list index
** tzh_charcnt (char)s '\0'-terminated zone abbreviations ** tzh_charcnt (char)s '\0'-terminated zone abbreviations
** tzh_leapcnt repetitions of ** tzh_leapcnt repetitions of
** one (char [4]) coded leap second transition times ** one (char [4]) coded leap second transition times
...@@ -77,33 +80,36 @@ struct tzhead { ...@@ -77,33 +80,36 @@ struct tzhead {
*/ */
#define TZ_MAX_TIMES 370 #define TZ_MAX_TIMES 370
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can
* hold */
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation
/* (limited by what unsigned chars can hold) */ * characters */
/* (limited by what unsigned chars can hold) */
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ #define TZ_MAX_LEAPS 50 /* Maximum number of leap second
* corrections */
#define SECSPERMIN 60 #define SECSPERMIN 60
#define MINSPERHOUR 60 #define MINSPERHOUR 60
#define HOURSPERDAY 24 #define HOURSPERDAY 24
#define DAYSPERWEEK 7 #define DAYSPERWEEK 7
#define DAYSPERNYEAR 365 #define DAYSPERNYEAR 365
#define DAYSPERLYEAR 366 #define DAYSPERLYEAR 366
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
#define MONSPERYEAR 12 #define MONSPERYEAR 12
#define TM_SUNDAY 0 #define TM_SUNDAY 0
#define TM_MONDAY 1 #define TM_MONDAY 1
#define TM_TUESDAY 2 #define TM_TUESDAY 2
#define TM_WEDNESDAY 3 #define TM_WEDNESDAY 3
#define TM_THURSDAY 4 #define TM_THURSDAY 4
#define TM_FRIDAY 5 #define TM_FRIDAY 5
#define TM_SATURDAY 6 #define TM_SATURDAY 6
#define TM_JANUARY 0 #define TM_JANUARY 0
#define TM_FEBRUARY 1 #define TM_FEBRUARY 1
#define TM_MARCH 2 #define TM_MARCH 2
#define TM_APRIL 3 #define TM_APRIL 3
#define TM_MAY 4 #define TM_MAY 4
...@@ -112,8 +118,8 @@ struct tzhead { ...@@ -112,8 +118,8 @@ struct tzhead {
#define TM_AUGUST 7 #define TM_AUGUST 7
#define TM_SEPTEMBER 8 #define TM_SEPTEMBER 8
#define TM_OCTOBER 9 #define TM_OCTOBER 9
#define TM_NOVEMBER 10 #define TM_NOVEMBER 10
#define TM_DECEMBER 11 #define TM_DECEMBER 11
#define TM_YEAR_BASE 1900 #define TM_YEAR_BASE 1900
...@@ -127,4 +133,4 @@ struct tzhead { ...@@ -127,4 +133,4 @@ struct tzhead {
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
#endif /* !defined TZFILE_H */ #endif /* !defined TZFILE_H */
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment