Skip to content

Commit a495a57

Browse files
committed
Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996. Fixes PR standards/11807 by Nick Hudson.
1 parent 4ce4608 commit a495a57

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

include/time.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: time.h,v 1.26 2001/03/29 19:06:39 kleink Exp $ */
1+
/* $NetBSD: time.h,v 1.27 2001/03/31 18:29:20 kleink Exp $ */
22

33
/*
44
* Copyright (c) 1989, 1993
@@ -113,6 +113,10 @@ void tzset __P((void));
113113
*/
114114
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
115115
(_XOPEN_SOURCE - 0) >= 4
116+
extern int daylight;
117+
#ifndef __LIBC12_SOURCE__
118+
extern long int timezone __RENAME(__timezone13);
119+
#endif
116120
char *strptime __P((const char * __restrict, const char * __restrict,
117121
struct tm * __restrict));
118122
#endif
@@ -149,7 +153,9 @@ time_t posix2time __P((time_t));
149153
time_t timegm __P((struct tm *const));
150154
time_t timeoff __P((struct tm *const, const long));
151155
time_t timelocal __P((struct tm *const));
156+
#ifdef __LIBC12_SOURCE__
152157
char *timezone __P((int, int));
158+
#endif
153159
void tzsetwall __P((void));
154160
struct tm *offtime __P((const time_t *const, const long));
155161
#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */

lib/libc/gen/timezone.3

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" $NetBSD: timezone.3,v 1.10 1998/08/02 03:20:41 jeremy Exp $
1+
.\" $NetBSD: timezone.3,v 1.11 2001/03/31 18:29:21 kleink Exp $
22
.\"
33
.\" Copyright (c) 1991, 1993
44
.\" The Regents of the University of California. All rights reserved.
@@ -47,11 +47,15 @@
4747
.Sh DESCRIPTION
4848
.Bf -symbolic
4949
.\" This interface is available from the compatibility library, libcompat;
50-
This interface is available for compatibility;
50+
This interface is available for compatibility only and will disappear in a
51+
future software release;
5152
it is impossible to reliably map timezone's arguments to a time zone
5253
abbreviation.
5354
See
54-
.Xr ctime 3 .
55+
.Xr ctime 3 ;
56+
see
57+
.Xr tzset 3
58+
for the new definition of this interface.
5559
.Ef
5660
.Pp
5761
The
@@ -66,7 +70,8 @@ is the number of minutes west of GMT and
6670
.Ar dst
6771
is non-zero if daylight savings time is in effect.
6872
.Sh SEE ALSO
69-
.Xr ctime 3
73+
.Xr ctime 3 ,
74+
.Xr tzset 3
7075
.Sh HISTORY
7176
A
7277
.Fn timezone

lib/libc/gen/timezone.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: timezone.c,v 1.14 2000/01/23 07:37:47 mycroft Exp $ */
1+
/* $NetBSD: timezone.c,v 1.15 2001/03/31 18:29:21 kleink Exp $ */
22

33
/*
44
* Copyright (c) 1987, 1993
@@ -38,10 +38,12 @@
3838
#if 0
3939
static char sccsid[] = "@(#)timezone.c 8.1 (Berkeley) 6/4/93";
4040
#else
41-
__RCSID("$NetBSD: timezone.c,v 1.14 2000/01/23 07:37:47 mycroft Exp $");
41+
__RCSID("$NetBSD: timezone.c,v 1.15 2001/03/31 18:29:21 kleink Exp $");
4242
#endif
4343
#endif /* LIBC_SCCS and not lint */
4444

45+
#define __LIBC12_SOURCE__
46+
4547
#include "namespace.h"
4648
#include <sys/types.h>
4749
#include <sys/time.h>
@@ -50,12 +52,6 @@ __RCSID("$NetBSD: timezone.c,v 1.14 2000/01/23 07:37:47 mycroft Exp $");
5052
#include <string.h>
5153
#include <tzfile.h>
5254

