. added zoneinfo to build, with fixes for minix
. now using zoneinfo date command, instead of commands/simple/date.c
This commit is contained in:
parent
a2d3b518d8
commit
0be7f44224
21 changed files with 86 additions and 1215 deletions
|
@ -4,7 +4,7 @@ MAKE = exec make -$(MAKEFLAGS)
|
|||
BZIP2=bzip2-1.0.3
|
||||
FLEX=flex-2.5.4
|
||||
|
||||
SMALLPROGRAMS=`arch` aal advent ash autil awk bc byacc cawf cron de dhcpd dis88 elle elvis ftp101 ftpd200 ibm indent m4 make mdb mined patch pax profile ps reboot rlogind scripts sh simple syslogd talk talkd telnet telnetd urlget yap
|
||||
SMALLPROGRAMS=`arch` aal advent ash autil awk bc byacc cawf cron de dhcpd dis88 elle elvis ftp101 ftpd200 ibm indent m4 make mdb mined patch pax profile ps reboot rlogind scripts sh simple syslogd talk talkd telnet telnetd urlget yap zoneinfo
|
||||
|
||||
usage:
|
||||
@echo "Usage: make all # Compile all commands" >&2
|
||||
|
|
|
@ -67,7 +67,6 @@ ALL = \
|
|||
cp \
|
||||
crc \
|
||||
cut \
|
||||
date \
|
||||
dd \
|
||||
decomp16 \
|
||||
dev2name \
|
||||
|
@ -325,10 +324,6 @@ cut: cut.c
|
|||
$(CCLD) -o $@ $?
|
||||
@install -S 4kw $@
|
||||
|
||||
date: date.c
|
||||
$(CCLD) -o $@ $?
|
||||
@install -S 4kw $@
|
||||
|
||||
dd: dd.c
|
||||
$(CCLD) -o $@ $?
|
||||
@install -S 20kw $@
|
||||
|
@ -950,7 +945,6 @@ install: \
|
|||
/bin/rm \
|
||||
/usr/bin/crc \
|
||||
/usr/bin/cut \
|
||||
/usr/bin/date \
|
||||
/usr/bin/dd \
|
||||
/usr/bin/decomp16 \
|
||||
/bin/dev2name \
|
||||
|
@ -1114,7 +1108,6 @@ install: \
|
|||
/usr/bin/yes \
|
||||
/usr/bin/udpstat \
|
||||
/bin/cat \
|
||||
/bin/date \
|
||||
/bin/fsck \
|
||||
/bin/intr \
|
||||
/bin/mount \
|
||||
|
@ -1227,9 +1220,6 @@ install: \
|
|||
/usr/bin/cut: cut
|
||||
install -cs -o bin $? $@
|
||||
|
||||
/usr/bin/date: date
|
||||
install -cs -o bin $? $@
|
||||
|
||||
/usr/bin/dd: dd
|
||||
install -cs -o bin $? $@
|
||||
|
||||
|
@ -1713,9 +1703,6 @@ install: \
|
|||
/bin/cat: /usr/bin/cat
|
||||
install -lcs $? $@
|
||||
|
||||
/bin/date: /usr/bin/date
|
||||
install -lcs $? $@
|
||||
|
||||
/bin/fsck: /usr/bin/fsck
|
||||
install -lcs $? $@
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# make zonenames
|
||||
# to get a list of the values you can use for LOCALTIME.
|
||||
|
||||
LOCALTIME= Factory
|
||||
LOCALTIME= GMT
|
||||
|
||||
# If you want something other than Eastern United States time as a template
|
||||
# for handling POSIX-style time zone environment variables,
|
||||
|
@ -34,30 +34,25 @@ POSIXRULES= America/New_York
|
|||
|
||||
# Everything gets put in subdirectories of. . .
|
||||
|
||||
TOPDIR= /usr/local
|
||||
TOPDIR= /usr
|
||||
|
||||
# "Compiled" time zone information is placed in the "TZDIR" directory
|
||||
# (and subdirectories).
|
||||
# Use an absolute path name for TZDIR unless you're just testing the software.
|
||||
|
||||
TZDIR= $(TOPDIR)/etc/zoneinfo
|
||||
TZDIR= $(TOPDIR)/share/zoneinfo
|
||||
|
||||
# The "tzselect", "zic", and "zdump" commands get installed in. . .
|
||||
|
||||
ETCDIR= $(TOPDIR)/etc
|
||||
ETCDIR= $(TOPDIR)/bin
|
||||
|
||||
# If you "make INSTALL", the "date" command gets installed in. . .
|
||||
|
||||
BINDIR= $(TOPDIR)/bin
|
||||
|
||||
# Manual pages go in subdirectories of. . .
|
||||
|
||||
MANDIR= $(TOPDIR)/man
|
||||
|
||||
# Library functions are put in an archive in LIBDIR.
|
||||
|
||||
LIBDIR= $(TOPDIR)/lib
|
||||
TZLIB= $(LIBDIR)/libtz.a
|
||||
|
||||
# If you always want time values interpreted as "seconds since the epoch
|
||||
# (not counting leap seconds)", use
|
||||
|
@ -210,7 +205,7 @@ GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \
|
|||
# before the first Monday in January when a "%V" format is used and January 1
|
||||
# falls on a Friday, Saturday, or Sunday.
|
||||
|
||||
CFLAGS=
|
||||
CFLAGS=-DHAVE_ADJTIME=0 -D_POSIX_SOURCE=1 -D_MINIX=1
|
||||
|
||||
# If you want zic's -s option used when installing, uncomment the next line
|
||||
# ZFLAGS= -s
|
||||
|
@ -255,9 +250,7 @@ HEADERS= tzfile.h private.h
|
|||
NONLIBSRCS= zic.c zdump.c scheck.c ialloc.c
|
||||
NEWUCBSRCS= date.c logwtmp.c strftime.c
|
||||
SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) tzselect.ksh
|
||||
MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
|
||||
tzfile.5 tzselect.8 zic.8 zdump.8
|
||||
DOCS= README Theory $(MANS) date.1 Makefile
|
||||
DOCS= README Theory date.1 Makefile
|
||||
PRIMARY_YDATA= africa antarctica asia australasia \
|
||||
europe northamerica southamerica
|
||||
YDATA= $(PRIMARY_YDATA) pacificnew etcetera factory backward
|
||||
|
@ -280,37 +273,28 @@ all: tzselect zic zdump $(LIBOBJS)
|
|||
|
||||
ALL: all date
|
||||
|
||||
install: all $(DATA) $(REDO) $(TZLIB) $(MANS) $(TABDATA)
|
||||
install: ALL $(DATA) $(REDO) $(TABDATA)
|
||||
$(ZIC) -y $(YEARISTYPE) \
|
||||
-d $(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
|
||||
-rm -f $(TZDIR)/iso3166.tab $(TZDIR)/zone.tab
|
||||
cp iso3166.tab zone.tab $(TZDIR)/.
|
||||
-mkdir $(TOPDIR) $(ETCDIR)
|
||||
cp tzselect zic zdump $(ETCDIR)/.
|
||||
-mkdir $(TOPDIR) $(MANDIR) \
|
||||
$(MANDIR)/man3 $(MANDIR)/man5 $(MANDIR)/man8
|
||||
-rm -f $(MANDIR)/man3/newctime.3 \
|
||||
$(MANDIR)/man3/newtzset.3 \
|
||||
$(MANDIR)/man5/tzfile.5 \
|
||||
$(MANDIR)/man8/tzselect.8 \
|
||||
$(MANDIR)/man8/zdump.8 \
|
||||
$(MANDIR)/man8/zic.8
|
||||
cp newctime.3 newtzset.3 $(MANDIR)/man3/.
|
||||
cp tzfile.5 $(MANDIR)/man5/.
|
||||
cp tzselect.8 zdump.8 zic.8 $(MANDIR)/man8/.
|
||||
install -m 644 iso3166.tab zone.tab $(TZDIR)/.
|
||||
-mkdir $(TOPDIR) $(ETCDIR) 2>/dev/null
|
||||
install -m 755 tzselect zic zdump $(ETCDIR)/.
|
||||
-mkdir $(TOPDIR) 2>/dev/null
|
||||
install -m 755 date /bin
|
||||
|
||||
INSTALL: ALL install date.1
|
||||
-mkdir $(TOPDIR) $(BINDIR)
|
||||
-mkdir $(TOPDIR) $(BINDIR) 2>/dev/null
|
||||
cp date $(BINDIR)/.
|
||||
-mkdir $(TOPDIR) $(MANDIR) $(MANDIR)/man1
|
||||
-rm -f $(MANDIR)/man1/date.1
|
||||
cp date.1 $(MANDIR)/man1/.
|
||||
-mkdir $(TOPDIR) 2>/dev/null
|
||||
|
||||
zdump: $(TZDOBJS)
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) $(LDLIBS) -o $@
|
||||
install -S768k $@
|
||||
|
||||
zic: $(TZCOBJS) yearistype
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) $(LDLIBS) -o $@
|
||||
install -S1M $@
|
||||
|
||||
yearistype: yearistype.sh
|
||||
cp yearistype.sh yearistype
|
||||
|
@ -342,21 +326,11 @@ right_posix: right_only other_two
|
|||
|
||||
zones: $(REDO)
|
||||
|
||||
$(TZLIB): $(LIBOBJS)
|
||||
-mkdir $(TOPDIR) $(LIBDIR)
|
||||
ar ru $@ $(LIBOBJS)
|
||||
if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
|
||||
then ranlib $@ ; fi
|
||||
|
||||
# We use the system's logwtmp in preference to ours if available.
|
||||
|
||||
date: $(DATEOBJS)
|
||||
ar r ,lib.a logwtmp.o
|
||||
if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
|
||||
then ranlib ,lib.a ; fi
|
||||
$(CC) $(CFLAGS) date.o localtime.o asctime.o strftime.o \
|
||||
$(LDLIBS) -lc ,lib.a -o $@
|
||||
rm -f ,lib.a
|
||||
date: $(DATEOBJS) logwtmp.o
|
||||
$(CC) $(CFLAGS) date.o logwtmp.o localtime.o asctime.o \
|
||||
strftime.o $(LDLIBS) -o $@
|
||||
|
||||
tzselect: tzselect.ksh
|
||||
sed \
|
||||
|
@ -390,7 +364,7 @@ names:
|
|||
public: $(ENCHILADA)
|
||||
make maintainer-clean
|
||||
make "CFLAGS=$(GCC_DEBUG_FLAGS)"
|
||||
-mkdir /tmp/,tzpublic
|
||||
-mkdir /tmp/,tzpublic 2>/dev/null
|
||||
-for i in $(TDATA) ; do zic -v -d /tmp/,tzpublic $$i 2>&1 | grep -v "starting year" ; done
|
||||
for i in $(TDATA) ; do zic -d /tmp/,tzpublic $$i || exit; done
|
||||
zic -v -d /tmp/,tzpublic $(TDATA) || exit
|
||||
|
|
|
@ -1,128 +0,0 @@
|
|||
NAME
|
||||
|
||||
date - show and set date and time
|
||||
|
||||
SYNOPSIS
|
||||
date [ -u ] [ -c ] [ -n ] [ -d dsttype ] [ -t minutes-west ]
|
||||
[ -a [+|-]sss.fff ] [ +format ] [ [yyyy]mmddhhmm[yy][.ss] ]
|
||||
|
||||
DESCRIPTION
|
||||
Date without arguments writes the date and time to the
|
||||
standard output in the form
|
||||
Wed Mar 8 14:54:40 EST 1989
|
||||
with EST replaced by the local time zone's abbreviation (or
|
||||
by the abbreviation for the time zone specified in the TZ
|
||||
environment variable if set). The exact output format
|
||||
depends on the locale.
|
||||
|
||||
If a command-line argument starts with a plus sign (`+'),
|
||||
the rest of the argument is used as a format that controls
|
||||
what appears in the output. In the format, when a percent
|
||||
sign (`%') appears, it and the character after it are not
|
||||
output, but rather identify part of the date or time to be
|
||||
output in a particular way (or identify a special character
|
||||
to output):
|
||||
|
||||
Sample output Explanation
|
||||
%a Wed Abbreviated weekday name*
|
||||
%A Wednesday Full weekday name*
|
||||
%b Mar Abbreviated month name*
|
||||
%B March Full month name*
|
||||
%c Wed Mar 08 14:54:40 1989 Date and time*
|
||||
%C 19 Century
|
||||
%d 08 Day of month (always two digits)
|
||||
%D 03/08/89 Month/day/year (eight characters)
|
||||
%e 8 Day of month (leading zero blanked)
|
||||
%h Mar Abbreviated month name*
|
||||
%H 14 24-hour-clock hour (two digits)
|
||||
%I 02 12-hour-clock hour (two digits)
|
||||
%j 067 Julian day number (three digits)
|
||||
%k 2 12-hour-clock hour (leading zero blanked)
|
||||
%l 14 24-hour-clock hour (leading zero blanked)
|
||||
%m 03 Month number (two digits)
|
||||
%M 54 Minute (two digits)
|
||||
%n \n newline character
|
||||
%p PM AM/PM designation
|
||||
%r 02:54:40 PM Hour:minute:second AM/PM designation
|
||||
%R 14:54 Hour:minute
|
||||
%S 40 Second (two digits)
|
||||
%t \t tab character
|
||||
%T 14:54:40 Hour:minute:second
|
||||
%U 10 Sunday-based week number (two digits)
|
||||
%w 3 Day number (one digit, Sunday is 0)
|
||||
%W 10 Monday-based week number (two digits)
|
||||
%x 03/08/89 Date*
|
||||
%X 14:54:40 Time*
|
||||
%y 89 Last two digits of year
|
||||
%Y 1989 Year in full
|
||||
%Z EST Time zone abbreviation
|
||||
%+ Wed Mar 8 14:54:40 EST 1989 Default output format*
|
||||
* The exact output depends on the locale.
|
||||
|
||||
If a character other than one of those shown above appears
|
||||
after a percent sign in the format, that following character
|
||||
is output. All other characters in the format are copied
|
||||
unchanged to the output; a newline character is always added
|
||||
at the end of the output.
|
||||
|
||||
In Sunday-based week numbering, the first Sunday of the year
|
||||
begins week 1; days preceding it are part of ``week 0.'' In
|
||||
Monday-based week numbering, the first Monday of the year
|
||||
begins week 1.
|
||||
|
||||
To set the date, use a command line argument with one of the
|
||||
following forms:
|
||||
1454 24-hour-clock hours (first two digits) and minutes
|
||||
081454 Month day (first two digits), hours, and minutes
|
||||
03081454 Month (two digits, January is 01), month day, hours, minutes
|
||||
8903081454 Year, month, month day, hours, minutes
|
||||
0308145489 Month, month day, hours, minutes, year
|
||||
(on System V-compatible systems)
|
||||
030814541989 Month, month day, hours, minutes, four-digit year
|
||||
198903081454 Four-digit year, month, month day, hours, minutes
|
||||
If the century, year, month, or month day is not given, the
|
||||
current value is used. Any of the above forms may be
|
||||
followed by a period and two digits that give the seconds
|
||||
part of the new time; if no seconds are given, zero is
|
||||
assumed.
|
||||
|
||||
These options are available:
|
||||
|
||||
-u or -c
|
||||
Use UTC when setting and showing the date and time.
|
||||
|
||||
-n Do not notify other networked systems of the time
|
||||
change.
|
||||
|
||||
-d dsttype
|
||||
Set the kernel-stored Daylight Saving Time type to the
|
||||
given value. (The kernel-stored DST type is used
|
||||
mostly by ``old'' binaries.)
|
||||
|
||||
-t minutes-west
|
||||
Set the kernel-stored ``minutes west of UTC'' value to
|
||||
the one given on the command line. (The kernel-stored
|
||||
DST type is used mostly by ``old'' binaries.)
|
||||
|
||||
-a adjustment
|
||||
Change the time forward (or backward) by the number of
|
||||
seconds (and fractions thereof) specified in the
|
||||
adjustment argument. Either the seconds part or the
|
||||
fractions part of the argument (but not both) may be
|
||||
omitted. On BSD-based systems, the adjustment is made
|
||||
by changing the rate at which time advances; on
|
||||
System-V-based systems, the adjustment is made by
|
||||
changing the time.
|
||||
|
||||
FILES
|
||||
/usr/lib/locale/L/LC_TIME description of time
|
||||
locale L
|
||||
/usr/local/etc/zoneinfo time zone information
|
||||
directory
|
||||
/usr/local/etc/zoneinfo/localtime local time zone file
|
||||
/usr/local/etc/zoneinfo/posixrules used with POSIX-style
|
||||
TZ's
|
||||
/usr/local/etc/zoneinfo/GMT for UTC leap seconds
|
||||
|
||||
If /usr/local/etc/zoneinfo/GMT is absent, UTC leap seconds
|
||||
are loaded from /usr/local/etc/zoneinfo/posixrules.
|
|
@ -24,6 +24,8 @@ static char elsieid[] = "@(#)date.c 7.45";
|
|||
* WARRANTIES OF MERCHANT[A]BILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <fcntl.h> /* for O_WRONLY, O_APPEND */
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1985, 1987, 1988 The Regents of the University of California.\n\
|
||||
|
@ -63,8 +65,9 @@ static char sccsid[] = "@(#)date.c 4.23 (Berkeley) 9/20/88";
|
|||
#define SECSPERMIN 60
|
||||
#endif /* !defined SECSPERMIN */
|
||||
|
||||
extern double atof();
|
||||
extern char ** environ;
|
||||
#if 0
|
||||
extern double atof();
|
||||
extern char * getlogin();
|
||||
extern time_t mktime();
|
||||
extern char * optarg;
|
||||
|
@ -72,6 +75,7 @@ extern int optind;
|
|||
extern char * strchr();
|
||||
extern time_t time();
|
||||
extern char * tzname[2];
|
||||
#endif
|
||||
|
||||
static int retval = EXIT_SUCCESS;
|
||||
|
||||
|
@ -315,6 +319,8 @@ dogmt()
|
|||
{
|
||||
static char ** fakeenv;
|
||||
|
||||
printf("dogmt wtf\n");
|
||||
|
||||
if (fakeenv == NULL) {
|
||||
register int from;
|
||||
register int to;
|
||||
|
@ -348,8 +354,6 @@ dogmt()
|
|||
** and don't have network notification to worry about.
|
||||
*/
|
||||
|
||||
#include "fcntl.h" /* for O_WRONLY, O_APPEND */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
#if __STDC__
|
||||
|
@ -448,9 +452,10 @@ const int nflag;
|
|||
#include "netinet/in.h"
|
||||
#include "netdb.h"
|
||||
#define TSPTYPES
|
||||
#include "protocols/timed.h"
|
||||
|
||||
#if 0
|
||||
extern int logwtmp();
|
||||
#endif
|
||||
|
||||
#if HAVE_SETTIMEOFDAY == 1
|
||||
#define settimeofday(t, tz) (settimeofday)(t)
|
||||
|
@ -563,7 +568,9 @@ const char * const format;
|
|||
exit(retval);
|
||||
}
|
||||
|
||||
#if 0
|
||||
extern size_t strftime();
|
||||
#endif
|
||||
|
||||
#define INCR 1024
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
#ifndef lint
|
||||
|
@ -20,13 +23,15 @@ static char sccsid[] = "@(#)ialloc.c 7.14";
|
|||
#define NULLMAL(x) ((x) == NULL)
|
||||
#endif /* !MAL */
|
||||
|
||||
#if 0
|
||||
extern char * calloc();
|
||||
extern char * malloc();
|
||||
extern char * realloc();
|
||||
extern char * strcpy();
|
||||
#endif
|
||||
|
||||
char *
|
||||
imalloc(n)
|
||||
imalloc(int n)
|
||||
{
|
||||
#ifdef MAL
|
||||
register char * result;
|
||||
|
@ -43,7 +48,7 @@ imalloc(n)
|
|||
}
|
||||
|
||||
char *
|
||||
icalloc(nelem, elsize)
|
||||
icalloc(int nelem, int elsize)
|
||||
{
|
||||
if (nelem == 0 || elsize == 0)
|
||||
nelem = elsize = 1;
|
||||
|
@ -51,8 +56,7 @@ icalloc(nelem, elsize)
|
|||
}
|
||||
|
||||
char *
|
||||
irealloc(pointer, size)
|
||||
char * pointer;
|
||||
irealloc(char *pointer, int size)
|
||||
{
|
||||
if (NULLMAL(pointer))
|
||||
return imalloc(size);
|
||||
|
@ -62,9 +66,7 @@ char * pointer;
|
|||
}
|
||||
|
||||
char *
|
||||
icatalloc(old, new)
|
||||
char * old;
|
||||
char * new;
|
||||
icatalloc(char *old, char *new)
|
||||
{
|
||||
register char * result;
|
||||
register oldsize, newsize;
|
||||
|
@ -78,21 +80,18 @@ char * new;
|
|||
}
|
||||
|
||||
char *
|
||||
icpyalloc(string)
|
||||
char * string;
|
||||
icpyalloc(char *string)
|
||||
{
|
||||
return icatalloc((char *) NULL, string);
|
||||
}
|
||||
|
||||
ifree(p)
|
||||
char * p;
|
||||
ifree(char *p)
|
||||
{
|
||||
if (!NULLMAL(p))
|
||||
free(p);
|
||||
}
|
||||
|
||||
icfree(p)
|
||||
char * p;
|
||||
icfree(char *p)
|
||||
{
|
||||
if (!NULLMAL(p))
|
||||
free(p);
|
||||
|
|
|
@ -311,8 +311,10 @@ register struct state * const sp;
|
|||
register int i;
|
||||
register int fid;
|
||||
|
||||
if (name == NULL && (name = TZDEFAULT) == NULL)
|
||||
if (name == NULL && (name = TZDEFAULT) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
register int doaccess;
|
||||
/*
|
||||
|
@ -1058,8 +1060,9 @@ tzset P((void))
|
|||
return;
|
||||
}
|
||||
|
||||
if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0)
|
||||
if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0) {
|
||||
return;
|
||||
}
|
||||
lcl_is_set = strlen(name) < sizeof lcl_TZname;
|
||||
if (lcl_is_set)
|
||||
(void) strcpy(lcl_TZname, name);
|
||||
|
@ -1159,9 +1162,7 @@ const time_t * const timep;
|
|||
*/
|
||||
|
||||
struct tm *
|
||||
localtime_r(timep, tmp)
|
||||
const time_t * const timep;
|
||||
struct tm * tmp;
|
||||
localtime_r(const time_t * const timep, struct tm * tmp)
|
||||
{
|
||||
return localsub(timep, 0L, tmp);
|
||||
}
|
||||
|
@ -1221,9 +1222,7 @@ const time_t * const timep;
|
|||
*/
|
||||
|
||||
struct tm *
|
||||
gmtime_r(timep, tmp)
|
||||
const time_t * const timep;
|
||||
struct tm * tmp;
|
||||
gmtime_r(const time_t * const timep, struct tm * tmp)
|
||||
{
|
||||
return gmtsub(timep, 0L, tmp);
|
||||
}
|
||||
|
@ -1401,9 +1400,7 @@ const time_t * const timep;
|
|||
}
|
||||
|
||||
char *
|
||||
ctime_r(timep, buf)
|
||||
const time_t * const timep;
|
||||
char * buf;
|
||||
ctime_r(const time_t * const timep, char * buf)
|
||||
{
|
||||
struct tm mytm;
|
||||
|
||||
|
@ -1590,12 +1587,16 @@ const int do_norm_secs;
|
|||
if (!TYPE_SIGNED(time_t)) {
|
||||
lo = 0;
|
||||
hi = lo - 1;
|
||||
} else if (!TYPE_INTEGRAL(time_t)) {
|
||||
}
|
||||
#if 0
|
||||
else if (!TYPE_INTEGRAL(time_t)) {
|
||||
if (sizeof(time_t) > sizeof(float))
|
||||
hi = (time_t) DBL_MAX;
|
||||
else hi = (time_t) FLT_MAX;
|
||||
lo = -hi;
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
lo = 1;
|
||||
for (i = 0; i < (int) TYPE_BIT(time_t) - 1; ++i)
|
||||
lo *= 2;
|
||||
|
|
|
@ -29,7 +29,12 @@ static char sccsid[] = "@(#)logwtmp.c 5.2 (Berkeley) 9/20/88";
|
|||
#endif /* !defined lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <utmp.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef OLD_TIME
|
||||
|
||||
|
@ -45,14 +50,11 @@ char dummy_to_keep_linker_happy;
|
|||
|
||||
#define WTMPFILE "/usr/adm/wtmp"
|
||||
|
||||
logwtmp(line, name, host)
|
||||
char *line, *name, *host;
|
||||
void logwtmp( char *line, char *name, char *host)
|
||||
{
|
||||
struct utmp ut;
|
||||
struct stat buf;
|
||||
int fd;
|
||||
time_t time();
|
||||
char *strncpy();
|
||||
|
||||
if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
|
||||
return;
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
NAME
|
||||
|
||||
asctime, ctime, difftime, gmtime, localtime, mktime -
|
||||
convert date and time to ASCII
|
||||
|
||||
SYNOPSIS
|
||||
extern char *tzname[2];
|
||||
|
||||
void tzset()
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
char *ctime(clock)
|
||||
const time_t *clock;
|
||||
|
||||
double difftime(time1, time0)
|
||||
time_t time1;
|
||||
time_t time0;
|
||||
|
||||
#include <time.h>
|
||||
|
||||
char *asctime(tm)
|
||||
const struct tm *tm;
|
||||
|
||||
struct tm *localtime(clock)
|
||||
const time_t *clock;
|
||||
|
||||
struct tm *gmtime(clock)
|
||||
const time_t *clock;
|
||||
|
||||
time_t mktime(tm)
|
||||
struct tm *tm;
|
||||
|
||||
cc ... -ltz
|
||||
|
||||
DESCRIPTION
|
||||
Ctime converts a long integer, pointed to by clock,
|
||||
representing the time in seconds since 00:00:00 UTC, 1970-
|
||||
01-01, and returns a pointer to a string of the form
|
||||
Thu Nov 24 18:22:48 1986\n\0
|
||||
Years requiring fewer than four characters are padded with
|
||||
leading zeroes. For years longer than four characters, the
|
||||
string is of the form
|
||||
Thu Nov 24 18:22:48 81986\n\0
|
||||
with five spaces before the year. These unusual formats are
|
||||
designed to make it less likely that older software that
|
||||
expects exactly 26 bytes of output will mistakenly output
|
||||
misleading values for out-of-range years.
|
||||
|
||||
Localtime and gmtime return pointers to ``tm'' structures,
|
||||
described below. Localtime corrects for the time zone and
|
||||
any time zone adjustments (such as Daylight Saving Time in
|
||||
the United States). After filling in the ``tm'' structure,
|
||||
localtime sets the tm_isdst'th element of tzname to a
|
||||
pointer to an ASCII string that's the time zone abbreviation
|
||||
to be used with localtime's return value.
|
||||
|
||||
Gmtime converts to Coordinated Universal Time.
|
||||
|
||||
Asctime converts a time value contained in a ``tm''
|
||||
structure to a string, as shown in the above example, and
|
||||
returns a pointer to the string.
|
||||
|
||||
Mktime converts the broken-down time, expressed as local
|
||||
time, in the structure pointed to by tm into a calendar time
|
||||
value with the same encoding as that of the values returned
|
||||
by the time function. The original values of the tm_wday
|
||||
and tm_yday components of the structure are ignored, and the
|
||||
original values of the other components are not restricted
|
||||
to their normal ranges. (A positive or zero value for
|
||||
tm_isdst causes mktime to presume initially that summer time
|
||||
(for example, Daylight Saving Time in the U.S.A.)
|
||||
respectively, is or is not in effect for the specified time.
|
||||
A negative value for tm_isdst causes the mktime function to
|
||||
attempt to divine whether summer time is in effect for the
|
||||
specified time.) On successful completion, the values of
|
||||
the tm_wday and tm_yday components of the structure are set
|
||||
appropriately, and the other components are set to represent
|
||||
the specified calendar time, but with their values forced to
|
||||
their normal ranges; the final value of tm_mday is not set
|
||||
until tm_mon and tm_year are determined. Mktime returns the
|
||||
specified calendar time; If the calendar time cannot be
|
||||
represented, it returns -1.
|
||||
|
||||
Difftime returns the difference between two calendar times,
|
||||
(time1 - time0), expressed in seconds.
|
||||
|
||||
Declarations of all the functions and externals, and the
|
||||
``tm'' structure, are in the <time.h> header file. The
|
||||
structure (of type) struct tm includes the following fields:
|
||||
|
||||
int tm_sec; /* seconds (0 - 60) */
|
||||
int tm_min; /* minutes (0 - 59) */
|
||||
int tm_hour; /* hours (0 - 23) */
|
||||
int tm_mday; /* day of month (1 - 31) */
|
||||
int tm_mon; /* month of year (0 - 11) */
|
||||
int tm_year; /* year - 1900 */
|
||||
int tm_wday; /* day of week (Sunday = 0) */
|
||||
int tm_yday; /* day of year (0 - 365) */
|
||||
int tm_isdst; /* is summer time in effect? */
|
||||
char *tm_zone; /* abbreviation of timezone name */
|
||||
long tm_gmtoff; /* offset from UTC in seconds */
|
||||
|
||||
The tm_zone and tm_gmtoff fields exist, and are filled in,
|
||||
only if arrangements to do so were made when the library
|
||||
containing these functions was created. There is no
|
||||
guarantee that these fields will continue to exist in this
|
||||
form in future releases of this code.
|
||||
|
||||
Tm_isdst is non-zero if summer time is in effect.
|
||||
|
||||
Tm_gmtoff is the offset (in seconds) of the time represented
|
||||
from UTC, with positive values indicating east of the Prime
|
||||
Meridian.
|
||||
|
||||
FILES
|
||||
/usr/local/etc/zoneinfo time zone information
|
||||
directory
|
||||
/usr/local/etc/zoneinfo/localtime local time zone file
|
||||
/usr/local/etc/zoneinfo/posixrules used with POSIX-style
|
||||
TZ's
|
||||
/usr/local/etc/zoneinfo/GMT for UTC leap seconds
|
||||
|
||||
If /usr/local/etc/zoneinfo/GMT is absent, UTC leap seconds
|
||||
are loaded from /usr/local/etc/zoneinfo/posixrules.
|
||||
|
||||
SEE ALSO
|
||||
getenv(3), newstrftime(3), newtzset(3), time(2), tzfile(5)
|
||||
|
||||
NOTES
|
||||
The return values point to static data; the data is
|
||||
overwritten by each call. The tm_zone field of a returned
|
||||
struct tm points to a static array of characters, which will
|
||||
also be overwritten at the next call (and by calls to
|
||||
tzset).
|
||||
|
||||
Asctime and ctime behave strangely for years before 1000 or
|
||||
after 9999. The 1989 and 1999 editions of the C Standard
|
||||
say that years from -99 through 999 are converted without
|
||||
extra spaces, but this conflicts with longstanding tradition
|
||||
and with this implementation. Traditional implementations
|
||||
of these two functions are restricted to years in the range
|
||||
1900 through 2099. To avoid this portability mess, new
|
||||
programs should use strftime instead.
|
||||
|
||||
Avoid using out-of-range values with mktime when setting up
|
||||
lunch with promptness sticklers in Riyadh.
|
|
@ -1,152 +0,0 @@
|
|||
NAME
|
||||
|
||||
strftime - format date and time
|
||||
|
||||
SYNOPSIS
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
size_t strftime(buf, maxsize, format, timeptr)
|
||||
char *buf;
|
||||
size_t maxsize;
|
||||
const char *format;
|
||||
const struct tm *timeptr
|
||||
|
||||
cc ... -ltz
|
||||
|
||||
DESCRIPTION
|
||||
The strftime function formats the information from timeptr
|
||||
into the buffer buf according to the string pointed to by
|
||||
format.
|
||||
|
||||
The format string consists of zero or more conversion
|
||||
specifications and ordinary characters. All ordinary
|
||||
characters are copied directly into the buffer. A
|
||||
conversion specification consists of a percent sign and one
|
||||
other character.
|
||||
|
||||
No more than maxsize characters are be placed into the
|
||||
array. If the total number of resulting characters,
|
||||
including the terminating null character, is not more than
|
||||
maxsize, strftime returns the number of characters in the
|
||||
array, not counting the terminating null. Otherwise, zero
|
||||
is returned.
|
||||
|
||||
Each conversion specification is replaced by the characters
|
||||
as follows which are then copied into the buffer.
|
||||
|
||||
%A is replaced by the locale's full weekday name.
|
||||
|
||||
%a is replaced by the locale's abbreviated weekday name.
|
||||
|
||||
%B is replaced by the locale's full month name.
|
||||
|
||||
%b or %h
|
||||
is replaced by the locale's abbreviated month name.
|
||||
|
||||
%C is replaced by the century (a year divided by 100 and
|
||||
truncated to an integer) as a decimal number (00-99).
|
||||
|
||||
%c is replaced by the locale's appropriate date and time
|
||||
representation.
|
||||
|
||||
%D is replaced by the date in the format %m/%d/%y.
|
||||
|
||||
%d is replaced by the day of the month as a decimal number
|
||||
(01-31).
|
||||
|
||||
%e is replaced by the day of month as a decimal number
|
||||
(1-31); single digits are preceded by a blank.
|
||||
|
||||
%F is replaced by the date in the format %Y-%m-%d.
|
||||
|
||||
%G is replaced by the ISO 8601 year with century as a
|
||||
decimal number.
|
||||
|
||||
%g is replaced by the ISO 8601 year without century as a
|
||||
decimal number (00-99).
|
||||
|
||||
%H is replaced by the hour (24-hour clock) as a decimal
|
||||
number (00-23).
|
||||
|
||||
%I is replaced by the hour (12-hour clock) as a decimal
|
||||
number (01-12).
|
||||
|
||||
%j is replaced by the day of the year as a decimal number
|
||||
(001-366).
|
||||
|
||||
%k is replaced by the hour (24-hour clock) as a decimal
|
||||
number (0-23); single digits are preceded by a blank.
|
||||
|
||||
%l is replaced by the hour (12-hour clock) as a decimal
|
||||
number (1-12); single digits are preceded by a blank.
|
||||
|
||||
%M is replaced by the minute as a decimal number (00-59).
|
||||
|
||||
%m is replaced by the month as a decimal number (01-12).
|
||||
|
||||
%n is replaced by a newline.
|
||||
|
||||
%p is replaced by the locale's equivalent of either AM or
|
||||
PM.
|
||||
|
||||
%R is replaced by the time in the format %H:%M.
|
||||
|
||||
%r is replaced by the locale's representation of 12-hour
|
||||
clock time using AM/PM notation.
|
||||
|
||||
%S is replaced by the second as a decimal number (00-60).
|
||||
|
||||
%s is replaced by the number of seconds since the Epoch,
|
||||
UTC (see mktime(3)).
|
||||
|
||||
%T is replaced by the time in the format %H:%M:%S.
|
||||
|
||||
%t is replaced by a tab.
|
||||
|
||||
%U is replaced by the week number of the year (Sunday as
|
||||
the first day of the week) as a decimal number (00-53).
|
||||
|
||||
%u is replaced by the weekday (Monday as the first day of
|
||||
the week) as a decimal number (1-7).
|
||||
|
||||
%V is replaced by the week number of the year (Monday as
|
||||
the first day of the week) as a decimal number (01-53).
|
||||
If the week containing January 1 has four or more days
|
||||
in the new year, then it is week 1; otherwise it is
|
||||
week 53 of the previous year, and the next week is week
|
||||
1.
|
||||
|
||||
%W is replaced by the week number of the year (Monday as
|
||||
the first day of the week) as a decimal number (00-53).
|
||||
|
||||
%w is replaced by the weekday (Sunday as the first day of
|
||||
the week) as a decimal number (0-6).
|
||||
|
||||
%X is replaced by the locale's appropriate time
|
||||
representation.
|
||||
|
||||
%x is replaced by the locale's appropriate date
|
||||
representation.
|
||||
|
||||
%Y is replaced by the year with century as a decimal
|
||||
number.
|
||||
|
||||
%y is replaced by the year without century as a decimal
|
||||
number (00-99).
|
||||
|
||||
%Z is replaced by the time zone name, or by the empty
|
||||
string if this is not determinable.
|
||||
|
||||
%z is replaced by the offset from UTC in the format +HHMM
|
||||
or -HHMM as appropriate, with positive values
|
||||
representing locations east of Greenwich, or by the
|
||||
empty string if this is not determinable.
|
||||
|
||||
%% is replaced by a single %.
|
||||
|
||||
%+ is replaced by the date and time in date(1) format.
|
||||
|
||||
SEE ALSO
|
||||
date(1), getenv(3), newctime(3), newtzset(3), time(2),
|
||||
tzfile(5)
|
|
@ -1,153 +0,0 @@
|
|||
NAME
|
||||
|
||||
tzset - initialize time conversion information
|
||||
|
||||
SYNOPSIS
|
||||
void tzset()
|
||||
|
||||
cc ... -ltz
|
||||
|
||||
DESCRIPTION
|
||||
Tzset uses the value of the environment variable TZ to set
|
||||
time conversion information used by localtime. If TZ does
|
||||
not appear in the environment, the best available
|
||||
approximation to local wall clock time, as specified by the
|
||||
tzfile(5)-format file localtime in the system time
|
||||
conversion information directory, is used by localtime. If
|
||||
TZ appears in the environment but its value is a null
|
||||
string, Coordinated Universal Time (UTC) is used (without
|
||||
leap second correction). If TZ appears in the environment
|
||||
and its value is not a null string:
|
||||
|
||||
if the value begins with a colon, it is used as a
|
||||
pathname of a file from which to read the time
|
||||
conversion information;
|
||||
|
||||
if the value does not begin with a colon, it is first
|
||||
used as the pathname of a file from which to read the
|
||||
time conversion information, and, if that file cannot
|
||||
be read, is used directly as a specification of the
|
||||
time conversion information.
|
||||
|
||||
When TZ is used as a pathname, if it begins with a slash, it
|
||||
is used as an absolute pathname; otherwise, it is used as a
|
||||
pathname relative to a system time conversion information
|
||||
directory. The file must be in the format specified in
|
||||
tzfile(5).
|
||||
|
||||
When TZ is used directly as a specification of the time
|
||||
conversion information, it must have the following syntax
|
||||
(spaces inserted for clarity):
|
||||
|
||||
stdoffset[dst[offset][,rule]]
|
||||
|
||||
Where:
|
||||
|
||||
std and dst Three or more bytes that are the
|
||||
designation for the standard (std) or
|
||||
summer (dst) time zone. Only std is
|
||||
required; if dst is missing, then summer
|
||||
time does not apply in this locale.
|
||||
Upper- and lowercase letters are
|
||||
explicitly allowed. Any characters
|
||||
except a leading colon (:), digits,
|
||||
comma (,), minus (-), plus (+), and
|
||||
ASCII NUL are allowed.
|
||||
|
||||
offset Indicates the value one must add to the
|
||||
local time to arrive at Coordinated
|
||||
Universal Time. The offset has the
|
||||
form:
|
||||
|
||||
hh[:mm[:ss]]
|
||||
|
||||
The minutes (mm) and seconds (ss) are
|
||||
optional. The hour (hh) is required and
|
||||
may be a single digit. The offset
|
||||
following std is required. If no offset
|
||||
follows dst, summer time is assumed to
|
||||
be one hour ahead of standard time. One
|
||||
or more digits may be used; the value is
|
||||
always interpreted as a decimal number.
|
||||
The hour must be between zero and 24,
|
||||
and the minutes (and seconds) - if
|
||||
present - between zero and 59. If
|
||||
preceded by a ``-'', the time zone shall
|
||||
be east of the Prime Meridian; otherwise
|
||||
it shall be west (which may be indicated
|
||||
by an optional preceding ``+'').
|
||||
|
||||
rule Indicates when to change to and back
|
||||
from summer time. The rule has the
|
||||
form:
|
||||
|
||||
date/time,date/time
|
||||
|
||||
where the first date describes when the
|
||||
change from standard to summer time
|
||||
occurs and the second date describes
|
||||
when the change back happens. Each time
|
||||
field describes when, in current local
|
||||
time, the change to the other time is
|
||||
made.
|
||||
|
||||
The format of date is one of the
|
||||
following:
|
||||
|
||||
Jn The Julian day n
|
||||
(1 < n < 365). Leap days are
|
||||
not counted; that is, in all
|
||||
years - including leap years -
|
||||
February 28 is day 59 and
|
||||
March 1 is day 60. It is
|
||||
impossible to explicitly refer
|
||||
to the occasional February 29.
|
||||
|
||||
n The zero-based Julian day
|
||||
(0 < n < 365). Leap days are
|
||||
counted, and it is possible to
|
||||
refer to February 29.
|
||||
|
||||
Mm.n.d The d'th day (0 < d < 6) of
|
||||
week n of month m of the year
|
||||
(1 < n < 5, 1 < m < 12, where
|
||||
week 5 means ``the last d day
|
||||
in month m'' which may occur
|
||||
in either the fourth or the
|
||||
fifth week). Week 1 is the
|
||||
first week in which the d'th
|
||||
day occurs. Day zero is
|
||||
Sunday.
|
||||
|
||||
The time has the same format as offset
|
||||
except that no leading sign (``-'' or
|
||||
``+'') is allowed. The default, if time
|
||||
is not given, is 02:00:00.
|
||||
|
||||
If no rule is present in TZ, the rules specified by the
|
||||
tzfile(5)-format file posixrules in the system time
|
||||
conversion information directory are used, with the standard
|
||||
and summer time offsets from UTC replaced by those specified
|
||||
by the offset values in TZ.
|
||||
|
||||
For compatibility with System V Release 3.1, a semicolon (;)
|
||||
may be used to separate the rule from the rest of the
|
||||
specification.
|
||||
|
||||
If the TZ environment variable does not specify a
|
||||
tzfile(5)-format and cannot be interpreted as a direct
|
||||
specification, UTC is used.
|
||||
|
||||
FILES
|
||||
/usr/local/etc/zoneinfo time zone information
|
||||
directory
|
||||
/usr/local/etc/zoneinfo/localtime local time zone file
|
||||
/usr/local/etc/zoneinfo/posixrules used with POSIX-style
|
||||
TZ's
|
||||
/usr/local/etc/zoneinfo/GMT for UTC leap seconds
|
||||
|
||||
If /usr/local/etc/zoneinfo/GMT is absent, UTC leap seconds
|
||||
are loaded from /usr/local/etc/zoneinfo/posixrules.
|
||||
|
||||
SEE ALSO
|
||||
getenv(3), newctime(3), newstrftime(3), time(2), tzfile(5)
|
|
@ -81,6 +81,8 @@ static char privatehid[] = "@(#)private.h 7.55";
|
|||
#define ctime_r _incompatible_ctime_r
|
||||
#endif /* HAVE_INCOMPATIBLE_CTIME_R */
|
||||
|
||||
void logwtmp(char *, char *, char *);
|
||||
|
||||
/*
|
||||
** Nested includes
|
||||
*/
|
||||
|
@ -203,7 +205,7 @@ extern int errno;
|
|||
*/
|
||||
|
||||
#ifndef asctime_r
|
||||
extern char * asctime_r();
|
||||
extern char * asctime_r(register const struct tm *, char *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
#ifndef lint
|
||||
|
@ -11,13 +14,12 @@ static char sccsid[] = "@(#)scheck.c 7.15";
|
|||
#endif /* !lint */
|
||||
|
||||
#include "ctype.h"
|
||||
#include "private.h"
|
||||
|
||||
extern char * imalloc();
|
||||
|
||||
char *
|
||||
const char *
|
||||
scheck(string, format)
|
||||
char * string;
|
||||
char * format;
|
||||
const char * string;
|
||||
const char * format;
|
||||
{
|
||||
register char * fbuf;
|
||||
register char * fp;
|
||||
|
@ -32,8 +34,8 @@ char * format;
|
|||
fbuf = imalloc(2 * strlen(format) + 4);
|
||||
if (fbuf == NULL)
|
||||
return result;
|
||||
fp = format;
|
||||
tp = fbuf;
|
||||
fp = (char *) format;
|
||||
tp = (char *) fbuf;
|
||||
while ((*tp++ = c = *fp++) != '\0') {
|
||||
if (c != '%')
|
||||
continue;
|
||||
|
@ -58,7 +60,7 @@ char * format;
|
|||
*tp++ = 'c';
|
||||
*tp = '\0';
|
||||
if (sscanf(string, fbuf, &dummy) != 1)
|
||||
result = format;
|
||||
result = (char *) format;
|
||||
free(fbuf);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
NAME
|
||||
|
||||
time2posix, posix2time - convert seconds since the Epoch
|
||||
|
||||
SYNOPSIS
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
time_t time2posix(t)
|
||||
time_t t
|
||||
|
||||
time_t posix2time(t)
|
||||
time_t t
|
||||
|
||||
cc ... -ltz
|
||||
|
||||
DESCRIPTION
|
||||
IEEE Standard 1003.1 (POSIX) legislates that a time_t value
|
||||
of 536457599 shall correspond to "Wed Dec 31 23:59:59 UTC
|
||||
1986." This effectively implies that POSIX time_t's cannot
|
||||
include leap seconds and, therefore, that the system time
|
||||
must be adjusted as each leap occurs.
|
||||
|
||||
If the time package is configured with leap-second support
|
||||
enabled, however, no such adjustment is needed and time_t
|
||||
values continue to increase over leap events (as a true
|
||||
`seconds since...' value). This means that these values
|
||||
will differ from those required by POSIX by the net number
|
||||
of leap seconds inserted since the Epoch.
|
||||
|
||||
Typically this is not a problem as the type time_t is
|
||||
intended to be (mostly) opaque-time_t values should only be
|
||||
obtained-from and passed-to functions such as time(2),
|
||||
localtime(3), mktime(3), and difftime(3). However, POSIX
|
||||
gives an arithmetic expression for directly computing a
|
||||
time_t value from a given date/time, and the same
|
||||
relationship is assumed by some (usually older)
|
||||
applications. Any programs creating/dissecting time_t's
|
||||
using such a relationship will typically not handle
|
||||
intervals over leap seconds correctly.
|
||||
|
||||
The time2posix and posix2time functions are provided to
|
||||
address this time_t mismatch by converting between local
|
||||
time_t values and their POSIX equivalents. This is done by
|
||||
accounting for the number of time-base changes that would
|
||||
have taken place on a POSIX system as leap seconds were
|
||||
inserted or deleted. These converted values can then be
|
||||
used in lieu of correcting the older applications, or when
|
||||
communicating with POSIX-compliant systems.
|
||||
|
||||
Time2posix is single-valued. That is, every local time_t
|
||||
corresponds to a single POSIX time_t. Posix2time is less
|
||||
well-behaved: for a positive leap second hit the result is
|
||||
not unique, and for a negative leap second hit the
|
||||
corresponding POSIX time_t doesn't exist so an adjacent
|
||||
value is returned. Both of these are good indicators of the
|
||||
inferiority of the POSIX representation.
|
||||
|
||||
The following table summarizes the relationship between a
|
||||
time T and it's conversion to, and back from, the POSIX
|
||||
representation over the leap second inserted at the end of
|
||||
June, 1993.
|
||||
DATE TIME T X=time2posix(T) posix2time(X)
|
||||
93/06/30 23:59:59 A+0 B+0 A+0
|
||||
93/06/30 23:59:60 A+1 B+1 A+1 or A+2
|
||||
93/07/01 00:00:00 A+2 B+1 A+1 or A+2
|
||||
93/07/01 00:00:01 A+3 B+2 A+3
|
||||
|
||||
A leap second deletion would look like...
|
||||
|
||||
DATE TIME T X=time2posix(T) posix2time(X)
|
||||
??/06/30 23:59:58 A+0 B+0 A+0
|
||||
??/07/01 00:00:00 A+1 B+2 A+1
|
||||
??/07/01 00:00:01 A+2 B+3 A+2
|
||||
|
||||
[Note: posix2time(B+1) => A+0 or A+1]
|
||||
|
||||
If leap-second support is not enabled, local time_t's and
|
||||
POSIX time_t's are equivalent, and both time2posix and
|
||||
posix2time degenerate to the identity function.
|
||||
|
||||
SEE ALSO
|
||||
difftime(3), localtime(3), mktime(3), time(2)
|
|
@ -1,93 +0,0 @@
|
|||
NAME
|
||||
|
||||
tzfile - time zone information
|
||||
|
||||
SYNOPSIS
|
||||
#include <tzfile.h>
|
||||
|
||||
DESCRIPTION
|
||||
The time zone information files used by tzset(3) begin with
|
||||
the magic characters "TZif" to identify then as time zone
|
||||
information files, followed by sixteen bytes reserved for
|
||||
future use, followed by six four-byte values of type long,
|
||||
written in a ``standard'' byte order (the high-order byte of
|
||||
the value is written first). These values are, in order:
|
||||
|
||||
tzh_ttisgmtcnt
|
||||
The number of UTC/local indicators stored in the file.
|
||||
|
||||
tzh_ttisstdcnt
|
||||
The number of standard/wall indicators stored in the
|
||||
file.
|
||||
|
||||
tzh_leapcnt
|
||||
The number of leap seconds for which data is stored in
|
||||
the file.
|
||||
|
||||
tzh_timecnt
|
||||
The number of "transition times" for which data is
|
||||
stored in the file.
|
||||
|
||||
tzh_typecnt
|
||||
The number of "local time types" for which data is
|
||||
stored in the file (must not be zero).
|
||||
|
||||
tzh_charcnt
|
||||
The number of characters of "time zone abbreviation
|
||||
strings" stored in the file.
|
||||
|
||||
The above header is followed by tzh_timecnt four-byte values
|
||||
of type long, sorted in ascending order. These values are
|
||||
written in ``standard'' byte order. Each is used as a
|
||||
transition time (as returned by time(2)) at which the rules
|
||||
for computing local time change. Next come tzh_timecnt
|
||||
one-byte values of type unsigned char; each one tells which
|
||||
of the different types of ``local time'' types described in
|
||||
the file is associated with the same-indexed transition
|
||||
time. These values serve as indices into an array of ttinfo
|
||||
structures that appears next in the file; these structures
|
||||
are defined as follows:
|
||||
|
||||
struct ttinfo {
|
||||
long tt_gmtoff;
|
||||
int tt_isdst;
|
||||
unsigned int tt_abbrind;
|
||||
};
|
||||
|
||||
Each structure is written as a four-byte value for tt_gmtoff
|
||||
of type long, in a standard byte order, followed by a one-
|
||||
byte value for tt_isdst and a one-byte value for tt_abbrind.
|
||||
In each structure, tt_gmtoff gives the number of seconds to
|
||||
be added to UTC, tt_isdst tells whether tm_isdst should be
|
||||
set by localtime (3) and tt_abbrind serves as an index into
|
||||
the array of time zone abbreviation characters that follow
|
||||
the ttinfo structure(s) in the file.
|
||||
|
||||
Then there are tzh_leapcnt pairs of four-byte values,
|
||||
written in standard byte order; the first value of each pair
|
||||
gives the time (as returned by time(2)) at which a leap
|
||||
second occurs; the second gives the total number of leap
|
||||
seconds to be applied after the given time. The pairs of
|
||||
values are sorted in ascending order by time.
|
||||
|
||||
Then there are tzh_ttisstdcnt standard/wall indicators, each
|
||||
stored as a one-byte value; they tell whether the transition
|
||||
times associated with local time types were specified as
|
||||
standard time or wall clock time, and are used when a time
|
||||
zone file is used in handling POSIX-style time zone
|
||||
environment variables.
|
||||
|
||||
Finally there are tzh_ttisgmtcnt UTC/local indicators, each
|
||||
stored as a one-byte value; they tell whether the transition
|
||||
times associated with local time types were specified as UTC
|
||||
or local time, and are used when a time zone file is used in
|
||||
handling POSIX-style time zone environment variables.
|
||||
|
||||
Localtime uses the first standard-time ttinfo structure in
|
||||
the file (or simply the first ttinfo structure in the
|
||||
absence of a standard-time structure) if either tzh_timecnt
|
||||
is zero or the time argument is less than the first
|
||||
transition time recorded in the file.
|
||||
|
||||
SEE ALSO
|
||||
newctime(3)
|
|
@ -30,7 +30,7 @@ static char tzfilehid[] = "@(#)tzfile.h 7.18";
|
|||
*/
|
||||
|
||||
#ifndef TZDIR
|
||||
#define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */
|
||||
#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
|
||||
#endif /* !defined TZDIR */
|
||||
|
||||
#ifndef TZDEFAULT
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
NAME
|
||||
|
||||
tzselect - select a time zone
|
||||
|
||||
SYNOPSIS
|
||||
tzselect
|
||||
|
||||
DESCRIPTION
|
||||
The tzselect program asks the user for information about the
|
||||
current location, and outputs the resulting time zone
|
||||
description to standard output. The output is suitable as a
|
||||
value for the TZ environment variable.
|
||||
|
||||
All interaction with the user is done via standard input and
|
||||
standard error.
|
||||
|
||||
ENVIRONMENT VARIABLES
|
||||
AWK Name of a Posix-compliant awk program (default: awk).
|
||||
|
||||
TZDIR
|
||||
Name of the directory containing time zone data files
|
||||
(default: /usr/local/etc/zoneinfo).
|
||||
|
||||
FILES
|
||||
TZDIR/iso3166.tab
|
||||
Table of ISO 3166 2-letter country codes and country
|
||||
names.
|
||||
|
||||
TZDIR/zone.tab
|
||||
Table of country codes, latitude and longitude, TZ
|
||||
values, and descriptive comments.
|
||||
|
||||
TZDIR/TZ
|
||||
Time zone data file for time zone TZ.
|
||||
|
||||
EXIT STATUS
|
||||
The exit status is zero if a time zone was successfully
|
||||
obtained from the user, nonzero otherwise.
|
||||
|
||||
SEE ALSO
|
||||
newctime(3), tzfile(5), zdump(8), zic(8)
|
|
@ -1,43 +0,0 @@
|
|||
NAME
|
||||
|
||||
zdump - time zone dumper
|
||||
|
||||
SYNOPSIS
|
||||
zdump [ --version ] [ -v ] [ -c [loyear,]hiyear ] [ zonename
|
||||
... ]
|
||||
|
||||
DESCRIPTION
|
||||
Zdump prints the current time in each zonename named on the
|
||||
command line.
|
||||
|
||||
These options are available:
|
||||
|
||||
--version
|
||||
Output version information and exit.
|
||||
|
||||
-v For each zonename on the command line, print the time
|
||||
at the lowest possible time value, the time one day
|
||||
after the lowest possible time value, the times both
|
||||
one second before and exactly at each detected time
|
||||
discontinuity, the time at one day less than the
|
||||
highest possible time value, and the time at the
|
||||
highest possible time value, Each line ends with
|
||||
isdst=1 if the given time is Daylight Saving Time or
|
||||
isdst=0 otherwise.
|
||||
|
||||
-c [loyear,]hiyear
|
||||
Cut off verbose output near the start of the given
|
||||
year(s). By default, the program cuts off verbose
|
||||
output near the starts of the years -500 and 2500.
|
||||
|
||||
LIMITATIONS
|
||||
The -v option may not be used on systems with floating-point
|
||||
time_t values that are neither float nor double.
|
||||
|
||||
Time discontinuities are found by sampling the results
|
||||
returned by localtime at twelve-hour intervals. This works
|
||||
in all real-world cases; one can construct artificial time
|
||||
zones for which this fails.
|
||||
|
||||
SEE ALSO
|
||||
newctime(3), tzfile(5), zic(8)
|
|
@ -236,9 +236,7 @@ const char * const zone;
|
|||
}
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char * argv[];
|
||||
main( int argc, char * argv[])
|
||||
{
|
||||
register int i;
|
||||
register int c;
|
||||
|
@ -400,6 +398,7 @@ _("%s: usage is %s [ --version ] [ -v ] [ -c [loyear,]hiyear ] zonename ...\n"),
|
|||
static void
|
||||
setabsolutes()
|
||||
{
|
||||
#if 0
|
||||
if (0.5 == (time_t) 0.5) {
|
||||
/*
|
||||
** time_t is floating.
|
||||
|
@ -416,7 +415,9 @@ _("%s: use of -v on system with floating time_t other than float or double\n"),
|
|||
progname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else if (0 > (time_t) -1) {
|
||||
} else
|
||||
#endif
|
||||
if (0 > (time_t) -1) {
|
||||
/*
|
||||
** time_t is signed. Assume overflow wraps around.
|
||||
*/
|
||||
|
|
|
@ -1,259 +0,0 @@
|
|||
NAME
|
||||
|
||||
zic - time zone compiler
|
||||
|
||||
SYNOPSIS
|
||||
zic [ --version ] [ -v ] [ -d directory ] [ -l localtime ] [
|
||||
-p posixrules ] [ -L leapsecondfilename ] [ -s ] [ -y
|
||||
command ] [ filename ... ]
|
||||
|
||||
DESCRIPTION
|
||||
Zic reads text from the file(s) named on the command line
|
||||
and creates the time conversion information files specified
|
||||
in this input. If a filename is -, the standard input is
|
||||
read.
|
||||
|
||||
These options are available:
|
||||
|
||||
--version
|
||||
Output version information and exit.
|
||||
|
||||
-d directory
|
||||
Create time conversion information files in the named
|
||||
directory rather than in the standard directory named
|
||||
below.
|
||||
|
||||
-l timezone
|
||||
Use the given time zone as local time. Zic will act as
|
||||
if the input contained a link line of the form
|
||||
|
||||
Link timezone localtime
|
||||
|
||||
-p timezone
|
||||
Use the given time zone's rules when handling POSIX-
|
||||
format time zone environment variables. Zic will act
|
||||
as if the input contained a link line of the form
|
||||
|
||||
Link timezone posixrules
|
||||
|
||||
-L leapsecondfilename
|
||||
Read leap second information from the file with the
|
||||
given name. If this option is not used, no leap second
|
||||
information appears in output files.
|
||||
|
||||
-v Complain if a year that appears in a data file is
|
||||
outside the range of years representable by time(2)
|
||||
values. Also complain if a time of 24:00 (which cannot
|
||||
be handled by pre-1998 versions of zic) appears in the
|
||||
input.
|
||||
|
||||
-s Limit time values stored in output files to values that
|
||||
are the same whether they're taken to be signed or
|
||||
unsigned. You can use this option to generate SVVS-
|
||||
compatible files.
|
||||
|
||||
-y command
|
||||
Use the given command rather than yearistype when
|
||||
checking year types (see below).
|
||||
|
||||
Input lines are made up of fields. Fields are separated
|
||||
from one another by any number of white space characters.
|
||||
Leading and trailing white space on input lines is ignored.
|
||||
An unquoted sharp character (#) in the input introduces a
|
||||
comment which extends to the end of the line the sharp
|
||||
character appears on. White space characters and sharp
|
||||
characters may be enclosed in double quotes (") if they're
|
||||
to be used as part of a field. Any line that is blank
|
||||
(after comment stripping) is ignored. Non-blank lines are
|
||||
expected to be of one of three types: rule lines, zone
|
||||
lines, and link lines.
|
||||
|
||||
A rule line has the form
|
||||
|
||||
Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
|
||||
For example:
|
||||
|
||||
Rule US 1967 1973 - Apr lastSun 2:00 1:00 D
|
||||
|
||||
The fields that make up a rule line are:
|
||||
|
||||
NAME Gives the (arbitrary) name of the set of rules this
|
||||
rule is part of.
|
||||
|
||||
FROM Gives the first year in which the rule applies. Any
|
||||
integer year can be supplied; the Gregorian calendar
|
||||
is assumed. The word minimum (or an abbreviation)
|
||||
means the minimum year representable as an integer.
|
||||
The word maximum (or an abbreviation) means the
|
||||
maximum year representable as an integer. Rules can
|
||||
describe times that are not representable as time
|
||||
values, with the unrepresentable times ignored; this
|
||||
allows rules to be portable among hosts with
|
||||
differing time value types.
|
||||
|
||||
TO Gives the final year in which the rule applies. In
|
||||
addition to minimum and maximum (as above), the word
|
||||
only (or an abbreviation) may be used to repeat the
|
||||
value of the FROM field.
|
||||
|
||||
TYPE Gives the type of year in which the rule applies.
|
||||
If TYPE is - then the rule applies in all years
|
||||
between FROM and TO inclusive. If TYPE is something
|
||||
else, then zic executes the command
|
||||
yearistype year type
|
||||
to check the type of a year: an exit status of zero
|
||||
is taken to mean that the year is of the given type;
|
||||
an exit status of one is taken to mean that the year
|
||||
is not of the given type.
|
||||
|
||||
IN Names the month in which the rule takes effect.
|
||||
Month names may be abbreviated.
|
||||
|
||||
ON Gives the day on which the rule takes effect.
|
||||
Recognized forms include:
|
||||
|
||||
5 the fifth of the month
|
||||
lastSun the last Sunday in the month
|
||||
lastMon the last Monday in the month
|
||||
Sun>=8 first Sunday on or after the eighth
|
||||
Sun<=25 last Sunday on or before the 25th
|
||||
|
||||
Names of days of the week may be abbreviated or
|
||||
spelled out in full. Note that there must be no
|
||||
spaces within the ON field.
|
||||
|
||||
AT Gives the time of day at which the rule takes
|
||||
effect. Recognized forms include:
|
||||
|
||||
2 time in hours
|
||||
2:00 time in hours and minutes
|
||||
15:00 24-hour format time (for times after noon)
|
||||
1:28:14 time in hours, minutes, and seconds
|
||||
- equivalent to 0
|
||||
|
||||
where hour 0 is midnight at the start of the day,
|
||||
and hour 24 is midnight at the end of the day. Any
|
||||
of these forms may be followed by the letter w if
|
||||
the given time is local "wall clock" time, s if the
|
||||
given time is local "standard" time, or u (or g or
|
||||
z) if the given time is universal time; in the
|
||||
absence of an indicator, wall clock time is assumed.
|
||||
|
||||
SAVE Gives the amount of time to be added to local
|
||||
standard time when the rule is in effect. This
|
||||
field has the same format as the AT field (although,
|
||||
of course, the w and s suffixes are not used).
|
||||
|
||||
LETTER/S
|
||||
Gives the "variable part" (for example, the "S" or
|
||||
"D" in "EST" or "EDT") of time zone abbreviations to
|
||||
be used when this rule is in effect. If this field
|
||||
is -, the variable part is null.
|
||||
|
||||
A zone line has the form
|
||||
|
||||
Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
|
||||
|
||||
For example:
|
||||
|
||||
Zone Australia/Adelaide 9:30 Aus CST 1971 Oct 31 2:00
|
||||
|
||||
The fields that make up a zone line are:
|
||||
|
||||
NAME The name of the time zone. This is the name used in
|
||||
creating the time conversion information file for the
|
||||
zone.
|
||||
|
||||
GMTOFF
|
||||
The amount of time to add to UTC to get standard time
|
||||
in this zone. This field has the same format as the
|
||||
AT and SAVE fields of rule lines; begin the field with
|
||||
a minus sign if time must be subtracted from UTC.
|
||||
|
||||
RULES/SAVE
|
||||
The name of the rule(s) that apply in the time zone
|
||||
or, alternately, an amount of time to add to local
|
||||
standard time. If this field is - then standard time
|
||||
always applies in the time zone.
|
||||
|
||||
FORMAT
|
||||
The format for time zone abbreviations in this time
|
||||
zone. The pair of characters %s is used to show where
|
||||
the "variable part" of the time zone abbreviation
|
||||
goes. Alternately, a slash (/) separates standard and
|
||||
daylight abbreviations.
|
||||
|
||||
UNTIL The time at which the UTC offset or the rule(s) change
|
||||
for a location. It is specified as a year, a month, a
|
||||
day, and a time of day. If this is specified, the
|
||||
time zone information is generated from the given UTC
|
||||
offset and rule change until the time specified. The
|
||||
month, day, and time of day have the same format as
|
||||
the IN, ON, and AT columns of a rule; trailing columns
|
||||
can be omitted, and default to the earliest possible
|
||||
value for the missing columns.
|
||||
|
||||
The next line must be a "continuation" line; this has
|
||||
the same form as a zone line except that the string
|
||||
"Zone" and the name are omitted, as the continuation
|
||||
line will place information starting at the time
|
||||
specified as the UNTIL field in the previous line in
|
||||
the file used by the previous line. Continuation
|
||||
lines may contain an UNTIL field, just as zone lines
|
||||
do, indicating that the next line is a further
|
||||
continuation.
|
||||
|
||||
A link line has the form
|
||||
|
||||
Link LINK-FROM LINK-TO
|
||||
|
||||
For example:
|
||||
|
||||
Link Europe/Istanbul Asia/Istanbul
|
||||
|
||||
The LINK-FROM field should appear as the NAME field in some
|
||||
zone line; the LINK-TO field is used as an alternate name
|
||||
for that zone.
|
||||
|
||||
Except for continuation lines, lines may appear in any order
|
||||
in the input.
|
||||
|
||||
Lines in the file that describes leap seconds have the
|
||||
following form:
|
||||
|
||||
Leap YEAR MONTH DAY HH:MM:SS CORR R/S
|
||||
|
||||
For example:
|
||||
|
||||
Leap 1974 Dec 31 23:59:60 + S
|
||||
|
||||
The YEAR, MONTH, DAY, and HH:MM:SS fields tell when the leap
|
||||
second happened. The CORR field should be "+" if a second
|
||||
was added or "-" if a second was skipped. The R/S field
|
||||
should be (an abbreviation of) "Stationary" if the leap
|
||||
second time given by the other fields should be interpreted
|
||||
as UTC or (an abbreviation of) "Rolling" if the leap second
|
||||
time given by the other fields should be interpreted as
|
||||
local wall clock time.
|
||||
|
||||
NOTES
|
||||
For areas with more than two types of local time, you may
|
||||
need to use local standard time in the AT field of the
|
||||
earliest transition time's rule to ensure that the earliest
|
||||
transition time recorded in the compiled file is correct.
|
||||
|
||||
If, for a particular zone, a clock advance caused by the
|
||||
start of daylight saving coincides with and is equal to a
|
||||
clock retreat caused by a change in UTC offset, zic produces
|
||||
a single transition to daylight saving at the new UTC offset
|
||||
(without any change in wall clock time). To get separate
|
||||
transitions use multiple zone continuation lines specifying
|
||||
transition instants using universal time.
|
||||
|
||||
FILE
|
||||
/usr/local/etc/zoneinfo standard directory used for created
|
||||
files
|
||||
|
||||
SEE ALSO
|
||||
newctime(3), tzfile(5), zdump(8)
|
|
@ -437,8 +437,7 @@ const char * const string;
|
|||
}
|
||||
|
||||
static void
|
||||
warning(string)
|
||||
const char * const string;
|
||||
warning(const char * const string)
|
||||
{
|
||||
char * cp;
|
||||
|
||||
|
@ -467,9 +466,7 @@ static const char * yitcommand;
|
|||
static int sflag = FALSE;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char * argv[];
|
||||
main( int argc, char * argv[])
|
||||
{
|
||||
register int i;
|
||||
register int j;
|
||||
|
@ -1445,9 +1442,7 @@ FILE * const fp;
|
|||
}
|
||||
|
||||
static int
|
||||
atcomp(avp, bvp)
|
||||
void * avp;
|
||||
void * bvp;
|
||||
atcomp(const void * avp, const void * bvp)
|
||||
{
|
||||
if (((struct attype *) avp)->at < ((struct attype *) bvp)->at)
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue