4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1995 Sun Microsystems, Inc. All rights reserved.
26 #ident "%Z%%M% %I% %E% SMI"
34 static int get_tzp_info(void);
35 extern long _timezone
, _altzone
; /* from the base libc */
39 * The second parameter to gettimeofday() did not work correctly on
40 * 4.x, and it was documented that localtime() should be used instead.
41 * This is an attempt to provide correctly what 4.x meant to do. There
42 * are shortcomings, however. See notes for DST_RUM and DST_AUSTALT.
53 if ((ret
= _gettimeofday(tp
)) == -1)
57 * We should call localtime() with the current time and
58 * set tz_minuteswest to _altzone/SECSPERMIN if tm_isdst
59 * is set. But we want to be bug-for-bug compatible with
60 * 4.x, which would never adjust for DST. Futher comments
61 * are in get_tzp_info().
65 tzp
->tz_dsttime
= get_tzp_info();
66 tzp
->tz_minuteswest
= _timezone
/SECSPERMIN
;
75 char *zonename
= getenv("TZ");
77 if ((zonename
== NULL
) || (*zonename
== '\0'))
80 if ((strncmp(zonename
, "US/", 3) == 0) ||
81 (strcmp(zonename
, "PST8PDT") == 0) ||
82 (strcmp(zonename
, "MST7MDT") == 0) ||
83 (strcmp(zonename
, "CST6CDT") == 0) ||
84 (strcmp(zonename
, "EST5EDT") == 0) ||
85 (strncmp(zonename
, "America/", 8) == 0))
88 if (strncmp(zonename
, "Australia/", 10) == 0)
91 if (strcmp(zonename
, "WET") == 0)
94 if (strcmp(zonename
, "MET") == 0)
97 if (strcmp(zonename
, "EET") == 0)
100 if (strncmp(zonename
, "Canada/", 7) == 0)
103 if ((strcmp(zonename
, "GB") == 0) ||
104 (strcmp(zonename
, "GB-Eire") == 0))
108 * what's the corresponding DST_RUM: Rumanian DST?
109 * There was not Rumanian timezone on 4.x.
112 if (strcmp(zonename
, "Turkey") == 0)
116 * How do we differentiate between DST_AUST and DST_AUSTALT?
117 * It seems that all of our current Australia timezones do
118 * not have the 1986 shift, so we never will return DST_AUSTALT.