53-
#if 0
54-
#ifdef __weak_alias
55-
__weak_alias(timezone,_timezone)
56-
#endif
57-
#endif
58-
5955
/*
6056
* timezone --
6157
* The arguments are the number of minutes of time you are westward

lib/libc/time/Makefile.inc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# $NetBSD: Makefile.inc,v 1.7 1999/05/04 15:34:50 kleink Exp $
1+
# $NetBSD: Makefile.inc,v 1.8 2001/03/31 18:29:21 kleink Exp $
22

33
.PATH: ${.CURDIR}/time
44

5-
SRCS+= asctime.c difftime.c localtime.c strftime.c strptime.c
5+
SRCS+= _daylight.c \
6+
asctime.c difftime.c localtime.c strftime.c strptime.c
67
MAN+= ctime.3 time2posix.3 tzfile.5 tzset.3 strftime.3 strptime.3
7-
CFLAGS+=-DALL_STATE
8+
CFLAGS+=-DALL_STATE -DUSG_COMPAT
89

910
MLINKS+=ctime.3 ctime_r.3 \
1011
ctime.3 asctime.3 \

lib/libc/time/_daylight.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* $NetBSD: _daylight.c,v 1.1 2001/03/31 18:29:21 kleink Exp $ */
2+
3+
/*
4+
* Written by Klaus Klein, December 27, 2000.
5+
* Public domain.
6+
*/
7+
8+
#include <sys/cdefs.h>
9+
10+
#ifdef __indr_reference
11+
__indr_reference(_daylight, daylight)
12+
#endif
13+
/* LINTED empty translation unit */

lib/libc/time/localtime.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: localtime.c,v 1.24 2000/09/13 22:32:28 msaitoh Exp $ */
1+
/* $NetBSD: localtime.c,v 1.25 2001/03/31 18:29:21 kleink Exp $ */
22

33
/*
44
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
1010
#if 0
1111
static char elsieid[] = "@(#)localtime.c 7.70";
1212
#else
13-
__RCSID("$NetBSD: localtime.c,v 1.24 2000/09/13 22:32:28 msaitoh Exp $");
13+
__RCSID("$NetBSD: localtime.c,v 1.25 2001/03/31 18:29:21 kleink Exp $");
1414
#endif
1515
#endif /* LIBC_SCCS and not lint */
1616

@@ -30,6 +30,7 @@ __RCSID("$NetBSD: localtime.c,v 1.24 2000/09/13 22:32:28 msaitoh Exp $");
3030

3131
#ifdef __weak_alias
3232
__weak_alias(ctime_r,_ctime_r)
33+
__weak_alias(daylight,_daylight)
3334
__weak_alias(gmtime_r,_gmtime_r)
3435
__weak_alias(localtime_r,_localtime_r)
3536
__weak_alias(offtime,_offtime)

lib/libc/time/tzset.3

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" $NetBSD: tzset.3,v 1.12 2001/03/29 20:56:30 kleink Exp $
1+
.\" $NetBSD: tzset.3,v 1.13 2001/03/31 18:29:21 kleink Exp $
22
.TH TZSET 3
33
.SH NAME
44
tzset \- initialize time conversion information
@@ -8,6 +8,8 @@ Standard C Library (libc, -lc)
88
.nf
99
.B void tzset(void);
1010
.PP
11+
.B extern long int timezone;
12+
.B extern int daylight;
1113
.fi
1214
.SH DESCRIPTION
1315
.I Tzset
@@ -215,6 +217,16 @@ environment variable does not specify a
215217
.IR tzfile (5)-format
216218
and cannot be interpreted as a direct specification,
217219
UTC is used.
220+
.PP
221+
.I Tzset
222+
sets the external variable
223+
.I timezone
224+
to the difference, in seconds, between Coordinated Universal Time (UTC)
225+
and local standard time.
226+
The external variable
227+
.I daylight
228+
is set to 0 if Daylight Savings Time conversions should never be applied
229+
for the time zone in use; otherwise non-zero.
218230
.SH FILES
219231
.ta \w'/usr/share/zoneinfo/posixrules\0\0'u
220232
/etc/localtime local time zone file

0 commit comments

Comments
 (0)