add directory gnu

This commit is contained in:
gohigh
2024-02-19 00:24:47 -05:00
parent 32616db5a4
commit a40f4cadb0
5086 changed files with 1860970 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
# Copyright (C) 1991, 1992 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB. If
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.
#
# Makefile for time routines
#
subdir := time
headers := time.h sys/time.h gnu/time.h
distribute := tzfile.h private.h scheck.c ialloc.c emkdir.c
routines := offtime asctime clock ctime difftime gmtime \
localtime mktime strftime time __tzset tzfile \
__gettod settod adjtime getitmr \
__getitmr __adjtime __settod \
__setitmr tzset gettod setitmr
aux := syms-time
others := ap zdump zic
tests := test_time
tzfiles := africa antarctica asia australasia europe northamerica \
southamerica etcetera factory systemv
# pacificnew doesn't compile; if it is to be used, it should be included in
# northamerica.
distribute := $(distribute) $(tzfiles) leapseconds pacificnew
install := zic zdump
define \n
endef
include zonenames
zonenames := $(subst $(\n), ,$(zonenames))
include ../Makeconfig
ifdef localtime
zonenames := $(zonenames) localtime
endif
ifdef posixrules
zonenames := $(zonenames) posixrules
endif
install-data := $(addprefix zoneinfo/,$(zonenames))
include ../Rules
$(tzfiles:%=zones-%): zones-%: %
(echo 'define $*-zones' ;\
awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^;\
echo 'endef' ;\
echo '$*-zones := $$(subst $$('\\\\n'), ,$$($*-zones))' ;\
echo 'ifdef $*-zones' ;\
echo '$$(addprefix zoneinfo/%/,$$($*-zones)): \' ;\
echo '$< $$(objpfx)zic leapseconds zoneinfo/' ;\
echo ' $$(tzcompile)' ;\
echo 'endif' ;\
echo 'define zonenames' ;\
echo '$$($*-zones)' ;\
echo 'endef' ;\
echo 'zonenames := $$(subst $$('\\\\n'), ,$$(zonenames))' ;\
) > $@
zonenames: Makefile
(for file in $(tzfiles); do \
echo "include zones-$$file"; \
done) > $@
.PHONY: echo-zonenames
echo-zonenames: zonenames
@echo 'Known zones: $(zonenames)'
# Make all the zoneinfo files.
.PHONY: zones zoneinfo
zones: zoneinfo
zoneinfo: $(foreach file,$(tzfiles),$(addprefix zoneinfo/,$($(file)-zones)))
define tzcompile
$(word 2,$^) -d $(patsubst %/,%,$(word 4,$^)) -L $(word 3,$^) $<
endef
ifdef localtime
zoneinfo/localtime: zoneinfo/$(localtime) $(objpfx)zic
$(word 2,$^) -d zoneinfo -l $(<:zoneinfo/%=%)
zoneinfo: zoneinfo/localtime
endif
ifdef posixrules
zoneinfo/posixrules: zoneinfo/$(posixrules) $(objpfx)zic
$(word 2,$^) -d zoneinfo -p $(<:zoneinfo/%=%)
zoneinfo: zoneinfo/posixrules
endif
$(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o $(objpfx)emkdir.o
$(objpfx)tzfile.o: tzfile.c; $(tz-cc)
$(objpfx)zic.o: zic.c; $(tz-cc)
define tz-cc
$(COMPILE.c) -DTZDIR='"$(datadir)/zoneinfo"' \
-DTZDEFAULT='"$(localtime-file)"' \
-DTZDEFRULES='"$(posixrules-file)"' \
$< $(OUTPUT_OPTION)
endef

View File

@@ -0,0 +1,436 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <localeinfo.h>
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifndef HAVE_GNU_LD
#define __tzname tzname
#define __daylight daylight
#define __timezone timezone
#endif
extern int __use_tzfile;
extern void EXFUN(__tzfile_read, (CONST char *file));
extern int EXFUN(__tzfile_compute, (time_t, struct tm));
char *__tzname[2] = { (char *) "GMT", (char *) "GMT" };
int __daylight = 0;
long int __timezone = 0L;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define sign(x) ((x) < 0 ? -1 : 1)
/* This structure contains all the information about a
timezone given in the POSIX standard TZ envariable. */
typedef struct
{
CONST char *name;
/* When to change. */
enum { J0, J1, M } type; /* Interpretation of: */
unsigned short int m, n, d; /* Month, week, day. */
unsigned int secs:17; /* Time of day. */
long int offset; /* Seconds east of GMT (west if < 0). */
/* We cache the computed time of change for a
given year so we don't have to recompute it. */
time_t change; /* When to change to this zone. */
int computed_for; /* Year above is computed for. */
} tz_rule;
/* tz_rules[0] is standard, tz_rules[1] is daylight. */
static tz_rule tz_rules[2];
static int tzset_run = 0;
/* Interpret the TZ envariable. */
void
DEFUN_VOID(__tzset)
{
register CONST char *tz;
register size_t l;
unsigned short int hh, mm, ss;
unsigned short int whichrule;
/* Free old storage. */
if (tz_rules[0].name != NULL && *tz_rules[0].name != '\0')
free((PTR) tz_rules[0].name);
if (tz_rules[1].name != NULL && *tz_rules[1].name != '\0' &&
tz_rules[1].name != tz_rules[0].name)
free((PTR) tz_rules[1].name);
tz = getenv("TZ");
if (tz != NULL && *tz == ':')
{
__tzfile_read(tz + 1);
if (__use_tzfile)
{
tzset_run = 1;
return;
}
else
tz = NULL;
}
if (tz == NULL || *tz == '\0')
tz = _time_info->tz;
if (tz == NULL || *tz == '\0')
{
__tzfile_read((char *) NULL);
if (!__use_tzfile)
{
size_t len = strlen(_time_info->ut0) + 1;
tz_rules[0].name = (char *) malloc(len);
if (tz_rules[0].name == NULL)
return;
tz_rules[1].name = (char *) malloc(len);
if (tz_rules[1].name == NULL)
return;
memcpy((PTR) tz_rules[0].name, _time_info->ut0, len);
memcpy((PTR) tz_rules[1].name, _time_info->ut0, len);
tz_rules[0].type = tz_rules[1].type = J0;
tz_rules[0].m = tz_rules[0].n = tz_rules[0].d = 0;
tz_rules[1].m = tz_rules[1].n = tz_rules[1].d = 0;
tz_rules[0].secs = tz_rules[1].secs = 0;
tz_rules[0].offset = tz_rules[1].offset = 0L;
tz_rules[0].change = tz_rules[1].change = (time_t) -1;
tz_rules[0].computed_for = tz_rules[1].computed_for = 0;
}
tzset_run = 1;
return;
}
/* Get the standard timezone name. */
tz_rules[0].name = (char *) malloc(strlen(tz) + 1);
if (tz_rules[0].name == NULL)
return;
if (sscanf(tz, "%[^0-9,+-]", tz_rules[0].name) != 1 ||
(l = strlen(tz_rules[0].name)) < 3)
return;
tz_rules[0].name = (char *) realloc((PTR) tz_rules[0].name, l + 1);
if (tz_rules[0].name == NULL)
return;
tz += l;
/* Figure out the standard offset from GMT. */
if (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit(*tz)))
return;
if (*tz == '-' || *tz == '+')
tz_rules[0].offset = *tz++ == '-' ? 1L : -1L;
else
tz_rules[0].offset = -1L;
switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss))
{
default:
return;
case 1:
mm = 0;
case 2:
ss = 0;
case 3:
break;
}
tz_rules[0].offset *= (min(ss, 59) + (min(mm, 59) * 60) +
(min(hh, 12) * 60 * 60));
for (l = 0; l < 3; ++l)
{
while (isdigit(*tz))
++tz;
if (l < 2 && *tz == ':')
++tz;
}
/* Get the DST timezone name (if any). */
if (*tz == '\0')
tz_rules[1].name = "";
else
{
tz_rules[1].name = (char *) malloc(strlen(tz) + 1);
if (tz_rules[1].name == NULL)
return;
if (sscanf(tz, "%[^0-9,+-]", tz_rules[1].name) != 1 ||
(l = strlen(tz_rules[1].name)) < 3)
return;
tz_rules[1].name = (char *) realloc((PTR) tz_rules[1].name, l + 1);
if (tz_rules[1].name == NULL)
return;
}
tz += l;
/* Figure out the DST offset from GMT. */
if (*tz == '-' || *tz == '+')
tz_rules[1].offset = *tz++ == '-' ? 1L : -1L;
else
tz_rules[1].offset = -1L;
switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss))
{
default:
/* Default to one hour later than standard time. */
tz_rules[1].offset *= abs (tz_rules[0].offset);
hh = 1;
case 1:
mm = 0;
case 2:
ss = 0;
case 3:
break;
}
tz_rules[1].offset *= (min(ss, 59) + (min(mm, 59) * 60) +
(min(hh, 12) * (60 * 60)));
for (l = 0; l < 3; ++l)
{
while (isdigit(*tz))
++tz;
if (l < 2 && *tz == ':')
++tz;
}
/* If no standard or DST offset was given, default to GMT
for standard and one hour later than standard for DST. */
if (*tz_rules[0].name == '\0')
tz_rules[0].offset = 0L;
if (*tz_rules[1].name == '\0')
tz_rules[1].offset = tz_rules[0].offset + (60 * 60);
if (*tz == '\0' || tz[0] == ',' && tz[1] == '\0')
{
/* There is no rule. See if there is a default rule file. */
__tzfile_default (tz_rules[0].name, tz_rules[1].name,
tz_rules[0].offset, tz_rules[1].offset);
if (__use_tzfile)
return;
}
/* Figure out the standard <-> DST rules. */
for (whichrule = 0; whichrule < 2; ++whichrule)
{
register tz_rule *tzr = &tz_rules[whichrule];
if (*tz != '\0' && *tz == ',')
{
++tz;
if (*tz == '\0')
return;
}
/* Get the date of the change. */
if (*tz == 'J' || isdigit(*tz))
{
char *end;
tzr->type = *tz == 'J' ? J1 : J0;
if (tzr->type == J1 && !isdigit(*++tz))
return;
tzr->n = (unsigned short int) strtoul(tz, &end, 10);
if (end == tz || tzr->n > 365)
return;
else if (tzr->type == J1 && tzr->n == 0)
return;
if (tzr->type == J1 && tzr->n == 60)
/* Can't do February 29. */
++tzr->n;
tz = end;
}
else if (*tz == 'M')
{
int n;
tzr->type = M;
if (sscanf (tz, "M%hu.%hu.%hu%n",
&tzr->m, &tzr->n, &tzr->d, &n) != 3 ||
tzr->m < 1 || tzr->m > 12 ||
tzr->n < 1 || tzr->n > 5 || tzr->d > 6)
return;
tz += n;
}
else if (*tz == '\0')
{
/* United States Federal Law, the equivalent of "M3.1.0,M8.5.0". */
tzr->type = M;
if (tzr == &tz_rules[0])
{
tzr->m = 4;
tzr->n = 1;
tzr->d = 0;
}
else
{
tzr->m = 10;
tzr->n = 5;
tzr->d = 0;
}
}
else
return;
if (*tz != '\0' && *tz != '/' && *tz != ',')
return;
else if (*tz == '/')
{
/* Get the time of day of the change. */
++tz;
if (*tz == '\0')
return;
switch (sscanf(tz, "%hu:%hu:%hu", &hh, &mm, &ss))
{
default:
return;
case 1:
mm = 0;
case 2:
ss = 0;
case 3:
break;
}
for (l = 0; l < 3; ++l)
{
while (isdigit(*tz))
++tz;
if (l < 2 && *tz == ':')
++tz;
}
tzr->secs = (hh * 60 * 60) + (mm * 60) + ss;
}
else
/* Default to 2:00 AM. */
tzr->secs = 2 * 60 * 60;
tzr->computed_for = -1;
}
tzset_run = 1;
}
/* Figure out the exact time (as a time_t) in YEAR
when the change described by RULE will occur and
put it in RULE->change, saving YEAR in RULE->computed_for.
Return nonzero if successful, zero on failure. */
static int
DEFUN(compute_change, (rule, year), tz_rule *rule AND int year)
{
register unsigned short int m = rule->m, n = rule->n, d = rule->d;
struct tm tbuf;
register time_t t;
if (year != -1 && rule->computed_for == year)
/* Operations on times in 1969 will be slower. Oh well. */
return 1;
memset((PTR) &tbuf, 0, sizeof(tbuf));
tbuf.tm_year = year;
if (rule->type == M)
{
/* Defined in _offtime.c. */
extern CONST unsigned short int __mon_lengths[2][12];
unsigned short int ml = __mon_lengths[__isleap(tbuf.tm_year)][m - 1];
tbuf.tm_mon = m - 1;
if (n == 5)
tbuf.tm_mday = ml;
else
tbuf.tm_mday = max((n - 1) * 7, 1);
tbuf.tm_sec = rule->secs;
t = mktime(&tbuf);
if (t == (time_t) -1)
return 0;
if (tbuf.tm_wday != d)
{
if (d > tbuf.tm_wday)
{
tbuf.tm_mday -= 7;
tbuf.tm_mday += tbuf.tm_wday - d;
}
else
tbuf.tm_mday -= tbuf.tm_wday - d;
if (tbuf.tm_mday < 1)
tbuf.tm_mday += 7;
else
if (tbuf.tm_mday > ml) tbuf.tm_mday -= 7;
t = mktime(&tbuf);
if (t == (time_t) -1)
return 0;
}
}
else
{
tbuf.tm_mon = 0;
if (rule->type == J1)
--n;
tbuf.tm_mday = n;
tbuf.tm_sec = rule->secs;
t = mktime(&tbuf);
if (t == (time_t) -1)
return 0;
}
rule->change = t;
rule->computed_for = year;
return 1;
}
/* Figure out the correct timezone for *TIMER and TM (which must be the same)
and set `__tzname', `__timezone', and `__daylight' accordingly.
Return nonzero on success, zero on failure. */
int
DEFUN(__tz_compute, (timer, tm),
time_t timer AND struct tm tm)
{
if (!tzset_run)
__tzset();
if (__use_tzfile)
return __tzfile_compute(timer, tm);
if (!compute_change(&tz_rules[0], tm.tm_year) ||
!compute_change(&tz_rules[1], tm.tm_year))
return 0;
__daylight = timer >= tz_rules[0].change && timer < tz_rules[1].change;
__timezone = tz_rules[__daylight ? 1 : 0].offset;
__tzname[0] = (char *) tz_rules[0].name;
__tzname[1] = (char *) tz_rules[1].name;
return 1;
}
long int
DEFUN_VOID (__tzname_max)
{
size_t len0 = strlen (__tzname[0]), len1 = strlen (__tzname[1]);
return len0 > len1 ? len0 : len1;
}

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
#include <sys/time.h>
#undef adjtime
#include <gnu-stabs.h>
function_alias(adjtime, __adjtime, int, (delta, olddelta),
DEFUN(adjtime, (delta, olddelta),
CONST struct timeval *delta AND
struct timeval *olddelta))

