Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/timezone.c view on Meta::CPAN
/*
Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* Replacement time library functions, based on platform independent public
* domain timezone code from ftp://elsie.nci.nih.gov/pub, with mktime and
* mkgmtime from our own mktime.c in Zip.
*
* Contains: tzset()
* __tzset()
* gmtime()
* localtime()
* mktime()
* mkgmtime()
* GetPlatformLocalTimezone() [different versions]
*/
/* HISTORY/CHANGES
* 17 Jun 00, Paul Kienitz, added the PD-based tzset(), localtime(), and so on
* to amiga/filedate.c, replacing GNU-based functions which had
* replaced time_lib.c, both having been rejected for licensing
* reasons. Support for timezone files and leap seconds was removed.
*
* 23 Aug 00, Paul Kienitz, split into separate timezone.c file, made platform
* independent, copied in mktime() and mkgmtime() from Zip, renamed
* locale_TZ as GetPlatformLocalTimezone(), for use as a generic
* hook by other platforms.
*/
#ifndef __timezone_c
#define __timezone_c
#include "zip.h"
#include "timezone.h"
#include <ctype.h>
#include <errno.h>
#ifdef IZTZ_DEFINESTDGLOBALS
long timezone = 0;
int daylight = 0;
char *tzname[2];
#endif
#ifndef IZTZ_GETLOCALETZINFO
# define IZTZ_GETLOCALETZINFO(ptzstruct, pgenrulefunct) (FALSE)
#endif
int real_timezone_is_set = FALSE; /* set by tzset() */
#define TZDEFRULESTRING ",M4.1.0,M10.5.0"
#define TZDEFAULT "EST5EDT"
#define SECSPERMIN 60
#define MINSPERHOUR 60
#define HOURSPERDAY 24
#define DAYSPERWEEK 7
#define DAYSPERNYEAR 365
#define DAYSPERLYEAR 366
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
#define MONSPERYEAR 12
#define EPOCH_WDAY 4 /* Jan 1, 1970 was thursday */
#define EPOCH_YEAR 1970
#define TM_YEAR_BASE 1900
#define FIRST_GOOD_YEAR ((time_t) -1 < (time_t) 1 ? EPOCH_YEAR-68 : EPOCH_YEAR)
#define LAST_GOOD_YEAR (EPOCH_YEAR + ((time_t) -1 < (time_t) 1 ? 67 : 135))
#define YDAYS(month, year) yr_days[leap(year)][month]
/* Nonzero if `y' is a leap year, else zero. */
#define leap(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)
/* Number of leap years from EPOCH_YEAR to `y' (not including `y' itself). */
#define _P4 ((EPOCH_YEAR / 4) * 4 + 1)
#define _P100 ((EPOCH_YEAR / 100) * 100 + 1)
#define _P400 ((EPOCH_YEAR / 400) * 400 + 1)
#define nleap(y) (((y) - _P4) / 4 - ((y) - _P100) / 100 + ((y) - _P400) / 400)
/* Length of month `m' (0 .. 11) */
#define monthlen(m, y) (yr_days[0][(m)+1] - yr_days[0][m] + \
((m) == 1 && leap(y)))
/* internal module-level constants */
( run in 2.026 seconds using v1.01-cache-2.11-cpan-a5162978ef8 )