View File

@@ -0,0 +1,43 @@
# @(#)africa 7.1
###############################################################################
# Egypt
# From Bob Devine (January 28, 1988):
# Egypt: DST from first day of May to first of October (ending may
# also be on Sept 30th not 31st -- you might want to ask one of the
# soc.* groups, you might hit someone who could ask an embassy).
# DST since 1960 except for 1981-82.
# From U. S. Naval Observatory (January 19, 1989):
# EGYPT 2 H AHEAD OF UTC
# EGYPT 3 H AHEAD OF UTC MAY 17 - SEP 30 (AFTER
# EGYPT RAMADAN)
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Egypt 1960 max - May 1 2:00 1:00 " DST"
Rule Egypt 1960 max - Oct 1 2:00 0 -
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Egypt 2:00 Egypt EET%s 1981
2:00 - EET 1983
2:00 Egypt EET%s
###############################################################################
# Libya
# From Bob Devine (January 28 1988):
# Libya: Since 1982 April 1st to September 30th (?)
# From U. S. Naval Observatory (January 19, 1989):
# LIBYAN ARAB 1 H AHEAD OF UTC JAMAHIRIYA/LIBYA
# LIBYAN ARAB 2 H AHEAD OF UTC APR 1 - SEP 30 JAMAHIRIYA/LIBYA
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Libya 1982 max - Apr 1 2:00 1:00 " DST"
Rule Libya 1982 max - Sep 30 2:00 0 -
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Libya 2:00 Libya EET%s

View File

@@ -0,0 +1,4 @@
# @(#)antarctica 7.1
# From Arthur David Olson (February 13, 1988):
# No data available.

View File

@@ -0,0 +1,46 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <malloc.h>
/* Prints the time in the form "hh:mm ?M", where ? is A or P.
A simple test for strftime(). */
int
DEFUN(main, (argc, argv), int argc AND char **argv)
{
char buf[20];
time_t t;
mcheck (NULL);
if (argc != 1)
fprintf(stderr, "Usage: %s\n", argv[0]);
t = time((time_t *) NULL);
if (strftime(buf, sizeof(buf), "%I:%M %p", localtime(&t)) == 0)
exit(EXIT_FAILURE);
puts(buf);
exit(EXIT_SUCCESS);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,47 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <localeinfo.h>
#include <errno.h>
#include <stdio.h>
#include <time.h>
/* Returns a string of the form "Day Mon dd hh:mm:ss yyyy\n"
which is the representation of TP in that form. */
char *
DEFUN(asctime, (tp), CONST struct tm *tp)
{
static char result[26];
if (tp == NULL)
{
errno = EINVAL;
return(NULL);
}
if (sprintf(result, "%.3s %.3s %2d %.2d:%.2d:%.2d %d\n",
_time_info->abbrev_wkday[tp->tm_wday],
_time_info->abbrev_month[tp->tm_mon],
tp->tm_mday, tp->tm_hour, tp->tm_min,
tp->tm_sec, 1900 + tp->tm_year) != sizeof(result) - 1)
return(NULL);
return(result);
}

View File

@@ -0,0 +1,134 @@
# @(#)asia 7.1
# From Guy Harris:
# Incorporates data for Singapore from Robert Elz' asia 1.1, as well as
# additional information from Tom Yap, Sun Microsystems Intercontinental
# Technical Support (including a page from the Official Airline Guide -
# Worldwide Edition). The names for time zones are guesses.
###############################################################################
# People's Republic of China
# From Guy Harris:
# People's Republic of China. Yes, they really have only one time zone.
# From Bob Devine (January 28, 1988):
# No they don't. See TIME mag, February 17, 1986 p.52. Even though
# China is across 4 physical time zones, before Feb 1, 1986 only the
# Peking (Bejing) time zone was recognized. Since that date, China
# has two of 'em -- Peking's and Urumqi (named after the capital of
# the Xinjiang Uighur Autonomous Region). I don't know about DST for it.
#
# . . .I just deleted the DST table and this editor makes it too
# painful to suck in another copy.. So, here is what I have for
# DST start/end dates for Peking's time zone (info from AP):
#
# 1986 May 4 - Sept 14
# 1987 mid-April - ??
# From U. S. Naval Observatory (January 19, 1989):
# CHINA 8 H AHEAD OF UTC ALL OF CHINA, INCL TAIWAN
# CHINA 9 H AHEAD OF UTC APR 17 - SEP 10
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule PRC 1970 max - Apr Sun<=14 2:00 1:00 D
Rule PRC 1970 max - Sep Sun<=14 3:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone PRC 8:00 PRC C%sT
###############################################################################
# Republic of China
# From Guy Harris
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone ROC 8:00 - CST
###############################################################################
# Hongkong
# From Guy Harris
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Hongkong 8:00 - HKT
###############################################################################
# Iran
# From Bob Devine (January 28, 1988):
# Iran: Last Sunday in March to third (?) Sunday in
# September. Since the revolution, the official calendar is Monarchic
# calendar; I have no idea what the correspondence between dates are.
# From U. S. Naval Observatory (January 19, 1989):
# IRAN 3.5H AHEAD OF UTC
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Iran 1988 max - Mar lastSun 2:00 1:00 D
Rule Iran 1988 max - Sep Sun>=15 2:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Iran 3:30 Iran I%sT
###############################################################################
# Israel
# From U. S. Naval Observatory (January 19, 1989):
# ISRAEL 2 H AHEAD OF UTC
# ISRAEL 3 H AHEAD OF UTC APR 10 - SEP 3
# From Arthur David Olson (January 21, 1989):
# Stick with rules below (which were provided by Guy Harris and which were
# posted in 1988) for now.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Israel 1987 max - Apr Sun<=21 2:00 1:00 D
Rule Israel 1987 max - Aug Sat<=28 2:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Israel 3:00 Israel I%sT
###############################################################################
# Japan
# From Guy Harris
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Japan 9:00 - JST
###############################################################################
# Republic of Korea
# From Guy Harris:
# According to someone at the Korean Times in San Francisco,
# Daylight Savings Time was not observed until 1987. He did not know
# at what time of day DST starts or ends.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule ROK 1987 max - May Sun<=14 2:00 1:00 D
Rule ROK 1987 max - Oct Sun<=14 3:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone ROK 9:00 ROK K%sT
###############################################################################
# Lebanon
# From Bob Devine (January 28, 1988):
# Lebanon: They do have DST but I don't know the dates.
###############################################################################
# Singapore
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Singapore 8:00 - SST

View File

@@ -0,0 +1,103 @@
# @(#)australasia 7.1
# Incorporates updates for Australia from Robert Elz' australia 1.1
# and further updates from the Australian consulate.
###############################################################################
# Australia
# Australian Data (for states with DST), standard rules
# Includes shift in 1987 to follow Vic/NSW rules for ending DST,
# and shift in 1986 to start DST earlier.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Oz 1971 1985 - Oct lastSun 2:00 1:00 -
Rule Oz 1986 max - Oct Sun<=24 2:00 1:00 -
Rule Oz 1972 only - Feb 27 3:00 0 -
Rule Oz 1973 1986 - Mar Sun>=1 3:00 0 -
Rule Oz 1987 max - Mar Sun<=21 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Australia/Tasmania 10:00 Oz EST
Zone Australia/Queensland 10:00 - EST # No DST here
Zone Australia/North 9:30 - CST # No DST here
Zone Australia/West 8:00 - WST # No DST here
Zone Australia/South 9:30 Oz CST
# Victoria jumped to a later ending date for DST in 1986 rather than 1987.
Zone Australia/Victoria 10:00 Oz EST 1985 Oct lastSun 2:00
10:00 1:00 EST 1986 Mar Sun<=21 3:00
10:00 Oz EST
# New South Wales and subjurisdictions have their own ideas of a fun time.
# Based on law library research by John Mackin (john@basser.cs.su.oz),
# who notes:
# In Australia, time is not legislated federally, but rather by the
# individual states. Thus, while such terms as ``Eastern Standard Time''
# [I mean, of course, Australian EST, not any other kind] are in common
# use, _they have NO REAL MEANING_, as they are not defined in the
# legislation. This is very important to understand.
# I have researched New South Wales time only; . . .I hope that perhaps a
# resident of each state could be found to do it for their own state.
# (And I can guarantee that Victoria and NSW are different, so the link
# between them in the current australasia file must be broken.)
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule NSW 1971 1985 - Oct lastSun 2:00 1:00 -
Rule NSW 1972 only - Feb lastSun 3:00 0 -
Rule NSW 1973 1981 - Mar Sun>=1 3:00 0 -
Rule NSW 1982 only - Apr 4 3:00 0 -
Rule NSW 1983 1985 - Mar Sun>=1 3:00 0 -
Rule NSW 1986 only - Mar 16 3:00 0 -
Rule NSW 1986 only - Oct 19 2:00 1:00 -
Rule NSW 1987 only - Mar 15 3:00 0 -
Rule NSW 1987 max - Oct lastSun 2:00 1:00 -
Rule NSW 1988 max - Mar Sun<=21 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Australia/NSW 10:00 NSW EST
# `Broken Hill' means the County of Yancowinna. [john@basser.cs.su.oz.au,1/4/89]
Zone Australia/Yancowinna 9:30 NSW ???
Zone Australia/LHI 10:30 NSW ???
# A footnote here:
#
# . . .
# Date: Thu, j19 Feb 87 12:02:17 EST
# From: Bradley White <seismo!k.cs.cmu.edu!bww>
# . . .
# I am including a description of Australian time zones. . .
# this stuff is definitely accurate.
# . . .
# a) Australian Eastern Time: (EST = GMT+10:00, EDT = GMT+11:00)
# . . .
# Summer of 86/87 - present (current legislation):
# third Sun Oct 02:00 EST -> third [S]un Mar 02:00 EST
#
# If this turns out to be true, substitute Sun<=21 (third Sunday in October)
# for Sun<=24 (next-to-last Sunday in October) above. . .some time before
# October 1988, the first time it makes a difference.
###############################################################################
# New Zealand
# New Zealand, from Elz' asia 1.1
# Elz says "no guarantees"
# the 1989/90 year was a trial of an extended "daylight saving" period.
# This trial was deemed successful and the extended period adopted for
# subsequent years (with the addition of a further week at the start).
# source -- phone call to Ministry of Internal Affairs Head Office.
# Mark Davies <mark@comp.vuw.ac.nz>, 3 Oct 1990.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule NZ 1974 1988 - Oct lastSun 2:00 1:00 D
Rule NZ 1989 only - Oct 8 2:00 1:00 D
Rule NZ 1990 max - Oct Sun>=1 2:00 1:00 D
Rule NZ 1975 1989 - Mar Sun>=1 3:00 0 S
Rule NZ 1990 max - Mar Sun>=15 3:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone NZ 12:00 NZ NZ%sT # New Zealand

View File

@@ -0,0 +1,35 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#undef __OPTIMIZE__ /* Avoid inline `ctime' function. */
#include <time.h>
#undef ctime
/* Return a string as returned by asctime which
is the representation of *T in that form. */
char *
DEFUN(ctime, (t), CONST time_t *t)
{
register struct tm *tp = localtime(t);
if (tp == NULL)
return NULL;
return asctime(tp);
}

View File

@@ -0,0 +1,29 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
/* Return the difference between TIME1 and TIME0. */
__CONSTVALUE
double
DEFUN(difftime, (time1, time0), time_t time1 AND time_t time0)
{
return (double) (time1 - time0);
}

View File

@@ -0,0 +1,87 @@
#ifdef LIBC
#include <ansidecl.h>
#endif
#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)emkdir.c 8.20";
#endif /* !defined NOID */
#endif /* !defined lint */
#ifndef emkdir
/*LINTLIBRARY*/
#include "private.h"
extern char * imalloc P((int n));
extern void ifree P((char * p));
static char *
quoted(name)
register const char * name;
{
register char * result;
register char * cp;
register int c;
if (name == NULL)
name = "";
result = imalloc(4 * strlen(name) + 3);
if (result == NULL)
return NULL;
cp = result;
#ifdef unix
*cp++ = '\'';
while ((c = *name++) != '\0')
if (c == '\'') {
*cp++ = c;
*cp++ = '\\';
*cp++ = c;
*cp++ = c;
} else *cp++ = c;
*cp++ = '\'';
#else /* !defined unix */
while ((c = *name++) != '\0')
if (c == '/')
*cp++ = '\\';
else *cp++ = c;
#endif /* !defined unix */
*cp = '\0';
return result;
}
int
emkdir(name, mode)
const char * name;
const int mode;
{
register int result;
register const char * format;
register char * command;
register char * qname;
if ((qname = quoted(name)) == NULL)
return -1;
#ifdef unix
format = "mkdir 2>&- %s && chmod 2>&- %o %s";
#else /* !defined unix */
format = "mkdir %s";
#endif /* !defined unix */
command = imalloc(strlen(format) + 2 * strlen(qname) + 20 + 1);
if (command == NULL) {
ifree(qname);
return -1;
}
(void) sprintf(command, format, qname, mode, qname);
ifree(qname);
result = system(command);
ifree(command);
return (result == 0) ? 0 : -1;
}
/*
** UNIX is a registered trademark of AT&T.
*/
#endif /* !defined emkdir */

View File

@@ -0,0 +1,55 @@
# @(#)etcetera 7.1
# All of these are set up just so people can "zic -l" to a timezone
# that's right for their area, even if it doesn't have a name or dst rules
# (half hour zones are too much to bother with -- when someone asks!)
Zone GMT 0 - GMT
Zone GMT-12 -12 - GMT-1200
Zone GMT-11 -11 - GMT-1100
Zone GMT-10 -10 - GMT-1000
Zone GMT-9 -9 - GMT-0900
Zone GMT-8 -8 - GMT-0800
Zone GMT-7 -7 - GMT-0700
Zone GMT-6 -6 - GMT-0600
Zone GMT-5 -5 - GMT-0500
Zone GMT-4 -4 - GMT-0400
Zone GMT-3 -3 - GMT-0300
Zone GMT-2 -2 - GMT-0200
Zone GMT-1 -1 - GMT-0100
Zone GMT+1 1 - GMT+0100
Zone GMT+2 2 - GMT+0200
Zone GMT+3 3 - GMT+0300
Zone GMT+4 4 - GMT+0400
Zone GMT+5 5 - GMT+0500
Zone GMT+6 6 - GMT+0600
Zone GMT+7 7 - GMT+0700
Zone GMT+8 8 - GMT+0800
Zone GMT+9 9 - GMT+0900
Zone GMT+10 10 - GMT+1000
Zone GMT+11 11 - GMT+1100
Zone GMT+12 12 - GMT+1200
Zone GMT+13 13 - GMT+1300 # GMT+12 with DST
Link GMT UTC
Link GMT UCT
Link GMT Universal
Link GMT Greenwich
Link GMT Zulu
Link GMT GMT-0
Link GMT GMT+0
Link GMT GMT0
Link GMT+1 GMT1
Link GMT+2 GMT2
Link GMT+3 GMT3
Link GMT+4 GMT4
Link GMT+5 GMT5
Link GMT+6 GMT6
Link GMT+7 GMT7
Link GMT+8 GMT8
Link GMT+9 GMT9
Link GMT+10 GMT10
Link GMT+11 GMT11
Link GMT+12 GMT12
Link GMT+13 GMT13

View File

@@ -0,0 +1,224 @@
# @(#)europe 7.1
# International country codes are used to identify countries' rules and
# zones
#
# This data is by no means authoritative; if you think you know better, go
# ahead and edit the file (and please send any changes to
# ado@ncifcrf.gov for general use in the future).
###############################################################################
# United Kingdom
# From Arthur David Olson (January 19, 1989):
#
# The starting and ending dates below (from which the rules are derived)
# are from Whitaker's Almanack for 1987, page 146.
# 1960 is the earliest year for which dates are given;
# Whitaker's notes that British Summer Time (and, in some years, Double Summer
# Time) was observed in earlier years but does not give start and end dates.
#
# A source at the British Information Office in New York avers that it's
# known as "British" Summer Time in all parts of the United Kingdom.
# 1960 April 10 October 2 (yes, 2, according to the almanac)
# 1961 March 26 October 29
# 1962 March 25 October 28
# 1963 March 31 October 27
# 1964 March 22 October 25
# 1965 March 21 October 24
# 1966 March 20 October 23
# 1967 March 19 October 29
# 1968 February 18 October 27
# "British Standard Time, also one hour ahead of G. M. T., was kept between
# 1968 Oct. 27-1971 Oct. 31."
# 1972 March 19 October 29
# 1973 March 18 October 28
# 1974 March 17 October 27
# 1975 March 16 October 26
# 1976 March 21 October 24
# 1977 March 20 October 23
# 1978 March 19 October 29
# 1979 March 18 October 28
# 1980 March 16 October 26
# 1981 March 29 October 25
# 1982 March 28 October 24
# 1983 March 27 October 23
# 1984 March 25 October 28
# 1985 March 31 October 27
# 1986 March 30 October 26
# 1987 March 29 October 25
# From an Anonymous U. K. Donor (January 4, 1989):
#
# It is NOT possible to predict when [British Summer Time] will change
# in a future year.
#
# (The admiralty calculate when they think it should be (no more that a couple
# of years in advance) and advise the government who then decide whether or
# not they will take the admiralty's advice)
#
# ...the Gre[e]nwich...observatory...[was] very helpful.
#
# I was not able to track down the Admiralty formula (I tried hard but failed)
# ...
# Date: 4 Jan 89 08:57:25 GMT (Wed)
# From: Jonathan Leffler <nih-csl!uunet!mcvax!sphinx.co.uk!john>
# ...
# [British Summer Time] is fixed annually by Act of Parliament.
# If you can predict what Parliament will do, you should be in
# politics making a fortune, not computing.
#
# Summer time ends on Sunday 29 October 1989.
# ...
# Date: 5 Jan 89 09:50:38 GMT (Thu)
# From: Peter Kendell <nih-csl!uunet!mcvax!tcom.stc.co.uk!pete>
# ...
#
# From my Collins Diary for 1989 -
#
# "At the time of going to press the Home Office was unable to confirm
# the 1989 starting and finishing dates for BST*, but expressed the
# view that 26 March and 29 October were the likeliest dates to be
# adopted"
#
# *British Summer Time.
# From an Anonymous U. K. Donor (January 5, 1989):
#
# . . .our government is seriously considering applying Double Summer Time -
# putting the clocks forwards and back TWO hours for daylight saving time.
# This is advocated to standardise time in the EEC - we're all supposed to
# keep the same time and to change the clocks on the same dates in the future.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
# Historic starting rules
Rule GB-Eire 1960 only - Apr 10 1:00s 1:00 BST
Rule GB-Eire 1961 1963 - Mar lastSun 1:00s 1:00 BST
Rule GB-Eire 1964 1967 - Mar Sun>=19 1:00s 1:00 BST
Rule GB-Eire 1968 only - Feb 18 1:00s 1:00 BST
Rule GB-Eire 1972 1980 - Mar Sun>=16 1:00s 1:00 BST
# Historic ending rules
Rule GB-Eire 1960 only - Oct 2 1:00s 0 GMT
Rule GB-Eire 1961 1967 - Oct Sun>=23 1:00s 0 GMT
Rule GB-Eire 1971 only - Oct 31 1:00s 0 GMT
# Current rules
Rule GB-Eire 1981 max - Mar lastSun 1:00s 1:00 BST
Rule GB-Eire 1972 max - Oct Sun>=23 1:00s 0 GMT
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone GB-Eire 0:00 GB-Eire %s 1968 Oct 27 1:00s
1:00 - BST 1971 Oct 31 1:00s
0:00 GB-Eire %s
###############################################################################
# Continental Europe
# The use of 1986 as starting years below is conservative.
Rule W-Eur 1986 max - Mar lastSun 1:00s 1:00 " DST"
Rule W-Eur 1986 max - Sep lastSun 1:00s 0 -
Rule M-Eur 1986 max - Mar lastSun 2:00s 1:00 " DST"
Rule M-Eur 1986 max - Sep lastSun 2:00s 0 -
Rule E-Eur 1986 max - Mar lastSun 3:00s 1:00 " DST"
Rule E-Eur 1986 max - Sep lastSun 3:00s 0 -
Rule Turkey 1986 max - Mar lastSun 1:00 1:00 " DST"
Rule Turkey 1986 max - Sep lastSun 1:00 0 -
Rule W-SU 1986 max - Mar lastSun 2:00s 1:00 " DST"
Rule W-SU 1986 max - Sep lastSun 2:00s 0 -
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone WET 0:00 W-Eur WET%s
Zone Iceland 0:00 - WET
Zone MET 1:00 M-Eur MET%s
Zone Poland 1:00 W-Eur MET%s
Zone EET 2:00 E-Eur EET%s
Zone Turkey 3:00 Turkey EET%s
Zone W-SU 3:00 M-Eur ????
# Tom Hoffman says that MET is also known as Central European Time
Link MET CET
###############################################################################
# One source shows that Bulgaria, Cyprus, Finland, and Greece observe DST from
# the last Sunday in March to the last Sunday in September in 1986.
# The source shows Romania changing a day later than everybody else.
#
# According to Bernard Sieloff's source, Poland is in the MET time zone but
# uses the WE DST rules. The Western USSR uses EET+1 and ME DST rules.
# Bernard Sieloff's source claims Romania switches on the same day, but at
# 00:00 standard time (i.e., 01:00 DST). It also claims that Turkey
# switches on the same day, but switches on at 01:00 standard time
# and off at 00:00 standard time (i.e., 01:00 DST)
# ...
# Date: Wed, 28 Jan 87 16:56:27 -0100
# From: seismo!mcvax!cgcha!wtho (Tom Hofmann)
# Message-Id: <8701281556.AA22174@cgcha.uucp>
# ...
#
# ...the European time rules are...standardized since 1981, when
# most European coun[tr]ies started DST. Before that year, only
# a few countries (UK, France, Italy) had DST, each according
# to own national rules. In 1981, however, DST started on
# 'Apr firstSun', and not on 'Mar lastSun' as in the following
# years...
# But also since 1981 there are some more national exceptions
# than listed in 'europe': Switzerland, for example, joined DST
# one year later, Denmark ended DST on 'Oct 1' instead of 'Sep
# lastSun' in 1981---I don't know how they handle now.
#
# Finally, DST ist always from 'Apr 1' to 'Oct 1' in the
# Soviet Union (as far as I know).
#
# Tom Hofmann, Scientific Computer Center, CIBA-GEIGY AG,
# 4002 Basle, Switzerland
# UUCP: ...!mcvax!cernvax!cgcha!wtho
# ...
# Date: Wed, 4 Feb 87 22:35:22 +0100
# From: seismo!mcvax!cwi.nl!dik (Dik T. Winter)
# ...
#
# The information from Tom Hofmann is (as far as I know) not entirely correct.
# After a request from chongo at amdahl I tried to retrieve all information
# about DST in Europe. I was able to find all from about 1969.
#
# ...standardization on DST in Europe started in about 1977 with switches on
# first Sunday in April and last Sunday in September...
# In 1981 UK joined Europe insofar that
# the starting day for both shifted to last Sunday in March. And from 1982
# the whole of Europe used DST, with switch dates April 1 and October 1 in
# the Sov[i]et Union. In 1985 the SU reverted to standard Europe[a]n switch
# dates...
#
# It should also be remembered that time-zones are not constants; e.g.
# Portugal switched in 1976 from MET (or CET) to WET with DST...
# Note also that though there were rules for switch dates not
# all countries abided to these dates, and many individual deviations
# occurred, though not since 1982 I believe. Another note: it is always
# assumed that DST is 1 hour ahead of normal time, this need not be the
# case; at least in the Netherlands there have been times when DST was 2 hours
# in advance of normal time.
#
# ...
# dik t. winter, cwi, amsterdam, nederland
# INTERNET : dik@cwi.nl
# BITNET/EARN: dik@mcvax
# From Bob Devine (January 28, 1988):
# ...
# Greece: Last Sunday in April to last Sunday in September (iffy on dates).
# Since 1978. Change at midnight.
# ...
# Monaco: has same DST as France.
# ...

View File

@@ -0,0 +1,8 @@
# @(#)factory 7.1
# For companies who don't want to put time zone specification in
# their installation procedures. When users run date, they'll get the message.
# Also useful for the "comp.sources" version.
# Zone NAME GMTOFF RULES FORMAT
Zone Factory 0 - "Local time zone must be set--see zic manual page"

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
#include <sys/time.h>
#undef getitimer
#include <gnu-stabs.h>
function_alias(getitimer, __getitimer, int, (which, value),
DEFUN(getitimer, (which, value),
enum __itimer_which which AND
struct itimerval *value))

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
#include <sys/time.h>
#undef gettimeofday
#include <gnu-stabs.h>
function_alias(gettimeofday, __gettimeofday, int, (tv, tz),
DEFUN(gettimeofday, (tv, tz),
struct timeval *tv AND struct timezone *tz))

View File

@@ -0,0 +1,32 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <stddef.h>
#undef __OPTIMIZE__ /* Avoid inline `gmtime' function. */
#include <time.h>
#undef gmtime
/* Return the `struct tm' representation of *T in UTC. */
struct tm *
DEFUN(gmtime, (t), CONST time_t *t)
{
return __offtime(t, 0L);
}

View File

@@ -0,0 +1,64 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _GNU_TIME_H
#define _GNU_TIME_H 1
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct __timeval
{
long int tv_sec; /* Seconds. */
long int tv_usec; /* Microseconds. */
};
/* Structure crudely representing a timezone. */
struct __timezone
{
int tz_minuteswest; /* Minutes west of GMT. */
int tz_dsttime; /* Nonzero if DST is ever in effect. */
};
/* Values for the first argument to `getitimer' and `setitimer'. */
enum __itimer_which
{
/* Timers run in real time. */
ITIMER_REAL = 0,
/* Timers run only when the process is executing. */
ITIMER_VIRTUAL = 1,
/* Timers run when the process is executing and when
the system is executing on behalf of the process. */
ITIMER_PROF = 2,
};
/* Type of the second argument to `getitimer' and
the second and third arguments `setitimer'. */
struct __itimerval
{
/* Value to put into `it_value' when the timer expires. */
struct __timeval it_interval;
/* Time to the next timer expiration. */
struct __timeval it_value;
};
#endif /* gnu/time.h */

View File

@@ -0,0 +1,105 @@
#ifdef LIBC
#include <ansidecl.h>
#endif
#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)ialloc.c 8.19";
#endif /* !defined NOID */
#endif /* !defined lint */
/*LINTLIBRARY*/
#include "private.h"
#ifdef MAL
#define NULLMAL(x) ((x) == NULL || (x) == MAL)
#else /* !defined MAL */
#define NULLMAL(x) ((x) == NULL)
#endif /* !defined MAL */
#define nonzero(n) (((n) == 0) ? 1 : (n))
char * icalloc P((int nelem, int elsize));
char * icatalloc P((char * old, const char * new));
char * icpyalloc P((const char * string));
char * imalloc P((int n));
char * irealloc P((char * pointer, int size));
void ifree P((char * pointer));
char *
imalloc(n)
const int n;
{
#ifdef MAL
register char * result;
result = malloc((alloc_size_t) nonzero(n));
return NULLMAL(result) ? NULL : result;
#else /* !defined MAL */
return malloc((alloc_size_t) nonzero(n));
#endif /* !defined MAL */
}
char *
icalloc(nelem, elsize)
int nelem;
int elsize;
{
if (nelem == 0 || elsize == 0)
nelem = elsize = 1;
return calloc((alloc_size_t) nelem, (alloc_size_t) elsize);
}
char *
irealloc(pointer, size)
char * const pointer;
const int size;
{
if (NULLMAL(pointer))
return imalloc(size);
return realloc((genericptr_t) pointer, (alloc_size_t) nonzero(size));
}
char *
icatalloc(old, new)
char * const old;
const char * const new;
{
register char * result;
register oldsize, newsize;
newsize = NULLMAL(new) ? 0 : strlen(new);
if (NULLMAL(old))
oldsize = 0;
else if (newsize == 0)
return old;
else oldsize = strlen(old);
if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
if (!NULLMAL(new))
(void) strcpy(result + oldsize, new);
return result;
}
char *
icpyalloc(string)
const char * const string;
{
return icatalloc((char *) NULL, string);
}
void
ifree(p)
char * const p;
{
if (!NULLMAL(p))
(void) free(p);
}
void
icfree(p)
char * const p;
{
if (!NULLMAL(p))
(void) free(p);
}

View File

@@ -0,0 +1,28 @@
# @(#)leapseconds 7.1
# Allowance for leapseconds added to each timezone file.
# The correction (+ or -) is made at the given time, so lines
# will typically look like:
# Leap YEAR MON DAY 23:59:60 + R/S
# or
# Leap YEAR MON DAY 23:59:59 - R/S
# If the leapsecond is Rolling (R) the given time is local time
# If the leapsecond is Stationary (S) the given time is GMT
# Leap YEAR MONTH DAY HH:MM:SS CORR R/S
Leap 1972 Jun 30 23:59:60 + S
Leap 1972 Dec 31 23:59:60 + S
Leap 1973 Dec 31 23:59:60 + S
Leap 1974 Dec 31 23:59:60 + S
Leap 1975 Dec 31 23:59:60 + S
Leap 1976 Dec 31 23:59:60 + S
Leap 1977 Dec 31 23:59:60 + S
Leap 1978 Dec 31 23:59:60 + S
Leap 1979 Dec 31 23:59:60 + S
Leap 1981 Jun 30 23:59:60 + S
Leap 1982 Jun 30 23:59:60 + S
Leap 1983 Jun 30 23:59:60 + S
Leap 1985 Jun 30 23:59:60 + S
Leap 1987 Dec 31 23:59:60 + S

View File

@@ -0,0 +1,60 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <localeinfo.h>
#include <stddef.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifndef HAVE_GNU_LD
#define __tzname tzname
#define __daylight daylight
#define __timezone timezone
#endif
/* Return the `struct tm' representation of *TIMER in the local timezone. */
struct tm *
DEFUN(localtime, (timer), CONST time_t *timer)
{
extern int EXFUN(__tz_compute, (time_t, struct tm));
register struct tm *tp;
if (timer == NULL)
{
errno = EINVAL;
return NULL;
}
tp = gmtime(timer);
if (tp == NULL)
return NULL;
if (!__tz_compute (*timer, *tp))
return NULL;
tp = __offtime(timer, __timezone);
tp->tm_isdst = __daylight;
tp->tm_gmtoff = __timezone;
tp->tm_zone = __tzname[__daylight];
return tp;
}

View File

@@ -0,0 +1,192 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <errno.h>
#include <limits.h>
#include <time.h>
/* Defined in offtime.c. */
extern CONST unsigned short int __mon_lengths[2][12];
#define invalid() return (time_t) -1
/* Return the `time_t' representation of TP and normalizes TP.
Return (time_t) -1 if TP is not representable as a `time_t'.
Note that 31 Dec 1969 23:59:59 is not representable
because it is represented as (time_t) -1. */
time_t
DEFUN(mktime, (tp), register struct tm *tp)
{
static struct tm min, max;
static char init = 0;
register time_t result;
register time_t t;
register int i;
register CONST unsigned short *l;
register struct tm *new;
time_t end;
if (tp == NULL)
{
errno = EINVAL;
invalid();
}
if (!init)
{
init = 1;
end = (time_t) LONG_MIN;
new = gmtime(&end);
if (new != NULL)
min = *new;
else
min.tm_sec = min.tm_min = min.tm_hour =
min.tm_mday = min.tm_mon = min.tm_year = INT_MIN;
end = (time_t) LONG_MAX;
new = gmtime(&end);
if (new != NULL)
max = *new;
else
max.tm_sec = max.tm_min = max.tm_hour =
max.tm_mday = max.tm_mon = max.tm_year = INT_MAX;
}
/* Make all the elements of TP that we pay attention to
be within the ranges of reasonable values for those things. */
#define normalize(elt, min, max, nextelt) \
while (tp->elt < min) \
{ \
--tp->nextelt; \
tp->elt += max + 1; \
} \
while (tp->elt > max) \
{ \
++tp->nextelt; \
tp->elt -= max + 1; \
}
normalize (tm_sec, 0, 59, tm_min);
normalize (tm_min, 0, 59, tm_hour);
normalize (tm_hour, 0, 24, tm_mday);
/* Normalize the month first so we can use
it to figure the range for the day. */
normalize (tm_mon, 0, 11, tm_year);
normalize (tm_mday, 1, __mon_lengths[__isleap (tp->tm_year)][tp->tm_mon],
tm_mon);
/* Normalize the month again, since normalizing
the day may have pushed it out of range. */
normalize (tm_mon, 0, 11, tm_year);
/* Normalize the day again, because normalizing
the month may have changed the range. */
normalize (tm_mday, 1, __mon_lengths[__isleap (tp->tm_year)][tp->tm_mon],
tm_mon);
/* Check for out-of-range values. */
#define lowhigh(field, minmax, cmp) (tp->field cmp minmax.field)
#define low(field) lowhigh(field, min, <)
#define high(field) lowhigh(field, max, >)
#define oor(field) (low(field) || high(field))
#define lowbound(field) (tp->field == min.field)
#define highbound(field) (tp->field == max.field)
if (oor(tm_year))
invalid();
else if (lowbound(tm_year))
{
if (low(tm_mon))
invalid();
else if (lowbound(tm_mon))
{
if (low(tm_mday))
invalid();
else if (lowbound(tm_mday))
{
if (low(tm_hour))
invalid();
else if (lowbound(tm_hour))
{
if (low(tm_min))
invalid();
else if (lowbound(tm_min))
{
if (low(tm_sec))
invalid();
}
}
}
}
}
else if (highbound(tm_year))
{
if (high(tm_mon))
invalid();
else if (highbound(tm_mon))
{
if (high(tm_mday))
invalid();
else if (highbound(tm_mday))
{
if (high(tm_hour))
invalid();
else if (highbound(tm_hour))
{
if (high(tm_min))
invalid();
else if (highbound(tm_min))
{
if (high(tm_sec))
invalid();
}
}
}
}
}
t = 0;
for (i = 1970; i > 1900 + tp->tm_year; --i)
t -= __isleap(i) ? 366 : 365;
for (i = 1970; i < 1900 + tp->tm_year; ++i)
t += __isleap(i) ? 366 : 365;
l = __mon_lengths[__isleap(1900 + tp->tm_year)];
for (i = 0; i < tp->tm_mon; ++i)
t += l[i];
t += tp->tm_mday - 1;
result = ((t * 60 * 60 * 24) +
(tp->tm_hour * 60 * 60) +
(tp->tm_min * 60) +
tp->tm_sec);
end = result;
if (tp->tm_isdst < 0)
new = localtime(&end);
else
new = gmtime(&end);
if (new == NULL)
invalid();
new->tm_isdst = tp->tm_isdst;
*tp = *new;
return result;
}

View File

@@ -0,0 +1,321 @@
# @(#)northamerica 7.1
###############################################################################
# United States
# From Arthur David Olson:
# US Daylight Saving Time ended on the last Sunday of *October* in 1974.
# See, for example, the front page of the Saturday, October 26, 1974
# and Sunday, October 27, 1974 editions of the Washington Post.
# From seismo!munnari!kre:
# I recall also being told by someone once that Canada didn't have
# the DST variations in 74/75 that the US did, but I am not nearly
# sure enough of this to add anything.
# From Arthur David Olson:
# The above has been confirmed by Bob Devine; we'll go with it here.
# From Arthur David Olson:
# Before the Uniform Time Act of 1966 took effect in 1967, observance of
# Daylight Saving Time in the US was by local option, except during wartime.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule US 1918 1919 - Mar lastSun 2:00 1:00 D
Rule US 1918 1919 - Oct lastSun 2:00 0 S
Rule US 1942 only - Feb 9 2:00 1:00 W # War
Rule US 1945 only - Sep 30 2:00 0 S
Rule US 1967 max - Oct lastSun 2:00 0 S
Rule US 1967 1973 - Apr lastSun 2:00 1:00 D
Rule US 1974 only - Jan 6 2:00 1:00 D
Rule US 1975 only - Feb 23 2:00 1:00 D
Rule US 1976 1986 - Apr lastSun 2:00 1:00 D
Rule US 1987 max - Apr Sun>=1 2:00 1:00 D
# From Bob Devine (January 28, 1988):
# ...Alaska (and Hawaii) had the timezone names changed in 1967.
# old new
# Pacific Standard Time(PST) -same-
# Yukon Standard Time(YST) -same-
# Central Alaska S.T. (CAT) Alaska-Hawaii St[an]dard Time (AHST)
# Nome Standard Time (NT) Bering Standard Time (BST)
#
# ...Alaska's timezone lines were redrawn in 1983 to give only 2 tz.
# The YST zone now covers nearly all of the state, AHST just part
# of the Aleutian islands. No DST.
# From U. S. Naval Observatory (January 19, 1989):
# USA EASTERN 5 H BEHIND UTC NEW YORK, WASHINGTON
# USA EASTERN 4 H BEHIND UTC APR 3 - OCT 30
# USA CENTRAL 6 H BEHIND UTC CHICAGO, HOUSTON
# USA CENTRAL 5 H BEHIND UTC APR 3 - OCT 30
# USA MOUNTAIN 7 H BEHIND UTC DENVER
# USA MOUNTAIN 6 H BEHIND UTC APR 3 - OCT 30
# USA PACIFIC 8 H BEHIND UTC L.A., SAN FRANCISCO
# USA PACIFIC 7 H BEHIND UTC APR 3 - OCT 30
# USA ALASKA STD 9 H BEHIND UTC MOST OF ALASKA (AKST)
# USA ALASKA STD 8 H BEHIND UTC APR 3 - OCT 30 (AKDT)
# USA ALEUTIAN 10 H BEHIND UTC ISLANDS WEST OF 170W
# USA - " - 9 H BEHIND UTC APR 3 - OCT 30
# USA HAWAII 10 H BEHIND UTC
# USA BERING 11 H BEHIND UTC SAMOA, MIDWAY
# From Arthur David Olson (January 21, 1989):
# The above dates are for 1988.
# Note the "AKST" and "AKDT" abbreviations, the claim that there's
# no DST in Samoa, and the claim that there is DST in Alaska and the
# Aleutians.
# From Arthur David Olson (February 13, 1988):
# Legal standard time zone names, from United States Code (1982 Edition and
# Supplement III), Title 15, Chapter 6, Section 260 and forward. First, names
# up to April 1, 1967 (when most provisions of the Uniform Time Act of 1966
# took effect), as explained in sections 263 and 261:
# (none)
# United States standard eastern time
# United States standard mountain time
# United States standard central time
# United States standard Pacific time
# (none)
# United States standard Alaska time
# (none)
# Next, names from April 1, 1967 until November 30, 1983 (the date for
# public law 98-181):
# Atlantic standard time
# eastern standard time
# central standard time
# mountain standard time
# Pacific standard time
# Yukon standard time
# Alaska-Hawaii standard time
# Bering standard time
# And after November 30, 1983:
# Atlantic standard time
# eastern standard time
# central standard time
# mountain standard time
# Pacific standard time
# Alaska standard time
# Hawaii-Aleutian standard time
# Samoa standard time
# The law doesn't give abbreviations.
# Easy stuff first--including Alaska, where we ignore history (since we
# can't tell if we should give Yukon time or Alaska-Hawaii time for "old"
# times).
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone US/Eastern -5:00 US E%sT
Zone US/Central -6:00 US C%sT
Zone US/Mountain -7:00 US M%sT
Zone US/Pacific -8:00 US P%sT
Zone US/Alaska -9:00 US AK%sT # Abbreviation per USNO
# Mainland US areas that are always Standard as of 1986.
Zone US/East-Indiana -5:00 US E%sT 1946
-5:00 - EST # Always EST as of 1986
Zone US/Arizona -7:00 US M%sT 1946
-7:00 - MST # Always MST as of 1986
# From Arthur David Olson (February 13, 1988):
# However. . .a writer from the Inter Tribal Council of Arizona, Inc.,
# notes in private correspondence dated 12/28/87 that "Presently, only the
# Navajo Nation participates in the Daylight Saving Time policy, due to its
# large size and location in three states." (The "only" means that other
# tribal nations don't use DST.)
Link US/Mountain Navajo
# From Bob Devine (January 28, 1988):
# Michigan didn't observe DST from 1968 to 1973.
Zone US/Michigan -5:00 US E%sT 1968
-5:00 - EST 1973
-5:00 US E%sT
# Samoa just changes names. No DST, per Naval Observatory.
Zone US/Samoa -11:00 - NST 1967 Apr 1 # N=Nome
-11:00 - BST 1983 Nov 30 # B=Bering
-11:00 - SST # S=Samoa
# Aleutian has a name change. DST, per Naval Observatory.
Zone US/Aleutian -10:00 US AH%sT 1983 Nov 30
-10:00 US HA%sT
# From Arthur David Olson:
# And then there's Hawaii.
# DST was observed for one day in 1933;
# Standard time was change by half an hour in 1947;
# it's always standard as of 1986.
Zone US/Hawaii -10:30 US H%sT 1933 Apr 30 2:00
-10:30 1:00 HDT 1933 May 1 2:00
-10:30 US H%sT 1947 Jun 8 2:00
-10:00 - HST
# Old names, for S5 users
# Link LINK-FROM LINK-TO
# Link US/Eastern EST5EDT
# Link US/Central CST6CDT
# Link US/Mountain MST7MDT
# Link US/Pacific PST8PDT
# Link US/East-Indiana EST
# Link US/Arizona MST
# Link US/Hawaii HST
################################################################################
# Canada
# Canada is reportedly lots easier than the US--leastways since 1951.
# I don't know what they did before then.
# 4.3BSD claims that it's perfectly regular.
# According to a posting in "comp.bugs.misc", "comp.unix.wizards", etc.
# on February 8, 1987, by Dave Sherman of the Law Society of Upper Canada,
# "...Canada (well, Ontario and at least some of the other provinces) are
# adopting the new daylight savings time rules...". We assume all of
# Canada is doing so.
# From Bob Devine (January 28, 1988):
# All of Canada did have DST from your first rule except Saskatchewan.
# Which parts did not observe DST is hard to pinpoint but most of the
# province follows the rules.
# NOTE: those that didn't have DST for that rule, also
# probably did not have it for several years previous.
# From U. S. Naval Observatory (January 19, 1989):
# CANADA NEW FDL 3.5H BEHIND UTC ST.JOHN'S
# CANADA NEW FDL 1.5H BEHIND UTC APR 3 - OCT 29
# CANADA ATLANTIC 4 H BEHIND UTC HALIFAX
# CANADA ATLANTIC 3 H BEHIND UTC APR 3 - OCT 29
# CANADA EASTERN 5 H BEHIND UTC TORONTO, MONTREAL, OTTAWA
# CANADA EASTERN 4 H BEHIND UTC APR 3 - OCT 29
# CANADA CENTRAL 6 H BEHIND UTC REGINA, WINNIPEG
# CANADA CENTRAL 5 H BEHIND UTC APR 3 - OCT 29
# CANADA MOUNTAIN 7 H BEHIND UTC CALGARY, EDMONTON
# CANADA MOUNTAIN 6 H BEHIND UTC APR 3 - OCT 29
# CANADA PACIFIC 8 H BEHIND UTC VANCOUVER
# CANADA PACIFIC 7 H BEHIND UTC APR 3 - OCT 29
# CANADA YUKON SAME AS PACIFIC DAWSON
# From Arthur David Olson (January 21, 1989):
# April 3 fell on a Sunday in 1988; October 29 fell on a Sunday in 1989. Ahem.
# Note claim that there's double DST in Newfoundland and that Yukon should
# be same as Pacific. Stick with rules posted in 1988 until more authoritative
# information is available.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Canada 1969 max - Oct lastSun 2:00 0 S
Rule Canada 1969 1986 - Apr lastSun 2:00 1:00 D
Rule Canada 1987 max - Apr Sun>=1 2:00 1:00 D
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
# Bob Devine says that DST *is* observed in Newfoundland
Zone Canada/Newfoundland -3:30 Canada N%sT
Zone Canada/Atlantic -4:00 Canada A%sT
Zone Canada/Eastern -5:00 Canada E%sT
Zone Canada/Central -6:00 Canada C%sT
Zone Canada/East-Saskatchewan -6:00 - CST # No DST as of 1987
Zone Canada/Mountain -7:00 Canada M%sT
Zone Canada/Pacific -8:00 Canada P%sT
Zone Canada/Yukon -9:00 Canada Y%sT
###############################################################################
# Mexico
# From Guy Harris:
# Rules are from the Official Airline Guide, Worldwide Edition, for 1987.
# Rules prior to 1987 are unknown.
# The comments in the OAG say "Only Ensenada, Mexicale, San Felipe and Tijuana
# observe DST." This is presumably Baja California Norte, above 28th parallel,
# as listed there; Mexico/BajaSur is for "Baja California Sur and N. Pacific
# Coast (States of Sinaloa and Sonora)."
# From Bob Devine (January 28, 1988):
# The Federal District (where Mexico City is) has observed [DST] several
# times but not recently.
#
# I don't where to drawn the line in the North Baja area. 28th latitude
# sounds good -- but it may be higher (how far [d]o radio stations from
# San Diego affect culture?).
#
# The dates of DST probably go back to 1981. The rules are the same as
# US's. This is going to be a headache for US presidential electi[o]n years!
# From Arthur David Olson (February 13, 1988)
# Since the 1981 starting date is only "probable," we'll keep the 1987
# starting date below.
# From U. S. Naval Observatory (January 19, 1989):
# MEXICO BAJA CAL N 7 H BEHIND UTC BAJA CALIFORNIA SUR AND
# MEXICO BAJA CAL N N. PACIFIC COAST (STATES
# MEXICO BAJA CAL N OF SINALOA AND SONORA)
# MEXICO BAJA CAL N 8 H BEHIND UTC ABOVE 28TH PARALLAL APR 3
# MEXICO BAJA CAL N - OCT 29
# MEXICO BAJA CAL N 7 H BEHIND UTC ABOVE 28TH PARALLAL APR 3
# MEXICO BAJA CAL N - 0CT 29
# MEXICO 6 H BEHIND UTC STATES OF DURANGO,
# MEXICO COAHUILA, NUEVO LEON,
# MEXICO TAMAULIPAS
# MEXICO 5 H BEHIND UTC STATES OF DURANGO,
# MEXICO COAHUILA, NUEVO LEON,
# MEXICO TAMAULIPAS APR 3 - OCT 29
# MEXICO 6 H BEHIND UTC GENERAL MEXICO, STATES OF
# MEXICO CAMPECHE, QUINTANA ROO AND
# MEXICO YUCATAN
# From Arthur David Olson (January 21, 1989):
# April 3 fell on a Sunday in 1988; October 29 fell on a Sunday in 1989. Ahem.
# USNO claims there should be four Mexican zones rather than three:
# a zone that's GMT-8 with DST; a zone that's always GMT-7;
# a zone that's GMT-6 with DST; and a zone that's always GMT-6.
# Wait for more authoritative information before changing.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mexico 1987 max - Oct lastSun 2:00 0 S
Rule Mexico 1987 max - Apr Sun>=1 2:00 1:00 D
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Mexico/BajaNorte -8:00 Mexico P%sT
Zone Mexico/BajaSur -7:00 - MST
Zone Mexico/General -6:00 - CST
###############################################################################
# Jamaica
# From Bob Devine (January 28, 1988):
# Follows US rules.
# From U. S. Naval Observatory (January 19, 1989):
# JAMAICA 5 H BEHIND UTC
Link US/Eastern Jamaica
###############################################################################
# Cuba
# From Bob Devine (January 28, 1988):
# . . .DST is from 2nd Sunday in May to 2nd Sunday in October since 1981.
# Change at midnight. In 1979 & 1980, started at 3rd Sunday in March
# (I think).
# From U. S. Naval Observatory (January 19, 1989):
# CUBA 5 H BEHIND UTC
# CUBA 4 H BEHIND UTC MAR 20 - OCT 8
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Cuba 1979 1980 - Mar Sun>=15 0:00 1:00 D
Rule Cuba 1979 1980 - Oct Sun>=8 0:00 0 S
Rule Cuba 1981 max - May Sun>=8 0:00 1:00 D
Rule Cuba 1981 max - Oct Sun>=8 0:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT
Zone Cuba -5:00 Cuba C%sT

View File

@@ -0,0 +1,90 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
/* How many days are in each month. */
CONST unsigned short int __mon_lengths[2][12] =
{
/* Normal years. */
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
/* Leap years. */
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
#define SECS_PER_HOUR (60 * 60)
#define SECS_PER_DAY (SECS_PER_HOUR * 24)
/* Returns the `struct tm' representation of *T,
offset OFFSET seconds east of UCT. */
struct tm *
DEFUN(__offtime, (t, offset), CONST time_t *t AND long int offset)
{
static struct tm tbuf;
register long int days, rem;
register int y;
register CONST unsigned short int *ip;
if (t == NULL)
return NULL;
days = *t / SECS_PER_DAY;
rem = *t % SECS_PER_DAY;
rem += offset;
while (rem < 0)
{
rem += SECS_PER_DAY;
--days;
}
while (rem >= SECS_PER_DAY)
{
rem -= SECS_PER_DAY;
++days;
}
tbuf.tm_hour = rem / SECS_PER_HOUR;
rem %= SECS_PER_HOUR;
tbuf.tm_min = rem / 60;
tbuf.tm_sec = rem % 60;
/* January 1, 1970 was a Thursday. */
tbuf.tm_wday = (4 + days) % 7;
if (tbuf.tm_wday < 0)
tbuf.tm_wday += 7;
y = 1970;
while (days >= (rem = __isleap(y) ? 366 : 365))
{
++y;
days -= rem;
}
while (days < 0)
{
--y;
days += __isleap(y) ? 366 : 365;
}
tbuf.tm_year = y - 1900;
tbuf.tm_yday = days;
ip = __mon_lengths[__isleap(y)];
for (y = 0; days >= ip[y]; ++y)
days -= ip[y];
tbuf.tm_mon = y;
tbuf.tm_mday = days + 1;
tbuf.tm_isdst = -1;
return &tbuf;
}

View File

@@ -0,0 +1,20 @@
# @(#)pacificnew 7.1
# From Arthur David Olson (April 5, 1989):
# On April 5, 1989, the U. S. House of Representatives passed (238-154) a bill
# establishing "Pacific Presidential Election Time"; it has yet to be acted on
# by the Senate or signed into law by the President.
# You might want to change the "PE" (Presidential Election) below to
# "Q" (Quadrennial) to maintain three-character zone abbreviations.
# If you're really conservative, you might want to change it to "D".
# Avoid "L" (Leap Year), which won't be true in 2100.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Twilite 1989 max - Apr Sun>=1 2:00 1:00 D
Rule Twilite 1989 max uspres Oct lastSun 2:00 1:00 PE
Rule Twilite 1989 max uspres Nov Sun>=7 2:00 0 S
Rule Twilite 1989 max nonpres Oct lastSun 2:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone US/Pacific-New -8:00 US P%sT 1989
-8:00 Twilite P%sT

View File

@@ -0,0 +1,168 @@
#ifndef PRIVATE_H
#define PRIVATE_H
/*
** This header is for use ONLY with the time conversion code.
** There is no guarantee that it will remain unchanged,
** or that it will remain at all.
** Do NOT copy it to any system include directory.
** Thank you!
*/
/*
** ID
*/
#ifndef lint
#ifndef NOID
static char privatehid[] = "@(#)private.h 7.1";
#endif /* !defined NOID */
#endif /* !defined lint */
/*
** const
*/
#ifndef const
#ifndef __STDC__
#define const
#endif /* !defined __STDC__ */
#endif /* !defined const */
/*
** void
*/
#ifndef void
#ifndef __STDC__
#ifndef vax
#ifndef sun
#define void char
#endif /* !defined sun */
#endif /* !defined vax */
#endif /* !defined __STDC__ */
#endif /* !defined void */
/*
** P((args))
*/
#ifndef P
#ifdef __STDC__
#define P(x) x
#else /* !defined __STDC__ */
#define ASTERISK *
#define P(x) ( /ASTERISK x ASTERISK/ )
#endif /* !defined __STDC__ */
#endif /* !defined P */
/*
** genericptr_t
*/
#ifdef __STDC__
typedef void * genericptr_t;
#else /* !defined __STDC__ */
typedef char * genericptr_t;
#endif /* !defined __STDC__ */
#include "sys/types.h" /* for time_t */
#include "stdio.h"
#include "ctype.h"
#include "errno.h"
#include "string.h"
#ifndef _TIME_
#include "time.h"
#endif /* !defined _TIME_ */
#ifndef remove
extern int unlink P((const char * filename));
#define remove unlink
#endif /* !defined remove */
#ifndef FILENAME_MAX
#ifndef MAXPATHLEN
#ifdef unix
#include "sys/param.h"
#endif /* defined unix */
#endif /* !defined MAXPATHLEN */
#ifdef MAXPATHLEN
#define FILENAME_MAX MAXPATHLEN
#else /* !defined MAXPATHLEN */
#define FILENAME_MAX 1024 /* Pure guesswork */
#endif /* !defined MAXPATHLEN */
#endif /* !defined FILENAME_MAX */
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif /* !defined EXIT_FAILURE */
#ifdef __STDC__
#define alloc_size_t size_t
#define qsort_size_t size_t
#define fwrite_size_t size_t
#else /* !defined __STDC__ */
#ifndef alloc_size_t
#define alloc_size_t unsigned
#endif /* !defined alloc_size_t */
#ifndef qsort_size_t
#ifdef USG
#define qsort_size_t unsigned
#else /* !defined USG */
#define qsort_size_t int
#endif /* !defined USG */
#endif /* !defined qsort_size_t */
#ifndef fwrite_size_t
#define fwrite_size_t int
#endif /* !defined fwrite_size_t */
#ifndef USG
extern char * sprintf P((char * buf, const char * format, ...));
#endif /* !defined USG */
#endif /* !defined __STDC__ */
/*
** Ensure that these are declared--redundantly declaring them shouldn't hurt.
*/
extern char * getenv P((const char * name));
extern genericptr_t malloc P((alloc_size_t size));
extern genericptr_t calloc P((alloc_size_t nelem, alloc_size_t elsize));
extern genericptr_t realloc P((genericptr_t oldptr, alloc_size_t newsize));
#ifdef USG
extern void exit P((int s));
extern void qsort P((genericptr_t base, qsort_size_t nelem,
qsort_size_t elsize, int (*comp)()));
extern void perror P((const char * string));
extern void free P((char * buf));
#endif /* defined USG */
#ifndef TRUE
#define TRUE 1
#endif /* !defined TRUE */
#ifndef FALSE
#define FALSE 0
#endif /* !defined FALSE */
/*
** UNIX is a registered trademark of AT&T.
** VAX is a trademark of Digital Equipment Corporation.
*/
#endif /* !defined PRIVATE_H */

View File

@@ -0,0 +1,65 @@
#ifdef LIBC
#include <ansidecl.h>
#endif
#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)scheck.c 8.10";
#endif /* !defined lint */
#endif /* !defined NOID */
/*LINTLIBRARY*/
#include "private.h"
extern char * imalloc P((int n));
extern void ifree P((char * p));
char *
scheck(string, format)
const char * const string;
const char * const format;
{
register char * fbuf;
register const char * fp;
register char * tp;
register int c;
register char * result;
char dummy;
result = "";
if (string == NULL || format == NULL)
return result;
fbuf = imalloc(2 * strlen(format) + 4);
if (fbuf == NULL)
return result;
fp = format;
tp = fbuf;
while ((*tp++ = c = *fp++) != '\0') {
if (c != '%')
continue;
if (*fp == '%') {
*tp++ = *fp++;
continue;
}
*tp++ = '*';
if (*fp == '*')
++fp;
while (isascii(*fp) && isdigit(*fp))
*tp++ = *fp++;
if (*fp == 'l' || *fp == 'h')
*tp++ = *fp++;
else if (*fp == '[')
do *tp++ = *fp++;
while (*fp != '\0' && *fp != ']');
if ((*tp++ = *fp++) == '\0')
break;
}
*(tp - 1) = '%';
*tp++ = 'c';
*tp = '\0';
if (sscanf(string, fbuf, &dummy) != 1)
result = (char *) format;
ifree(fbuf);
return result;
}

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
#include <sys/time.h>
#undef setitimer
#include <gnu-stabs.h>
function_alias(setitimer, __setitimer, int, (which, old, new),
DEFUN(setitimer, (which, old, new),
enum __itimer_which which AND
struct itimerval *old AND struct itimerval *new))

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
#include <sys/time.h>
#undef settimeofday
#include <gnu-stabs.h>
function_alias(settimeofday, __settimeofday, int, (tv, tz),
DEFUN(settimeofday, (tv, tz),
CONST struct timeval *tv AND CONST struct timezone *tz))

View File

@@ -0,0 +1,103 @@
# @(#)southamerica 7.1
# From Guy Harris:
# From Official Airline Guide - Worldwide Edition (1987). Countries not
# listed here do not observe DST, according to the OAG. Time zone names
# are pure inventions, and none are supplied for countries not observing
# DST; updates from natives would be appreciated. The times that DST
# starts and ends are based on the assumption that they switch a 2AM just
# as everybody else does.
###############################################################################
# Brazil
# From Guy Harris:
# The OAG lists October 25, 1987 and February 12, 1988 as the starting and
# ending dates, giving them as "estimated date(s) based on previous year". We
# infer a rule here from one example, always a dangerous practice.... Yes,
# they really do switch on Saturday, according to the OAG.
# "Brazil/Acre" is for the Territory of Acre; "Brazil/DeNoronha" is for
# Fernando De Noronha.
# From Bob Devine (January 28, 1988):
# The only information I found is that there was no DST up to 1985.
# But there was some before 1952!
# From U. S. Naval Observatory (January 16, 1989):
# BRAZIL WEST 5 H BEHIND UTC TERRITORY OF ACRE
# BRAZIL WEST 4 H BEHIND UTC ACRE OCT 23, '88-FEB 11,
# BRAZIL '89 (ESTIMATED)
# BRAZIL CENTRAL 4 H BEHIND UTC MANAUS
# BRAZIL CENTRAL 3 H BEHIND UTC MANAUS OCT 23, '88-FEB 11,
# BRAZIL CENTRAL '89 (ESTIMATED)
# BRAZIL EAST 3 H BEHIND UTC COASTAL STATES, RIO, SAO
# BRAZIL EAST PAULO, BRASILIA
# BRAZIL EAST 2 H BEHIND UTC COASTAL STATES, RIO, SAO
# BRAZIL PAULO, BRASILIA OCT 23,
# BRAZIL '88-FEB 11, '89
# BRAZIL (ESTIMATED)
# BRAZIL 2 H BEHIND UTC ATLANTIC ISLANDS, FERNANDO
# BRAZIL DE NORONHA
# BRAZIL 1 H BEHIND UTC OCT 23, '88-FEB 11, '89
# BRAZIL (ESTIMATED)
# BRAZIL 3 H BEHIND UTC FOR MOST MAJOR AIRPORTS.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Brazil 1987 max - Feb Sat<=14 2:00 0 S
Rule Brazil 1987 max - Oct Sat<=28 2:00 1:00 D
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Brazil/East -3:00 Brazil E%sT
Zone Brazil/West -4:00 Brazil W%sT
Zone Brazil/Acre -5:00 Brazil A%sT
Zone Brazil/DeNoronha -2:00 Brazil F%sT
###############################################################################
# Chile
# From Guy Harris:
# The OAG lists October 11, 1987 and March 12, 1988 as the starting and
# ending dates, giving them as "estimated date(s) based on previous year."
# From Bob Devine (January 28, 1988):
# Chile has had 2nd Sunday in October to 2nd Sunday in March DST since 1977.
# Switch is at midnight. OAG is right.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Chile 1977 max - Oct Sun>=8 0:00 1:00 D
Rule Chile 1978 max - Mar Sun>=8 0:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone Chile/Continental -4:00 Chile C%sT
Zone Chile/EasterIsland -6:00 Chile E%sT
###############################################################################
# Paraguay
# From Bob Devine (January 28, 1988):
# Paraguay: First day in October to last in March. Midnight switch??
# Since 1980.
# From U. S. Naval Observatory (January 19, 1989):
# PARAGUAY 4 H BEHIND UTC
# PARAGUAY 3 H BEHIND UTC OCT 1, '88-MAR 31, '89
# From Arthur David Olson (January 21, 1989):
# Still don't know time of day when switch occurs. Punt.
###############################################################################
# Argentina
# From Bob Devine (January 28, 1988):
# Argentina: first Sunday in October to first Sunday in April since 1976.
# Double Summer time from 1969 to 1974. Switches at midnight.
# From U. S. Naval Observatory (January 19, 19889):
# ARGENTINA 3 H BEHIND UTC
# From Arthur David Olson (January 21, 1989):
# OAG, USNO and Bob have different data. Punt.

View File

@@ -0,0 +1,260 @@
/* Extensions for GNU date that are still missing here:
-
_
e
*/
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <localeinfo.h>
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifndef HAVE_GNU_LD
#define __tzname tzname
#define __daylight daylight
#define __timezone timezone
#endif
#define add(n, f) \
do \
{ \
i += (n); \
if (i >= maxsize) \
return 0; \
else \
if (p != NULL) \
{ \
f; \
p += (n); \
} \
} while (0)
#define cpy(n, s) add((n), memcpy((PTR) p, (PTR) (s), (n)))
#define fmt(n, args) add((n), if (sprintf args != (n)) return 0)
/* Return the week in the year specified by TP,
with weeks starting on STARTING_DAY. */
#ifdef __GNUC__
inline
#endif
static unsigned int
DEFUN(week, (tp, starting_day),
CONST struct tm *CONST tp AND int starting_day)
{
int wday, dl;
wday = tp->tm_wday - starting_day;
if (wday < 0)
wday += 7;
/* Set DL to the day in the year of the last day of the week previous to the
one containing the day specified in TP. If DL is negative or zero, the
day specified in TP is in the first week of the year. Otherwise,
calculate the number of complete weeks before our week (DL / 7) and
add any partial week at the start of the year (DL % 7). */
dl = tp->tm_yday - wday;
return dl <= 0 ? 0 : ((dl / 7) + ((dl % 7) == 0 ? 0 : 1));
}
/* Write information from TP into S according to the format
string FORMAT, writing no more that MAXSIZE characters
(including the terminating '\0') and returning number of
characters written. If S is NULL, nothing will be written
anywhere, so to determine how many characters would be
written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */
size_t
DEFUN(strftime, (s, maxsize, format, tp),
char *s AND size_t maxsize AND
CONST char *format AND register CONST struct tm *tp)
{
CONST char *CONST a_wkday = _time_info->abbrev_wkday[tp->tm_wday];
CONST char *CONST f_wkday = _time_info->full_wkday[tp->tm_wday];
CONST char *CONST a_month = _time_info->abbrev_month[tp->tm_mon];
CONST char *CONST f_month = _time_info->full_month[tp->tm_mon];
size_t aw_len = strlen(a_wkday);
size_t am_len = strlen(a_month);
size_t wkday_len = strlen(f_wkday);
size_t month_len = strlen(f_month);
int hour12 = tp->tm_hour;
CONST char *CONST ampm = _time_info->ampm[hour12 >= 12];
size_t ap_len = strlen(ampm);
CONST unsigned int y_week0 = week(tp, 0);
CONST unsigned int y_week1 = week(tp, 1);
CONST char *zone;
size_t zonelen;
register size_t i = 0;
register char *p = s;
register CONST char *f;
if (tp->tm_isdst < 0)
{
zone = "";
zonelen = 0;
}
else
{
zone = __tzname[tp->tm_isdst];
zonelen = strlen(zone);
}
if (hour12 > 12)
hour12 -= 12;
else
if (hour12 == 0) hour12 = 12;
for (f = format; *f != '\0'; ++f)
{
CONST char *subfmt;
if (!isascii(*f))
{
/* Non-ASCII, may be a multibyte. */
int len = mblen(f, strlen(f));
if (len > 0)
{
cpy(len, f);
continue;
}
}
if (*f != '%')
{
add(1, *p = *f);
continue;
}
++f;
switch (*f)
{
case '\0':
case '%':
add(1, *p = *f);
break;
case 'n': /* GNU extension. */
add (1, *p = '\n');
break;
case 't': /* GNU extenstion. */
add (1, *p = '\t');
break;
case 'a':
cpy(aw_len, a_wkday);
break;
case 'A':
cpy(wkday_len, f_wkday);
break;
case 'b':
cpy(am_len, a_month);
break;
case 'B':
cpy(month_len, f_month);
break;
case 'c':
subfmt = _time_info->date_time;
subformat:;
{
size_t len = strftime(p, maxsize - i, subfmt, tp);
add(len, );
}
break;
case 'd':
fmt(2, (p, "%.2d", tp->tm_mday));
break;
case 'H':
fmt(2, (p, "%.2d", tp->tm_hour));
break;
case 'I':
fmt(2, (p, "%.2d", hour12));
break;
case 'j':
fmt(3, (p, "%.3d", tp->tm_yday));
break;
case 'm':
fmt(2, (p, "%.2d", tp->tm_mon + 1));
break;
case 'M':
fmt(2, (p, "%.2d", tp->tm_min));
break;
case 'p':
cpy(ap_len, ampm);
break;
case 'S':
fmt(2, (p, "%.2d", tp->tm_sec));
break;
case 'U':
fmt(2, (p, "%.2u", y_week0));
break;
case 'w':
fmt(2, (p, "%.2d", tp->tm_wday));
break;
case 'W':
fmt(2, (p, "%.2u", y_week1));
break;
case 'x':
subfmt = _time_info->date;
goto subformat;
case 'X':
subfmt = _time_info->time;
goto subformat;
case 'y':
fmt(2, (p, "%.2d", tp->tm_year));
break;
case 'Y':
fmt(4, (p, "%.4d", 1900 + tp->tm_year));
break;
case 'Z':
cpy(zonelen, zone);
break;
/* GNU extensions. */
case 'r':
subfmt = "%I:%M:%S %p";
goto subformat;
case 'R':
subfmt = "%H:%M";
goto subformat;
case 'T':
subfmt = "%H:%M:%S";
goto subformat;
case 'D':
subfmt = "%m/%d/%y";
goto subformat;
case 'e': /* %d, but blank-padded. */
/* XXX */
break;
default:
/* Bad format. */
break;
}
}
if (p != NULL)
*p = '\0';
return(i);
}

View File

@@ -0,0 +1,34 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifdef HAVE_GNU_LD
#include <ansidecl.h>
#include <time.h>
#undef tzname
#undef timezone
#undef daylight
#include <gnu-stabs.h>
symbol_alias(__tzname, tzname);
symbol_alias(__timezone, timezone);
symbol_alias(__daylight, daylight);
#endif

View File

@@ -0,0 +1,95 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _SYS_TIME_H
#if !defined(__need_timeval)
#define _SYS_TIME_H 1
#include <features.h>
#endif
#include <gnu/time.h>
#ifdef _SYS_TIME_H
#include <time.h>
#endif
#if (!defined(__timeval_defined) && \
(defined(_SYS_TIME_H) || defined(__need_timeval)))
#define __timeval_defined 1
#define timeval __timeval
#endif
#undef __need_timeval
/* <time.h> already does #define timezone __timezone. */
#ifdef _SYS_TIME_H
#define itimerval __itimerval
/* Get the current time of day and timezone information,
putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
Returns 0 on success, -1 on errors.
NOTE: This form of timezone information is obsolete.
Use the functions and variables declared in <time.h> instead. */
extern int EXFUN(__gettimeofday, (struct __timeval *__tv,
struct __timezone *__tz));
/* Set the current time of day and timezone information.
This call is restricted to the super-user. */
extern int EXFUN(__settimeofday, (CONST struct __timeval *__tv,
CONST struct __timezone *__tz));
/* Adjust the current time of day by the amount in DELTA.
If OLDDELTA is not NULL, it is filled in with the amount
of time adjustment remaining to be done from the last `adjtime' call.
This call is restricted to the super-user. */
extern int EXFUN(__adjtime, (CONST struct __timeval *__delta,
struct __timeval *__olddelta));
#define gettimeofday __gettimeofday
#define settimeofday __settimeofday
#define adjtime __adjtime
/* Set *VALUE to the current setting of timer WHICH.
Return 0 on success, -1 on errors. */
extern int EXFUN(__getitimer, (enum __itimer_which __which,
struct __itimerval *__value));
/* Set the timer WHICH to *NEW. If OLD is not NULL,
set *OLD to the old value of timer WHICH.
Returns 0 on success, -1 on errors. */
extern int EXFUN(__setitimer, (enum __itimer_which __which,
struct __itimerval *__old,
struct __itimerval *__new));
/* Change the access time of FILE to TVP[0] and
the modification time of FILE to TVP[1]. */
extern int EXFUN(__utimes, (CONST char *__file, struct __timeval __tvp[2]));
#define getitimer __getitimer
#define setitimer __setitimer
#define utimes __utimes
#endif /* <sys/time.h> included. */
#endif /* sys/time.h */

View File

@@ -0,0 +1,35 @@
# @(#)systemv 7.1
# Old rules, should the need arise.
# No attempt is made to handle Newfoundland, since it cannot be expressed
# using the System V "TZ" scheme (half-hour offset), or anything outside
# North America (no support for non-standard DST start/end dates), nor
# the change in the DST rules in the US in 1987 (can't split between
# Canada, with no changes, and the US)
#
# Be sure to compile this *without* leap second correction for true conformance.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule SystemV min 1973 - Apr lastSun 2:00 1:00 D
Rule SystemV min 1973 - Oct lastSun 2:00 0 S
Rule SystemV 1974 only - Jan 6 2:00 1:00 D
Rule SystemV 1974 only - Nov lastSun 2:00 0 S
Rule SystemV 1975 only - Feb 23 2:00 1:00 D
Rule SystemV 1975 only - Oct lastSun 2:00 0 S
Rule SystemV 1976 max - Apr lastSun 2:00 1:00 D
Rule SystemV 1976 max - Oct lastSun 2:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone SystemV/AST4ADT -4:00 SystemV A%sT
Zone SystemV/EST5EDT -5:00 SystemV E%sT
Zone SystemV/CST6CDT -6:00 SystemV C%sT
Zone SystemV/MST7MDT -7:00 SystemV M%sT
Zone SystemV/PST8PDT -8:00 SystemV P%sT
Zone SystemV/YST9YDT -9:00 SystemV Y%sT
Zone SystemV/AST4 -4:00 - AST
Zone SystemV/EST5 -5:00 - EST
Zone SystemV/CST6 -6:00 - CST
Zone SystemV/MST7 -7:00 - MST
Zone SystemV/PST8 -8:00 - PST
Zone SystemV/YST9 -9:00 - YST
Zone SystemV/HST10 -10:00 - HST

View File

@@ -0,0 +1 @@
EST5EDT

View File

@@ -0,0 +1,106 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int
DEFUN(main, (argc, argv), int argc AND char **argv)
{
time_t t;
register struct tm *tp;
struct tm tbuf;
int lose = 0;
--argc;
++argv;
do
{
char buf[BUFSIZ];
if (argc > 0)
{
static char buf[BUFSIZ];
sprintf(buf, "TZ=%s", *argv);
if (putenv(buf))
{
puts("putenv failed.");
lose = 1;
}
else
puts (buf);
}
tzset();
tbuf.tm_year = 72;
tbuf.tm_mon = 0;
tbuf.tm_mday = 31;
tbuf.tm_hour = 6;
tbuf.tm_min = 14;
tbuf.tm_sec = 50;
doit:;
t = mktime(&tbuf);
if (t == (time_t) -1)
{
puts("mktime() failed?");
lose = 1;
}
tp = localtime(&t);
if (tp == NULL)
{
puts("localtime() failed.");
lose = 1;
}
else if (strftime(buf, sizeof(buf), "%a %b %d %X %Z %Y", tp) == 0)
{
puts("strftime() failed.");
lose = 1;
}
else
puts(buf);
if (tbuf.tm_year == 101)
{
tbuf.tm_year = 97;
tbuf.tm_mon = 0;
goto doit;
}
++argv;
} while (--argc > 0);
{
#define SIZE 256
char buffer[SIZE];
time_t curtime;
struct tm *loctime;
curtime = time (NULL);
loctime = localtime (&curtime);
fputs (asctime (loctime), stdout);
strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
fputs (buffer, stdout);
strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
fputs (buffer, stdout);
}
exit(lose ? EXIT_FAILURE : EXIT_SUCCESS);
}

View File

@@ -0,0 +1,183 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* ANSI Standard: 4.12 DATE and TIME <time.h>
*/
#ifndef _TIME_H
#if !defined(__need_time_t) && !defined(__need_clock_t)
#define _TIME_H 1
#include <features.h>
#endif
#ifdef _TIME_H
/* Get size_t and NULL from <stddef.h>. */
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#endif /* <time.h> included. */
#ifdef _TIME_H
/* Processor clock ticks per second. */
#define CLOCKS_PER_SEC 1 /* ??? */
#ifdef __USE_POSIX
#define CLK_TCK 60 /* ??? */
#endif
#endif /* <time.h> included. */
#if !defined(__clock_t_defined) && \
(defined(_TIME_H) || defined(__need_clock_t))
#define __clock_t_defined 1
/* Returned by `clock'. */
typedef long int clock_t;
#endif /* clock_t not defined and <time.h> or need clock_t. */
#undef __need_clock_t
#if !defined(__time_t_defined) && \
(defined(_TIME_H) || defined(__need_time_t))
#define __time_t_defined 1
#include <gnu/types.h>
/* Returned by `time'. */
typedef __time_t time_t;
#endif /* time_t not defined and <time.h> or need time_t. */
#undef __need_time_t
#ifdef _TIME_H
/* Used by other time functions. */
struct tm
{
int tm_sec; /* Seconds. [0-61] (2 leap seconds) */
int tm_min; /* Minutes. [0-59] */
int tm_hour; /* Hours. [0-23] */
int tm_mday; /* Day. [1-31] */
int tm_mon; /* Month. [0-11] */
int tm_year; /* Year - 1900. */
int tm_wday; /* Day of week. [0-6] */
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/
long int tm_gmtoff; /* Seconds west of UTC. */
CONST char *tm_zone;/* Timezone abbreviation. */
};
#endif /* <time.h> included. */
#ifdef _TIME_H
/* Time used by the program so far (user time + system time).
The result / CLOCKS_PER_SECOND is program time in seconds. */
extern clock_t EXFUN(clock, (NOARGS));
/* Return the current time and put it in *TIMER if TIMER is not NULL. */
extern time_t EXFUN(time, (time_t *__timer));
#ifndef __CONSTVALUE
#ifdef __GNUC__
/* The `const' keyword tells GCC that a function's return value is
based solely on its arguments, and there are no side-effects. */
#define __CONSTVALUE __const
#else
#define __CONSTVALUE
#endif /* GCC. */
#endif /* __CONSTVALUE not defined. */
/* Return the difference between TIME1 and TIME0. */
extern __CONSTVALUE double EXFUN(difftime, (time_t __time1, time_t __time0));
/* Return the `time_t' representation of TP and normalize TP. */
extern time_t EXFUN(mktime, (struct tm *__tp));
/* Format TP into S according to FORMAT.
Write no more than MAXSIZE characters and return the number
of characters written, or 0 if it would exceed MAXSIZE. */
extern size_t EXFUN(strftime, (char *__s, size_t __maxsize,
CONST char *__format, CONST struct tm *__tp));
/* Return the `struct tm' representation of *TIMER
in Universal Coordinated Time (aka Greenwich Mean Time). */
extern struct tm *EXFUN(gmtime, (CONST time_t *__timer));
/* Return the `struct tm' representation
of *TIMER in the local timezone. */
extern struct tm *EXFUN(localtime, (CONST time_t *__timer));
/* Return the `struct tm' representation of *TIMER,
offset OFFSET seconds east of Universal Coordinated Time. */
extern struct tm *EXFUN(__offtime, (CONST time_t *__timer, long int __offset));
#ifdef __OPTIMIZE__
#define gmtime(timer) __offtime((timer), 0L)
#endif /* Optimizing. */
/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
that is the representation of TP in this format. */
extern char *EXFUN(asctime, (CONST struct tm *__tp));
/* Equivalent to `asctime(localtime(timer))'. */
extern char *EXFUN(ctime, (CONST time_t *__timer));
/* Defined in localtime.c. */
extern char *__tzname[2]; /* Current timezone names. */
extern int __daylight; /* If it is daylight savings time. */
extern long int __timezone; /* Seconds west of UTC. */
/* Set time conversion information from the TZ environment variable.
If TZ is not defined, a locale-dependent default is used. */
extern void EXFUN(__tzset, (NOARGS));
#ifdef __USE_POSIX
/* Same as above. */
extern char *tzname[2];
extern long int EXFUN(__tzname_max, (NOARGS));
extern void EXFUN(tzset, (NOARGS));
#ifdef __OPTIMIZE__
#define tzset() __tzset()
#endif /* Optimizing. */
#endif
#ifdef __USE_SVID
extern int daylight;
extern long int timezone;
#endif
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
#define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
#endif /* <time.h> included. */
#endif /* <time.h> not already included. */

View File

@@ -0,0 +1,279 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <limits.h>
#define NOID
#include <tzfile.h>
#ifndef HAVE_GNU_LD
#define __tzname tzname
#define __daylight daylight
#define __timezone timezone
#endif
int __use_tzfile = 0;
struct ttinfo
{
long int offset; /* Seconds east of GMT. */
unsigned char isdst; /* Used to set tm_isdst. */
unsigned char idx; /* Index into `zone_names'. */
unsigned char isstd; /* Transition times are standard time. */
};
struct leap
{
time_t transition;
long int change;
};
static size_t num_transitions;
static time_t *transitions = NULL;
static unsigned char *type_idxs = NULL;
static size_t num_types;
static struct ttinfo *types = NULL;
static char *zone_names = NULL;
static size_t num_leaps;
static struct leap *leaps = NULL;
#define uc2ul(x) _uc2ul((unsigned char *) (x))
#define _uc2ul(x) \
((x)[3] + ((x)[2] << CHAR_BIT) + ((x)[1] << (2 * CHAR_BIT)) + \
((x)[0] << (3 * CHAR_BIT)))
void
DEFUN(__tzfile_read, (file), CONST char *file)
{
size_t num_isstd;
register FILE *f;
struct tzhead tzhead;
size_t chars;
register size_t i;
__use_tzfile = 0;
if (transitions != NULL)
free((PTR) transitions);
transitions = NULL;
if (type_idxs != NULL)
free((PTR) type_idxs);
type_idxs = NULL;
if (types != NULL)
free((PTR) types);
types = NULL;
if (zone_names != NULL)
free((PTR) zone_names);
zone_names = NULL;
if (leaps != NULL)
free((PTR) leaps);
leaps = NULL;
if (file == NULL || *file == '\0')
file = TZDEFAULT;
if (*file != '/')
{
static CONST char tzdir[] = TZDIR;
register CONST unsigned int len = strlen(file) + 1;
char *new = (char *) __alloca(sizeof(tzdir) + len);
memcpy(new, tzdir, sizeof(tzdir) - 1);
new[sizeof(tzdir) - 1] = '/';
memcpy(&new[sizeof(tzdir)], file, len);
file = new;
}
f = fopen(file, "r");
if (f == NULL)
return;
if (fread((PTR) &tzhead, sizeof(tzhead), 1, f) != 1)
goto lose;
num_transitions = (size_t) uc2ul(tzhead.tzh_timecnt);
num_types = (size_t) uc2ul(tzhead.tzh_typecnt);
chars = (size_t) uc2ul(tzhead.tzh_charcnt);
num_leaps = (size_t) uc2ul(tzhead.tzh_leapcnt);
num_isstd = (size_t) uc2ul(tzhead.tzh_ttisstdcnt);
if (num_transitions > 0)
{
transitions = (time_t *) malloc (num_transitions * sizeof(time_t));
if (transitions == NULL)
goto lose;
type_idxs = (unsigned char *) malloc (num_transitions);
if (type_idxs == NULL)
goto lose;
}
if (num_types > 0)
{
types = (struct ttinfo *) malloc (num_types * sizeof (struct ttinfo));
if (types == NULL)
goto lose;
}
if (chars > 0)
{
zone_names = (char *) malloc (chars);
if (zone_names == NULL)
goto lose;
}
if (num_leaps > 0)
{
leaps = (struct leap *) malloc (num_leaps * sizeof (struct leap));
if (leaps == NULL)
goto lose;
}
if (fread((PTR) transitions, sizeof(time_t),
num_transitions, f) != num_transitions ||
fread((PTR) type_idxs, 1, num_transitions, f) != num_transitions)
goto lose;
for (i = 0; i < num_transitions; ++i)
transitions[i] = uc2ul (&transitions[i]);
for (i = 0; i < num_types; ++i)
{
unsigned char x[4];
if (fread((PTR) x, 1, 4, f) != 4 ||
fread((PTR) &types[i].isdst, 1, 1, f) != 1 ||
fread((PTR) &types[i].idx, 1, 1, f) != 1)
goto lose;
types[i].offset = (long int) uc2ul(x);
}
if (fread((PTR) zone_names, 1, chars, f) != chars)
goto lose;
for (i = 0; i < num_leaps; ++i)
{
unsigned char x[4];
if (fread((PTR) x, 1, sizeof(x), f) != sizeof(x))
goto lose;
leaps[i].transition = (time_t) uc2ul(x);
if (fread((PTR) x, 1, sizeof(x), f) != sizeof(x))
goto lose;
leaps[i].change = (long int) uc2ul(x);
}
for (i = 0; i < num_isstd; ++i)
{
char c = getc(f);
if (c == EOF)
goto lose;
types[i].isstd = c != 0;
}
while (i < num_types)
types[i++].isstd = 0;
(void) fclose(f);
__use_tzfile = 1;
return;
lose:;
(void) fclose(f);
}
void
DEFUN(__tzfile_default, (std, dst, stdoff, dstoff),
char *std AND char *dst AND
long int stdoff AND long int dstoff)
{
size_t stdlen, dstlen;
__tzfile_read (TZDEFRULES);
if (!__use_tzfile)
return;
if (num_types != 2)
{
__use_tzfile = 0;
return;
}
free (zone_names);
stdlen = strlen (std) + 1;
dstlen = strlen (dst) + 1;
zone_names = malloc (stdlen + dstlen);
if (zone_names == NULL)
{
__use_tzfile = 0;
return;
}
memcpy (zone_names, std, stdlen);
memcpy (&zone_names[stdlen], dst, dstlen);
types[0].idx = 0;
types[0].isdst = 0;
if (std[0] != '\0')
types[0].offset = stdoff;
types[1].idx = stdlen;
types[1].isdst = 1;
if (dst[0] != '\0')
types[1].offset = dstoff;
}
int
DEFUN(__tzfile_compute, (timer, tm), time_t timer AND struct tm tm)
{
struct ttinfo *info;
register size_t i;
if (num_transitions == 0 || timer < transitions[0])
{
/* TIMER is before any transition (or there are no transitions).
Choose the first non-DST type
(or the first if they're all DST types). */
i = 0;
while (i < num_types && types[i].isdst)
++i;
if (i == num_types)
i = 0;
}
else
{
/* Find the first transition after TIMER, and then go back one. */
i = 1;
while (i < num_transitions && transitions[i] < timer)
++i;
--i;
}
info = &types[type_idxs[i]];
__daylight = info->isdst;
__timezone = info->offset;
for (i = 0; i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]);
++i)
__tzname[types[i].isdst] = &zone_names[types[i].idx];
if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0]))
__tzname[info->isdst] = &zone_names[info->idx];
i = num_leaps;
do
if (i-- == 0)
return 1;
while (timer < leaps[i].transition);
__timezone += leaps[i].change;
return 1;
}

View File

@@ -0,0 +1,168 @@
#ifndef TZFILE_H
#define TZFILE_H
/*
** This header is for use ONLY with the time conversion code.
** There is no guarantee that it will remain unchanged,
** or that it will remain at all.
** Do NOT copy it to any system include directory.
** Thank you!
*/
/*
** ID
*/
#ifndef lint
#ifndef NOID
static char tzfilehid[] = "@(#)tzfile.h 7.1";
#endif /* !defined NOID */
#endif /* !defined lint */
/*
** Information about time zone files.
*/
#ifndef TZDIR
#define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */
#endif /* !defined TZDIR */
#ifndef TZDEFAULT
#define TZDEFAULT "localtime"
#endif /* !defined TZDEFAULT */
#ifndef TZDEFRULES
#define TZDEFRULES "posixrules"
#endif /* !defined TZDEFRULES */
/*
** Each file begins with. . .
*/
struct tzhead {
char tzh_reserved[24]; /* reserved for future use */
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
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 */
};
/*
** . . .followed by. . .
**
** tzh_timecnt (char [4])s coded transition times a la time(2)
** tzh_timecnt (unsigned char)s types of local time starting at above
** tzh_typecnt repetitions of
** one (char [4]) coded GMT offset in seconds
** one (unsigned char) used to set tm_isdst
** one (unsigned char) that's an abbreviation list index
** tzh_charcnt (char)s '\0'-terminated zone abbreviations
** tzh_leapcnt repetitions of
** one (char [4]) coded leap second transition times
** one (char [4]) total correction after above
** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
** time is standard time, if FALSE,
** transition time is wall clock time
** if absent, transition times are
** assumed to be wall clock time
*/
/*
** In the current implementation, "tzset()" refuses to deal with files that
** exceed any of the limits below.
*/
#ifndef TZ_MAX_TIMES
/*
** The TZ_MAX_TIMES value below is enough to handle a bit more than a
** year's worth of solar time (corrected daily to the nearest second) or
** 138 years of Pacific Presidential Election time
** (where there are three time zone transitions every fourth year).
*/
#define TZ_MAX_TIMES 370
#endif /* !defined TZ_MAX_TIMES */
#ifndef TZ_MAX_TYPES
#ifndef NOSOLAR
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
#else /* !defined NOSOLAR */
#define TZ_MAX_TYPES 10 /* Maximum number of local time types */
#endif /* !defined NOSOLAR */
#endif /* !defined TZ_MAX_TYPES */
#ifndef TZ_MAX_CHARS
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
#endif /* !defined TZ_MAX_CHARS */
#ifndef TZ_MAX_LEAPS
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
#endif /* !defined TZ_MAX_LEAPS */
#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 TM_SUNDAY 0
#define TM_MONDAY 1
#define TM_TUESDAY 2
#define TM_WEDNESDAY 3
#define TM_THURSDAY 4
#define TM_FRIDAY 5
#define TM_SATURDAY 6
#define TM_JANUARY 0
#define TM_FEBRUARY 1
#define TM_MARCH 2
#define TM_APRIL 3
#define TM_MAY 4
#define TM_JUNE 5
#define TM_JULY 6
#define TM_AUGUST 7
#define TM_SEPTEMBER 8
#define TM_OCTOBER 9
#define TM_NOVEMBER 10
#define TM_DECEMBER 11
#define TM_YEAR_BASE 1900
#define EPOCH_YEAR 1970
#define EPOCH_WDAY TM_THURSDAY
/*
** Accurate only for the past couple of centuries;
** that will probably do.
*/
#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
#ifndef USG
/*
** Use of the underscored variants may cause problems if you move your code to
** certain System-V-based systems; for maximum portability, use the
** underscore-free variants. The underscored variants are provided for
** backward compatibility only; they may disappear from future versions of
** this file.
*/
#define SECS_PER_MIN SECSPERMIN
#define MINS_PER_HOUR MINSPERHOUR
#define HOURS_PER_DAY HOURSPERDAY
#define DAYS_PER_WEEK DAYSPERWEEK
#define DAYS_PER_NYEAR DAYSPERNYEAR
#define DAYS_PER_LYEAR DAYSPERLYEAR
#define SECS_PER_HOUR SECSPERHOUR
#define SECS_PER_DAY SECSPERDAY
#define MONS_PER_YEAR MONSPERYEAR
#endif /* !defined USG */
#endif /* !defined TZFILE_H */

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <time.h>
#include <gnu-stabs.h>
#undef tzset
function_alias(tzset, __tzset, void, (), DEFUN_VOID(tzset))

View File

@@ -0,0 +1,282 @@
#ifdef LIBC
#include <ansidecl.h>
#endif
#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)zdump.c 7.2";
#endif /* !defined NOID */
#endif /* !defined lint */
/*
** This code has been made independent of the rest of the time
** conversion package to increase confidence in the verification it provides.
** You can use this code to help in verifying other implementations.
*/
#include <stdio.h> /* for stdout, stderr */
#include <string.h> /* for strcpy */
#include <sys/types.h> /* for time_t */
#include <time.h> /* for struct tm */
#ifndef MAX_STRING_LENGTH
#define MAX_STRING_LENGTH 1024
#endif /* !defined MAX_STRING_LENGTH */
#ifndef TRUE
#define TRUE 1
#endif /* !defined TRUE */
#ifndef FALSE
#define FALSE 0
#endif /* !defined FALSE */
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif /* !defined EXIT_FAILURE */
#ifndef SECSPERMIN
#define SECSPERMIN 60
#endif /* !defined SECSPERMIN */
#ifndef SECSPERHOUR
#define SECSPERHOUR 3600
#endif /* !defined SECSPERHOUR */
#ifndef HOURSPERDAY
#define HOURSPERDAY 24
#endif /* !defined HOURSPERDAY */
#ifndef EPOCH_YEAR
#define EPOCH_YEAR 1970
#endif /* !defined EPOCH_YEAR */
#ifndef DAYSPERNYEAR
#define DAYSPERNYEAR 365
#endif /* !defined DAYSPERNYEAR */
extern char ** environ;
extern int getopt();
extern char * optarg;
extern int optind;
extern time_t time();
extern char * tzname[2];
extern void tzset();
#ifdef USG
extern void exit();
extern void perror();
#endif /* defined USG */
static char * abbr();
static long delta();
static void hunt();
static int longest;
static char * progname;
static void show();
int
main(argc, argv)
int argc;
char * argv[];
{
register int i, c;
register int vflag;
register char * cutoff;
register int cutyear;
register long cuttime;
time_t now;
time_t t, newt;
time_t hibit;
struct tm tm, newtm;
progname = argv[0];
vflag = 0;
cutoff = NULL;
while ((c = getopt(argc, argv, "c:v")) == 'c' || c == 'v')
if (c == 'v')
vflag = 1;
else cutoff = optarg;
if (c != EOF ||
(optind == argc - 1 && strcmp(argv[optind], "=") == 0)) {
(void) fprintf(stderr,
"%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n",
argv[0], argv[0]);
(void) exit(EXIT_FAILURE);
}
if (cutoff != NULL)
cutyear = atoi(cutoff);
/*
** VERY approximate.
*/
cuttime = (long) (cutyear - EPOCH_YEAR) *
SECSPERHOUR * HOURSPERDAY * DAYSPERNYEAR;
(void) time(&now);
longest = 0;
for (i = optind; i < argc; ++i)
if (strlen(argv[i]) > longest)
longest = strlen(argv[i]);
for (hibit = 1; (hibit << 1) != 0; hibit <<= 1)
;
for (i = optind; i < argc; ++i) {
register char ** saveenv;
static char buf[MAX_STRING_LENGTH];
char * fakeenv[2];
if (strlen(argv[i]) + 4 > sizeof buf) {
(void) fflush(stdout);
(void) fprintf(stderr, "%s: argument too long -- %s\n",
progname, argv[i]);
(void) exit(EXIT_FAILURE);
}
(void) strcpy(buf, "TZ=");
(void) strcat(buf, argv[i]);
fakeenv[0] = buf;
fakeenv[1] = NULL;
saveenv = environ;
environ = fakeenv;
(void) tzset();
environ = saveenv;
show(argv[i], now, FALSE);
if (!vflag)
continue;
/*
** Get lowest value of t.
*/
t = hibit;
if (t > 0) /* time_t is unsigned */
t = 0;
show(argv[i], t, TRUE);
t += SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
tm = *localtime(&t);
(void) strncpy(buf, abbr(&tm), (sizeof buf) - 1);
for ( ; ; ) {
if (cutoff != NULL && t >= cuttime)
break;
newt = t + SECSPERHOUR * 12;
if (cutoff != NULL && newt >= cuttime)
break;
if (newt <= t)
break;
newtm = *localtime(&newt);
if (delta(&newtm, &tm) != (newt - t) ||
newtm.tm_isdst != tm.tm_isdst ||
strcmp(abbr(&newtm), buf) != 0) {
hunt(argv[i], t, newt);
(void) strncpy(buf, abbr(&newtm),
(sizeof buf) - 1);
}
t = newt;
tm = newtm;
}
/*
** Get highest value of t.
*/
t = ~((time_t) 0);
if (t < 0) /* time_t is signed */
t &= ~hibit;
t -= SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
t += SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
}
if (fflush(stdout) || ferror(stdout)) {
(void) fprintf(stderr, "%s: Error writing standard output ",
argv[0]);
(void) perror("standard output");
(void) exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
/* gcc -Wall pacifier */
for ( ; ; )
;
}
static void
hunt(name, lot, hit)
char * name;
time_t lot;
time_t hit;
{
time_t t;
struct tm lotm;
struct tm tm;
static char loab[MAX_STRING_LENGTH];
lotm = *localtime(&lot);
(void) strncpy(loab, abbr(&lotm), (sizeof loab) - 1);
while ((hit - lot) >= 2) {
t = lot / 2 + hit / 2;
if (t <= lot)
++t;
else if (t >= hit)
--t;
tm = *localtime(&t);
if (delta(&tm, &lotm) == (t - lot) &&
tm.tm_isdst == lotm.tm_isdst &&
strcmp(abbr(&tm), loab) == 0) {
lot = t;
lotm = tm;
} else hit = t;
}
show(name, lot, TRUE);
show(name, hit, TRUE);
}
static long
delta(newp, oldp)
struct tm * newp;
struct tm * oldp;
{
long result;
result = newp->tm_hour - oldp->tm_hour;
if (result < 0)
result += HOURSPERDAY;
result *= SECSPERHOUR;
result += (newp->tm_min - oldp->tm_min) * SECSPERMIN;
return result + newp->tm_sec - oldp->tm_sec;
}
static void
show(zone, t, v)
char * zone;
time_t t;
int v;
{
struct tm * tmp;
extern struct tm * localtime();
(void) printf("%-*s ", longest, zone);
if (v)
(void) printf("%.24s GMT = ", asctime(gmtime(&t)));
tmp = localtime(&t);
(void) printf("%.24s", asctime(tmp));
if (*abbr(tmp) != '\0')
(void) printf(" %s", abbr(tmp));
if (v) {
(void) printf(" isdst=%d", tmp->tm_isdst);
#ifdef TM_GMTOFF
(void) printf(" gmtoff=%ld", tmp->TM_GMTOFF);
#endif /* defined TM_GMTOFF */
}
(void) printf("\n");
}
static char *
abbr(tmp)
struct tm * tmp;
{
register char * result;
if (tmp->tm_isdst != 0 && tmp->tm_isdst != 1)
return "";
result = tzname[tmp->tm_isdst];
return (result == NULL) ? "" : result;
}

File diff suppressed because it is too large Load Diff