diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/time/Arts.htm | 149 | ||||
-rw-r--r-- | lib/libc/time/Music | 81 | ||||
-rw-r--r-- | lib/libc/time/README | 7 | ||||
-rw-r--r-- | lib/libc/time/Theory | 240 | ||||
-rw-r--r-- | lib/libc/time/WWW | 71 | ||||
-rw-r--r-- | lib/libc/time/WWW.htm | 100 | ||||
-rw-r--r-- | lib/libc/time/asctime.c | 9 | ||||
-rw-r--r-- | lib/libc/time/difftime.c | 9 | ||||
-rw-r--r-- | lib/libc/time/ialloc.c | 16 | ||||
-rw-r--r-- | lib/libc/time/localtime.c | 96 | ||||
-rw-r--r-- | lib/libc/time/private.h | 17 | ||||
-rw-r--r-- | lib/libc/time/scheck.c | 14 | ||||
-rw-r--r-- | lib/libc/time/time2posix.3 | 8 | ||||
-rw-r--r-- | lib/libc/time/tzfile.5 | 16 | ||||
-rw-r--r-- | lib/libc/time/tzfile.h | 13 | ||||
-rw-r--r-- | lib/libc/time/tzset.3 | 6 | ||||
-rw-r--r-- | lib/libc/time/zdump.c | 49 | ||||
-rw-r--r-- | lib/libc/time/zic.8 | 14 | ||||
-rw-r--r-- | lib/libc/time/zic.c | 80 |
19 files changed, 653 insertions, 342 deletions
diff --git a/lib/libc/time/Arts.htm b/lib/libc/time/Arts.htm new file mode 100644 index 00000000000..87468b04102 --- /dev/null +++ b/lib/libc/time/Arts.htm @@ -0,0 +1,149 @@ +<pre> +$OpenBSD: Arts.htm,v 1.1 1998/01/18 23:24:43 millert Exp $ +@(#)Arts.htm 7.15 + +Data on recordings of "Save That Time," Russ Long, Serrob Publishing, BMI: +-------------------------------------------------------------------------- +Artist: Karrin Allyson +CD: I Didn't Know About You +Copyright Date: 1993 +Label: Concord Jazz, Inc. +ID: CCD-4543 +Track Time: 3:44 +Personnel: Karrin Allyson, vocal + Russ Long, piano + Gerald Spaits, bass + Todd Strait, drums +Notes: CD notes "additional lyric by Karrin Allyson; + arranged by Russ Long and Karrin Allyson" +ADO Rating: 1 star +<a href="http://205.186.189.2/cgi-win/amg.exe?sql=1A_IDR|||175928">AMG Rating: 3.5 stars</a> +Penguin Rating: 3.5 stars +-------------------------------------------------------------------------- +Artist: Kevin Mahogany +CD: Double Rainbow +Copyright Date: 1993 +Label: Enja Records +ID: ENJ-7097 2 +Track Time: 6:27 +Personnel: Kevin Mahogany, vocal + Kenny Barron, piano + Ray Drummond, bss + Ralph Moore, tenor saxophone + Lewis Nash, drums +ADO Rating: 1.5 stars +<a href="http://205.186.189.2/cgi-win/amg.exe?sql=1A_IDR|||262654">AMG Rating: unrated</a> +Penguin Rating: 3 stars +-------------------------------------------------------------------------- +Artist: Joe Williams +CD: Here's to Life +Copyright Date: 1994 +Label: Telarc International Corporation +ID: CD-83357 +Track Time: 3:58 +Personnel: Joe Williams, vocal + The Robert Farnon [39 piece] Orchestra +Notes: On-line information and samples available at + <a href="http://telarc.dmn.com/telarc/release.req?ID=TEL-83357">http://telarc.dmn.com/telarc/release.req?ID=TEL-83357</a> +ADO Rating: black dot +<a href="http://205.186.189.2/cgi-win/amg.exe?sql=1A_IDR|||194434">AMG Rating: 2 stars</a> +Penguin Rating: 3 stars +-------------------------------------------------------------------------- +Artist: Charles Fambrough +CD: Keeper of the Spirit +Copyright Date: 1995 +Label: AudioQuest Music +ID: AQ-CD1033 +Track Time: 7:07 +Personnel: Charles Fambrough, bass + Joel Levine, tenor recorder + Edward Simon, piano + Lenny White, drums + Marion Simon, percussion +Notes: On-line information and samples available at + <a href="http://wwmusic.com/~music/audioq/rel/1033.html">http://wwmusic.com/~music/audioq/rel/1033.html</a> +ADO Rating: 2 stars +<a href="http://205.186.189.2/cgi-win/AMG.exe?sql=1A_IDR|||224430">AMG Rating: unrated</a> +Penguin Rating: 3 stars +========================================================================== +Also of note: +-------------------------------------------------------------------------- +Artist: Holly Cole Trio +CD: Blame It On My Youth +Copyright Date: 1992 +Label: Manhattan +ID: CDP 7 97349 2 +Total Time: 37:45 +Personnel: Holly Cole, voice + Aaron Davis, piano + David Piltch, string bass +Notes: Lyrical reference to "Eastern Standard Time" in + Tom Waits' "Purple Avenue" +ADO Rating: 2.5 stars +<a href="http://205.186.189.2/cgi-win/AMG.exe?sql=1A_IDR|||157959">AMG Rating: 2 stars</a> +Penguin Rating: unrated +-------------------------------------------------------------------------- +Artist: Milt Hinton +CD: Old Man Time +Copyright Date: 1990 +Label: Chiaroscuro +ID: CR(D) 310 +Total Time: 149:38 (two CDs) +Personnel: Milt Hinton, bass + Doc Cheatham, Dizzy Gillespie, Clark Terry, trumpet + Al Grey, trombone + Eddie Barefield, Joe Camel (Flip Phillips), Buddy Tate, + clarinet and saxophone + John Bunch, Red Richards, Norman Simmons, Derek Smith, + Ralph Sutton, piano + Danny Barker, Al Casey, guitar + Gus Johnson, Gerryck King, Bob Rosengarden, Jackie Williams, + drums + Lionel Hampton, vibraphone + Cab Calloway, Joe Williams, vocal + Buck Clayton, arrangements +Notes: tunes include Old Man Time, Time After Time, + Sometimes I'm Happy, + A Hot Time in the Old Town Tonight, + Four or Five Times, Now's the Time, + Time on My Hands, This Time It's Us, + and Good Time Charlie + On-line samples available at + <a href="http://www.globalmusic.com/labels/chiaroscuro/chiaro_cd_gallery.html">http://www.globalmusic.com/labels/chiaroscuro/chiaro_cd_gallery.html</a> +ADO Rating: 3 stars +<a href="http://205.186.189.2/cgi-win/AMG.exe?sql=1A_IDR|||162344">AMG Rating: 4 stars</a> +Penguin Rating: 3 stars +-------------------------------------------------------------------------- +Artist: Paul Broadbent +CD: Pacific Standard Time +Copyright Date: 1995 +Label: Concord Jazz, Inc. +ID: CCD-4664 +Total Time: 62:42 +Personnel: Paul Broadbent, piano + Putter Smith, Bass + Frank Gibson, Jr., drums +Notes: The CD cover features an analemma for equation of time fans +ADO Rating: 1 star +<a href="http://205.186.189.2/cgi-win/AMG.exe?sql=1A_IDR|||223722">AMG Rating: unrated</a> +Penguin Rating: 3.5 stars +-------------------------------------------------------------------------- +Artist: Jules Verne +Book: Le Tour du Monde en Quatre-Vingts Jours + (Around the World in Eighty Days) +Notes: Wall-clock time plays a central role in the plot. + European readers of the 1870s clearly held the U.S. press in + deep contempt; the protagonists cross the U.S. without once + reading a paper. + An on-line French-language version of the book + "with illustrations from the original 1873 French-language edition" + is available at + <a href="http://fourmilab.ch/etexts/www/tdm80j">http://fourmilab.ch/etexts/www/tdm80j</a> + An on-line English-language translation of the book is available at + <a href="http://www.literature.org/Works/Jules-Verne/eighty">http://www.literature.org/Works/Jules-Verne/eighty</a> +</pre> +-------------------------------------------------------------------------- +Film: Bell Science - About Time +Notes: The Frank Baxter/Richard Deacon extravaganza + Information on ordering is available at + <a href="http://www.videoflicks.com/VF/38/038332.htm">http://www.videoflicks.com/VF/38/038332.htm</a> diff --git a/lib/libc/time/Music b/lib/libc/time/Music deleted file mode 100644 index e8e9adae0bb..00000000000 --- a/lib/libc/time/Music +++ /dev/null @@ -1,81 +0,0 @@ -$OpenBSD: Music,v 1.2 1996/08/19 08:34:45 tholo Exp $ - -Data on recordings of "Save That Time," Russ Long, Serrob Publishing, BMI: --------------------------------------------------------------------------- -Artist: Karrin Allyson -CD: I Didn't Know About You -Copyright Date: 1993 -Label: Concord Jazz, Inc. -ID: CCD-4543 -Track Time: 3:44 -Personnel: Karrin Allyson, vocal - Russ Long, piano - Gerald Spaits, bass - Todd Strait, drums -Notes: CD notes "additional lyric by Karrin Allyson; - arranged by Russ Long and Karrin Allyson" -Rating: 1 star --------------------------------------------------------------------------- -Artist: Kevin Mahogany -CD: Double Rainbow -Copyright Date: 1993 -Label: Enja Records -ID: ENJ-7097 2 -Track Time: 6:27 -Personnel: Kevin Mahogany, vocal - Kenny Barron, piano - Ray Drummond, bss - Ralph Moore, tenor saxophone - Lewis Nash, drums -Rating: 1.5 stars --------------------------------------------------------------------------- -Artist: Joe Williams -CD: Here's to Life -Copyright Date: 1994 -Label: Telarc International Corporation -ID: CD-83357 -Track Time: 3:58 -Personnel: Joe Williams, vocal - The Robert Farnon [39 piece] Orchestra -Rating: black dot --------------------------------------------------------------------------- -Artist: Charles Fambrough -CD: Keeper of the Spirit -Copyright Date: 1995 -Label: AudioQuest Music -ID: AQ-CD1033 -Track Time: 7:07 -Personnel: Charles Fambrough, bass - Joel Levine, tenor recorder - Edward Simon, piano - Lenny White, drums - Marion Simon, percussion -Rating: 2 stars -========================================================================== -Also of note: -Artist: Milt Hinton -CD: Old Man Time -Date: 1993 -Label: Chiaroscuro -ID: CR(D) 310 -Total Time: 149:38 (two CDs) -Personnel: Milt Hinton, bass - Doc Cheatham, Dizzy Gillespie, Clark Terry, trumpet - Al Grey, trombone - Eddier Barefield, Joe Camel (Flip Phillips), Buddy Tate, - clarinet and saxophone - John Bunch, Red Richards, Norman Simmons, Derek Smith, - Ralph Sutton, piano - Danny Barker, Al Casey, guitar - Gus Johnson, Gerryck King, Bob Rosengarden, Jackie Williams, - drums - Lionel Hampton, vibraphone - Cab Calloway, Joe Williams, vocal - Buck Clayton, arrangements -Notes: tunes include Old Man Time, Time After Time, - Sometimes I'm Happy, - A Hot Time in the Old Town Tonight, - Four or Five Times, Now's the Time, - Time on My Hands, This Time It's Us, - and Good Time Charlie -Rating: 3 stars diff --git a/lib/libc/time/README b/lib/libc/time/README index c54e0c7b3fa..80276794113 100644 --- a/lib/libc/time/README +++ b/lib/libc/time/README @@ -1,8 +1,9 @@ -$OpenBSD: README,v 1.2 1996/08/19 08:34:46 tholo Exp $ +$OpenBSD: README,v 1.3 1998/01/18 23:24:46 millert Exp $ +@(#)README 7.10 "What time is it?" -- Richard Deacon as The King "Any time you want it to be." -- Frank Baxter as The Scientist - (from the Bell System film on time) + (from the Bell System film "About Time") The 1989 update of the time zone package featured @@ -36,7 +37,7 @@ leap second information from its output files. Be sure to read the comments in "Makefile" and make any changes needed to make things right for your system. -To use the new functions, use a "-lz" option when compiling or linking. +To use the new functions, use a "-ltz" option when compiling or linking. Historical local time information has been included here not because it is particularly useful, but rather to: diff --git a/lib/libc/time/Theory b/lib/libc/time/Theory index 5dd6f068f13..5625f0ae4b4 100644 --- a/lib/libc/time/Theory +++ b/lib/libc/time/Theory @@ -1,40 +1,85 @@ -$OpenBSD: Theory,v 1.3 1996/08/19 08:34:46 tholo Exp $ - -These time and date functions are much like the System V Release 2.0 (SVR2) -time and date functions; there are a few additions and changes to extend -the usefulness of the SVR2 functions: - -* In SVR2, time display in a process is controlled by the environment - variable TZ, which "must be a three-letter time zone name, followed - by a number representing the difference between local time and - Greenwich Mean Time in hours, followed by an optional three-letter - name for a daylight time zone;" when the optional daylight time zone is - present, "standard U.S.A. Daylight Savings Time conversion is applied." - This means that SVR2 can't deal with other (for example, Australian) - daylight savings time rules, or situations where more than two +$OpenBSD: Theory,v 1.4 1998/01/18 23:24:47 millert Exp $ +@(#)Theory 7.6 + + +----- Outline ----- + + Time and date functions + Names of time zone regions + Time zone abbreviations + + +----- Time and date functions ----- + +These time and date functions are upwards compatible with POSIX.1, +an international standard for Unix-like systems. +As of this writing, the current edition of POSIX.1 is: + + Information technology --Portable Operating System Interface (POSIX (R)) + -- Part 1: System Application Program Interface (API) [C Language] + ISO/IEC 9945-1:1996 + ANSI/IEEE Std 1003.1, 1996 Edition + 1996-07-12 + +POSIX.1 has the following properties and limitations. + +* In POSIX.1, time display in a process is controlled by the + environment variable TZ. Unfortunately, the POSIX.1 TZ string takes + a form that is hard to describe and is error-prone in practice. + Also, POSIX.1 TZ strings can't deal with other (for example, Israeli) + daylight saving time rules, or situations where more than two time zone abbreviations are used in an area. -* In SVR2, time conversion information is compiled into each program - that does time conversion. This means that when time conversion + The POSIX.1 TZ string takes the following form: + + stdoffset[dst[offset],date[/time],date[/time]] + + where: + + std and dst + are 3 or more characters specifying the standard + and daylight saving time (DST) zone names. + offset + is of the form `[-]hh:[mm[:ss]]' and specifies the + offset west of UTC. The default DST offset is one hour + ahead of standard time. + date[/time],date[/time] + specifies the beginning and end of DST. If this is absent, + the system supplies its own rules for DST, and these can + differ from year to year; typically US DST rules are used. + time + takes the form `hh:[mm[:ss]]' and defaults to 02:00. + date + takes one of the following forms: + Jn (1<=n<=365) + origin-1 day number not counting February 29 + n (0<=n<=365) + origin-0 day number counting February 29 if present + Mm.n.d (0[Sunday]<=d<=6[Saturday], 1<=n<=5, 1<=m<=12) + for the dth day of week n of month m of the year, + where week 1 is the first week in which day d appears, + and `5' stands for the last week in which day d appears + (which may be either the 4th or 5th week). + +* In POSIX.1, when a TZ value like "EST5EDT" is parsed, + typically the current US DST rules are used, + but this means that the US DST rules are compiled into each program + that does time conversion. This means that when US time conversion rules change (as in the United States in 1987), all programs that do time conversion must be recompiled to ensure proper results. -* In SVR2, time conversion fails for near-minimum or near-maximum - time_t values when doing conversions for places that don't use GMT. - -* In SVR2, there's no tamper-proof way for a process to learn the +* In POSIX.1, there's no tamper-proof way for a process to learn the system's best idea of local wall clock. (This is important for applications that an administrator wants used only at certain times-- without regard to whether the user has fiddled the "TZ" environment - variable. While an administrator can "do everything in GMT" to get + variable. While an administrator can "do everything in UTC" to get around the problem, doing so is inconvenient and precludes handling - daylight savings time shifts--as might be required to limit phone + daylight saving time shifts--as might be required to limit phone calls to off-peak hours.) -* These functions can account for leap seconds, thanks to Bradley White - (bww@k.cs.cmu.edu). +* POSIX.1 requires that systems ignore leap seconds. -These are the changes that have been made to the SVR2 functions: +These are the extensions that have been made to the POSIX.1 functions: * The "TZ" environment variable is used in generating the name of a file from which time zone information is read (or is interpreted a la @@ -62,13 +107,12 @@ These are the changes that have been made to the SVR2 functions: * To handle places where more than two time zone abbreviations are used, the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst] (where "tmp" is the value the function returns) to the time zone - abbreviation to be used. This differs from SVR2, where the elements + abbreviation to be used. This differs from POSIX.1, where the elements of tzname are only changed as a result of calls to tzset. * Since the "TZ" environment variable can now be used to control time conversion, the "daylight" and "timezone" variables are no longer - needed or supported. (You can use a compile-time option to cause - these variables to be defined and to be set by "tzset"; however, their + needed. (These variables are defined and set by "tzset"; however, their values will not be used by "localtime.") * The "localtime" function has been set up to deliver correct results @@ -86,9 +130,21 @@ These are the changes that have been made to the SVR2 functions: environment variable; portable applications should not, however, rely on this behavior since it's not the way SVR2 systems behave.) -Points of interest to folks with Version 7 or BSD systems: +* These functions can account for leap seconds, thanks to Bradley White + (bww@k.cs.cmu.edu). + +Points of interest to folks with other systems: + +* This package is already part of many POSIX-compliant hosts, + including BSD, HP, Linux, Network Appliance, SCO, SGI, and Sun. + On such hosts, the primary use of this package + is to update obsolete time zone rule tables. + To do this, you may need to compile the time zone compiler + `zic' supplied with this package instead of using the system `zic', + since the format of zic's input changed slightly in late 1994, + and many vendors still do not support the new input format. -* The BSD "timezone" function is not present in this package; +* The Unix Version 7 "timezone" function is not present in this package; it's impossible to reliably map timezone's arguments (a "minutes west of GMT" value and a "daylight saving time in effect" flag) to a time zone abbreviation, and we refuse to guess. @@ -97,12 +153,13 @@ Points of interest to folks with Version 7 or BSD systems: zone abbreviation to use. Alternatively, use localtime(&clock)->tm_zone if this has been enabled. -* The BSD gettimeofday function is not used in this package; - this lets users control the time zone used in doing time conversions. - Users who don't try to control things (that is, users who do not set - the environment variable TZ) get the time conversion specified in the - file "/etc/zoneinfo/localtime"; see the time zone compiler writeup for - information on how to initialize this file. +* The 4.2BSD gettimeofday function is not used in this package. + This formerly let users obtain the current UTC offset and DST flag, + but this functionality was removed in later versions of BSD. + +* In SVR2, time conversion fails for near-minimum or near-maximum + time_t values when doing conversions for places that don't use UTC. + This package takes care to do these conversions correctly. The functions that are conditionally compiled if STD_INSPIRED is defined should, at this point, be looked on primarily as food for thought. They are @@ -115,6 +172,115 @@ Hewlett Packard, offer a wider selection of functions that provide capabilities beyond those provided here. The absence of such functions from this package is not meant to discourage the development, standardization, or use of such functions. Rather, their absence reflects the decision to make this package -close to SVR2 (with the exceptions outlined above) to ensure its broad +contain valid extensions to POSIX.1, to ensure its broad acceptability. If more powerful time conversion functions can be standardized, so much the better. + + +----- Names of time zone rule files ----- + +The names of this package's installed time zone rule files are chosen to +help minimize possible future incompatibilities due to political events. +Ordinarily, names of countries are not used, to avoid incompatibilities +when countries change their name (e.g. Zaire->Congo) or +when locations change countries (e.g. Hong Kong from UK colony to China). + +Names normally have the form AREA/LOCATION, where AREA is the name +of a continent or ocean, and LOCATION is the name of a specific +location within that region. North and South America share the same +area, `America'. Typical names are `Africa/Cairo', `America/New_York', +and `Pacific/Honolulu'. + +Here are the general rules used for choosing location names, +in decreasing order of importance: + + Use only valid Posix file names. Use only Ascii letters, digits, `.', + `-' and `_'. Do not exceed 14 characters or start with `-'. + E.g. prefer `Brunei' to `Bandar_Seri_Begawan'. + Include at least one location per time zone rule set per country. + One such location is enough. + If all the clocks in a country's region have agreed since 1970, + don't bother to include more than one location + even if subregions' clocks disagreed before 1970. + Otherwise these tables would become annoyingly large. + If a name is ambiguous, use a less ambiguous alternative; + e.g. many cities are named San Jose and Georgetown, so + prefer `Costa_Rica' to `San_Jose' and `Guyana' to `Georgetown'. + Keep locations compact. Use cities or small islands, not countries + or regions, so that any future time zone changes do not split + locations into different time zones. E.g. prefer `Paris' + to `France', since France has had multiple time zones. + Use traditional English spelling, e.g. prefer `Rome' to `Roma', and + prefer `Athens' to the true name (which uses Greek letters). + The Posix file name restrictions encourage this rule. + Use the most populous among locations in a country's time zone, + e.g. prefer `Shanghai' to `Beijing'. Among locations with + similar populations, pick the best-known location, + e.g. prefer `Rome' to `Milan'. + Use the singular form, e.g. prefer `Canary' to `Canaries'. + Omit common suffixes like `_Islands' and `_City', unless that + would lead to ambiguity. E.g. prefer `Cayman' to + `Cayman_Islands' and `Guatemala' to `Guatemala_City', + but prefer `Mexico_City' to `Mexico' because the country + of Mexico has several time zones. + Use `_' to represent a space. + Omit `.' from abbreviations in names, e.g. prefer `St_Helena' + to `St._Helena'. + +The file `zone.tab' lists the geographical locations used to name +time zone rule files. + +Older versions of this package used a different naming scheme, +and these older names are still supported. +See the file `backwards' for most of these older names +(e.g. `US/Eastern' instead of `America/New_York'). +The other old-fashioned names still supported are +`WET', `CET', `MET', `EET' (see the file `europe'), +and `Factory' (see the file `factory'). + + +----- Time zone abbreviations ----- + +When this package is installed, it generates time zone abbreviations +like `EST' to be compatible with human tradition and POSIX.1. +Here are the general rules used for choosing time zone abbreviations, +in decreasing order of importance: + + Use abbreviations that consist of 3 or more upper-case Ascii letters, + except use "___" for locations while uninhabited. + Posix.1 requires at least 3 characters, and the restriction to + upper-case Ascii letters follows most traditions. + Previous editions of this database also used characters like + ' ' and '?', but these characters have a special meaning to + the shell and cause commands like + set `date` + to have unexpected effects. In theory, the character set could + be !%./@A-Z^_a-z{}, but these tables use only upper-case + Ascii letters (and "___"). + Use abbreviations that are in common use among English-speakers, + e.g. `EST' for Eastern Standard Time in North America. + We assume that applications translate them to other languages + as part of the normal localization process; for example, + a French application might translate `EST' to `HNE'. + For zones whose times are taken from a city's longitude, use the + traditional xMT notation, e.g. `PMT' for Paris Mean Time. + The only name like this in current use is `GMT'. + If there is no common English abbreviation, abbreviate the English + translation of the usual phrase used by native speakers. + If this is not available or is a phrase mentioning the country + (e.g. ``Cape Verde Time''), then: + + When a country has a single or principal time zone region, + append `T' to the country's ISO code, e.g. `CVT' for + Cape Verde Time. For summer time append `ST'; + for double summer time append `DST'; etc. + When a country has multiple time zones, take the first three + letters of an English place name identifying each zone + and then append `T', `ST', etc. as before; + e.g. `VLAST' for VLAdivostok Summer Time. + +Application writers should note that these abbreviations are ambiguous +in practice: e.g. `EST' has a different meaning in Australia than +it does in the United States. In new applications, it's often better +to use numeric UTC offsets like `-0500' instead of time zone +abbreviations like `EST'; this avoids the ambiguity. diff --git a/lib/libc/time/WWW b/lib/libc/time/WWW deleted file mode 100644 index bb5214fc6c9..00000000000 --- a/lib/libc/time/WWW +++ /dev/null @@ -1,71 +0,0 @@ -# '$OpenBSD: WWW,v 1.2 1996/08/19 08:34:47 tholo Exp $ - -# From Paul Eggert <eggert@twinsun.com> (1995-11-03) -# -# The Web has several other sources for time zone and daylight savings data. -# Here are some recent links that may be of interest. -# -# Date and Time Gateway -# http://www.bsdi.com/date -# A text-based source for tables of current time throughout the world. -# Its point-and-click interface accesses a recent version of the tz data. -# -# Local Times Around the World -# http://www.hilink.com.au/times/ -# This text-based system contains links to local time servers -# throughout the world, and though the coverage is limited, -# the live data provide a nice way to check one's tables. -# -# World Time Zones -# http://tycho.usno.navy.mil/tzones.html -# US Naval Observatory data, used as the source for `usno1995'. -# -# Standard Time Zones of the World -# http://www.odci.gov/cia/publications/95fact/802389.gif [54 kB] -# http://www.odci.gov/cia/publications/95fact/802389h.gif [1317 kB] -# A static time zone map, available in both low-resolution and -# high-resolution versions. The quality is good, but the map does not -# indicate summer time, and parts of the data are a few years out of date. -# -# VIBE's World Map -# http://pathfinder.com/vibe/vibeworld -# An active time zone map. You can point to the map and find out what -# time it is at that location. The map and data are not as good as -# other sources. - -############################################################################### - -# From Manavendra Thakur <Manavendra_Thakur@NeXT.COM> (1995-11-06) -# -# To Paul's list of time zone information on the web, I would add the -# following URL: -# http://www.dhl.com/dhl/dhlinfo/1bb.html -# or more simply: -# http://www.dhl.com/ -# -# This is run by DHL (the courier company), and it presents a list of the -# countries served by that company. If you then click on a particular -# country, here's an example of what you'll see (graphics stripped out): -# -# United Kingdom -# -# HOLIDAYS: Jan 1, 2, Apr 14, 17, May 1, 29, Aug 28, Dec 25, 26 -# -# INTERNATIONAL DIALING CODE: +44 -# -# CURRENT LOCAL TIME: 09:41 Monday 6 November 1995 -# -# I find this rather handy, and given that DHL covers 217 countries and -# territories, it's pretty comprehensive coverage. -# -# (I have no idea what system DHL is using to calculate the local time, but -# it's been accurate so far.) - -############################################################################### - - -# From Arthur David Olson <arthur_david_olson@nih.gov> (1996-01-04) -# -# A good source of information about ISO 8601 seems to be -# http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html -# maintained by Markus Kuhn. diff --git a/lib/libc/time/WWW.htm b/lib/libc/time/WWW.htm new file mode 100644 index 00000000000..a17f03ffa45 --- /dev/null +++ b/lib/libc/time/WWW.htm @@ -0,0 +1,100 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<HTML> +<HEAD> +<TITLE>Sources for Time Zone and Daylight Saving Time Data</TITLE> +</HEAD> +<BODY> +<H1>Sources for Time Zone and Daylight Saving Time Data</H1> +<P> +<small> +@(#)WWW.htm 7.11 +$OpenBSD: WWW.htm,v 1.1 1998/01/18 23:24:49 millert Exp $ +</small> +</P> +<H2>Paul Eggert writes:</H2><P> +The public-domain tz database contains code and data +that represent the history of local time +for many representative locations around the globe. +It is updated periodically to reflect changes made by political bodies +to UTC offsets and daylight-saving rules. +This database (often called <samp>zoneinfo</samp>) +is used by several implementations, +including BSD, DJGPP, GNU/Linux, HP-UX, IRIX, Solaris, and UnixWare. +In the tz database's +<A HREF="ftp://elsie.nci.nih.gov/pub/">FTP distribution</A>, +the code is in the file <samp>tzcode<var>C</var>.tar.gz</samp>, +where <samp><var>C</var></samp> is the code's version; +similarly, the data are in <samp>tzdata<var>D</var>.tar.gz</samp>, +where <samp><var>D</var></samp> is the data's version. +<P> +The <A HREF="ftp://ftp.gnu.org/pub/gnu/GETTING.GNU.SOFTWARE">GNU C Library</A> +has an independent, thread-safe implementation of +a time zone file reader. +This library is freely available under the GNU Library General Public License, +and is widely used in GNU/Linux systems. +<P> +The Web has several other sources for time zone and daylight saving time data. +Here are some recent links that may be of interest. +<UL> +<LI><A HREF="http://www.bsdi.com/date">Date and Time Gateway</A> +is a text-based source for tables of current time throughout the world. +Its point-and-click interface accesses a recent version of the tz data. +<LI><A HREF="http://www.worldtime.com/">WORLDTIME: interactive atlas, +time info, public holidays</A> +contains information on local time, sunrise and sunset, +and public holidays in several hundred cities around the world. +<LI><A HREF="http://www.hilink.com.au/times/">Local Times Around the World</A> +is a text-based system containing links to local time servers +throughout the world; though the coverage is limited, +the live data provide a nice way to check one's tables. +<LI><A HREF="http://tycho.usno.navy.mil/tzones.html">World Time Zones</A> +contains US Naval Observatory data, used as the source +for the <samp>usno*</samp> files. +<LI>The US Central Intelligence agency publishes a static +Standard Time Zones of the World map in multiple resolutions. +including +<A HREF="http://www.odci.gov/cia/publications/nsolo/rmap-gif/802483.gif">75 +kB</A>, +<A HREF="http://www.odci.gov/cia/publications/nsolo/rmap-tif/802483.tif">1 +MB</A>, and +<A HREF="http://www.odci.gov/cia/publications/nsolo/rmap-pdf/802483.pdf">3 +MB</A> versions. +The pictorial quality is good, but the map does not indicate summer time, +and parts of the data are a few years out of date. +<LI><A HREF="http://pisolo.cstv.to.cnr.it/toi/uk/toi.html">The +Time of Internet</A> +contains good descriptions of Time Zones and daylight saving time, +with diagrams. +The time zone map is out of date, however. +<LI><A HREF="http://community.bellcore.com/mbr/gmt-explained.html">A Few Facts +Concerning GMT, UT, and the RGO</A> +answers questions like ``What is the difference between GMT and UTC?'' +<LI><A HREF="http://www.energy.ca.gov/energy/daylightsaving.html">Daylight +Saving Time -- Saving Time, Saving Energy</A> +is a history of DST in the US. +<LI><A HREF="http://www.yahoo.com/Science/Weights_and_Measures/Measurements/Time/Daylight_Saving_Time/">Yahoo! - Science:Weights and Measures:Measurements:Time:Daylight Saving Time</A> +is where the famous Internet indexing service Yahoo! collects its time zone +info. +<LI>The <A HREF="http://www.iata.org/">International Air Transport Association</A> +publishes the IATA SSIM, which gives current time zone rules for +all the airports served by commercial aviation. +<LI><A HREF="http://hpiers.obspm.fr/webiers/results/bul/README.html">Bulletins +of IERS</A> contains official publications of the +International Earth Rotation Service, the committee that decides +when leap seconds occur. +</UL> +<P> +-- <A HREF="mailto:eggert@twinsun.com">eggert@twinsun.com</A> +(1997-12-26) +</P> +<H2>Arthur David Olson writes:</H2><P> +A good source of information about ISO 8601 seems to be +<A HREF="http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html">International +Standard Date and Time Notation</A> +maintained by Markus Kuhn. +<P> +-- <A HREF="mailto:arthur_david_olson@nih.gov">arthur_david_olson@nih.gov</A> +(1996-01-04) +</P> +</BODY> +</HTML> diff --git a/lib/libc/time/asctime.c b/lib/libc/time/asctime.c index e31c6148584..690430a94b1 100644 --- a/lib/libc/time/asctime.c +++ b/lib/libc/time/asctime.c @@ -3,12 +3,9 @@ ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). */ -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char elsieid[] = "@(#)asctime.c 7.8"; -#else -static char rcsid[] = "$OpenBSD: asctime.c,v 1.3 1997/01/14 03:16:42 millert Exp $"; -#endif +#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) +static char elsieid[] = "@(#)asctime.c 7.8"; +static char rcsid[] = "$OpenBSD: asctime.c,v 1.4 1998/01/18 23:24:50 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /*LINTLIBRARY*/ diff --git a/lib/libc/time/difftime.c b/lib/libc/time/difftime.c index 6cfddc68ef1..f5e0c9c6bea 100644 --- a/lib/libc/time/difftime.c +++ b/lib/libc/time/difftime.c @@ -3,12 +3,9 @@ ** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). */ -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char elsieid[] = "@(#)difftime.c 7.7"; -#else -static char rcsid[] = "$OpenBSD: difftime.c,v 1.4 1997/01/14 03:16:44 millert Exp $"; -#endif +#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) +static char elsieid[] = "@(#)difftime.c 7.7"; +static char rcsid[] = "$OpenBSD: difftime.c,v 1.5 1998/01/18 23:24:51 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /*LINTLIBRARY*/ diff --git a/lib/libc/time/ialloc.c b/lib/libc/time/ialloc.c index 5590dd13b54..78ce8e6b54f 100644 --- a/lib/libc/time/ialloc.c +++ b/lib/libc/time/ialloc.c @@ -1,9 +1,6 @@ -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char elsieid[] = "@(#)ialloc.c 8.28"; -#else -static char rcsid[] = "$OpenBSD: ialloc.c,v 1.3 1997/01/14 03:16:45 millert Exp $"; -#endif +#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) +static char elsieid[] = "@(#)ialloc.c 8.29"; +static char rcsid[] = "$OpenBSD: ialloc.c,v 1.4 1998/01/18 23:24:52 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /*LINTLIBRARY*/ @@ -12,13 +9,6 @@ static char rcsid[] = "$OpenBSD: ialloc.c,v 1.3 1997/01/14 03:16:45 millert Exp #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)); -void * irealloc P((void * pointer, int size)); -void ifree P((char * pointer)); - char * imalloc(n) const int n; diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 00132616c1e..ee180d11d95 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -3,12 +3,9 @@ ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). */ -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char elsieid[] = "@(#)localtime.c 7.59"; -#else -static char rcsid[] = "$OpenBSD: localtime.c,v 1.10 1997/04/02 03:57:30 deraadt Exp $"; -#endif +#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) +static char elsieid[] = "@(#)localtime.c 7.64"; +static char rcsid[] = "$OpenBSD: localtime.c,v 1.11 1998/01/18 23:24:53 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -62,11 +59,11 @@ static char wildabbr[] = "WILDABBR"; static const char gmt[] = "GMT"; struct ttinfo { /* time type information */ - long tt_gmtoff; /* GMT offset in seconds */ + long tt_gmtoff; /* UTC offset in seconds */ int tt_isdst; /* used to set tm_isdst */ int tt_abbrind; /* abbreviation list index */ int tt_ttisstd; /* TRUE if transition is std time */ - int tt_ttisgmt; /* TRUE if transition is GMT */ + int tt_ttisgmt; /* TRUE if transition is UTC */ }; struct lsinfo { /* leap second information */ @@ -136,6 +133,10 @@ static time_t time2 P((struct tm *tmp, void(*funcp) P((const time_t *, long, struct tm*)), long offset, int * okayp)); +static time_t time2sub P((struct tm *tmp, + void(*funcp) P((const time_t *, + long, struct tm*)), + long offset, int * okayp, int do_norm_secs)); static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp)); static int tmcomp P((const struct tm * atmp, @@ -286,7 +287,7 @@ register struct state * const sp; /* ** Section 4.9.1 of the C standard says that ** "FILENAME_MAX expands to an integral constant expression - ** that is the sie needed for an array of char large enough + ** that is the size needed for an array of char large enough ** to hold the longest file name string that the implementation ** guarantees can be opened." */ @@ -317,27 +318,23 @@ register struct state * const sp; } { struct tzhead * tzhp; - char buf[sizeof *sp + sizeof *tzhp]; + union { + struct tzhead tzhead; + char buf[sizeof *sp + sizeof *tzhp]; + } u; int ttisstdcnt; int ttisgmtcnt; - i = read(fid, buf, sizeof buf); + i = read(fid, u.buf, sizeof u.buf); if (close(fid) != 0) return -1; - p = buf; - p += sizeof tzhp->tzh_reserved; - ttisstdcnt = (int) detzcode(p); - p += 4; - ttisgmtcnt = (int) detzcode(p); - p += 4; - sp->leapcnt = (int) detzcode(p); - p += 4; - sp->timecnt = (int) detzcode(p); - p += 4; - sp->typecnt = (int) detzcode(p); - p += 4; - sp->charcnt = (int) detzcode(p); - p += 4; + ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt); + ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt); + sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt); + sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt); + sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt); + sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt); + p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt; if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || @@ -345,7 +342,7 @@ register struct state * const sp; (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) return -1; - if (i - (p - buf) < sp->timecnt * 4 + /* ats */ + if (i - (p - u.buf) < sp->timecnt * 4 + /* ats */ sp->timecnt + /* types */ sp->typecnt * (4 + 2) + /* ttinfos */ sp->charcnt + /* chars */ @@ -603,8 +600,8 @@ register struct rule * const rulep; } /* -** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the -** year, a rule, and the offset from GMT at the time that rule takes effect, +** Given the Epoch-relative time of January 1, 00:00:00 UTC, in a year, the +** year, a rule, and the offset from UTC at the time that rule takes effect, ** calculate the Epoch-relative time that rule takes effect. */ @@ -690,10 +687,10 @@ const long offset; } /* - ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in + ** "value" is the Epoch-relative time of 00:00:00 UTC on the day in ** question. To get the Epoch-relative time of the specified local ** time on that day, add the transition time and the current offset - ** from GMT. + ** from UTC. */ return value + rulep->r_time + offset; } @@ -727,15 +724,14 @@ const int lastditch; name += stdlen; if (stdlen >= sizeof sp->chars) stdlen = (sizeof sp->chars) - 1; + stdoffset = 0; } else { name = getzname(name); stdlen = name - stdname; if (stdlen < 3) return -1; - } - if (*name == '\0') - return -1; /* was "stdoffset = 0;" */ - else { + if (*name == '\0') + return -1; name = getoffset(name, &stdoffset); if (name == NULL) return -1; @@ -904,7 +900,7 @@ const int lastditch; sp->charcnt = stdlen + 1; if (dstlen != 0) sp->charcnt += dstlen + 1; - if (sp->charcnt > sizeof sp->chars) + if ((size_t) sp->charcnt > sizeof sp->chars) return -1; cp = sp->chars; (void) strncpy(cp, stdname, stdlen); @@ -1081,7 +1077,7 @@ struct tm * const tmp; #ifdef TM_ZONE /* ** Could get fancy here and deliver something such as - ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, + ** "UTC+xxxx" or "UTC-xxxx" if offset is non-zero, ** but this is no time for a treasure hunt. */ if (offset != 0) @@ -1296,11 +1292,12 @@ register const struct tm * const btmp; } static time_t -time2(tmp, funcp, offset, okayp) +time2sub(tmp, funcp, offset, okayp, do_norm_secs) struct tm * const tmp; void (* const funcp) P((const time_t*, long, struct tm*)); const long offset; int * const okayp; +const int do_norm_secs; { register const struct state * sp; register int dir; @@ -1313,6 +1310,11 @@ int * const okayp; *okayp = FALSE; yourtm = *tmp; + if (do_norm_secs) { + if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec, + SECSPERMIN)) + return WRONG; + } if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR)) return WRONG; if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY)) @@ -1449,6 +1451,24 @@ label: } static time_t +time2(tmp, funcp, offset, okayp) +struct tm * const tmp; +void (* const funcp) P((const time_t*, long, struct tm*)); +const long offset; +int * const okayp; +{ + time_t t; + + /* + ** First try without normalization of seconds + ** (in case tm_sec contains a value associated with a leap second). + ** If that fails, try with normalization of seconds. + */ + t = time2sub(tmp, funcp, offset, okayp, FALSE); + return *okayp ? t : time2sub(tmp, funcp, offset, okayp, TRUE); +} + +static time_t time1(tmp, funcp, offset) struct tm * const tmp; void (* const funcp) P((const time_t *, long, struct tm *)); @@ -1575,7 +1595,7 @@ struct tm * const tmp; /* ** IEEE Std 1003.1-1988 (POSIX) legislates that 536457599 -** shall correspond to "Wed Dec 31 23:59:59 GMT 1986", which +** shall correspond to "Wed Dec 31 23:59:59 UTC 1986", which ** is not the case if we are accounting for leap seconds. ** So, we provide the following conversion routines for use ** when exchanging timestamps with POSIX conforming systems. diff --git a/lib/libc/time/private.h b/lib/libc/time/private.h index 98d09dfbdf6..876ce0a1185 100644 --- a/lib/libc/time/private.h +++ b/lib/libc/time/private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: private.h,v 1.6 1997/01/14 03:16:48 millert Exp $ */ +/* $OpenBSD: private.h,v 1.7 1998/01/18 23:24:55 millert Exp $ */ #ifndef PRIVATE_H @@ -32,7 +32,7 @@ #if 0 #ifndef lint #ifndef NOID -static char privatehid[] = "@(#)private.h 7.44"; +static char privatehid[] = "@(#)private.h 7.46"; #endif /* !defined NOID */ #endif /* !defined lint */ #endif @@ -187,6 +187,19 @@ extern int errno; #endif /* +** Private function declarations. +*/ +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)); +void * irealloc P((void * pointer, int size)); +void icfree P((char * pointer)); +void ifree P((char * pointer)); +char * scheck P((const char *string, const char *format)); + + +/* ** Finally, some convenience items. */ diff --git a/lib/libc/time/scheck.c b/lib/libc/time/scheck.c index e7455daf67b..dc71c49df9d 100644 --- a/lib/libc/time/scheck.c +++ b/lib/libc/time/scheck.c @@ -1,22 +1,16 @@ -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char elsieid[] = "@(#)scheck.c 8.13"; -#else -static char rcsid[] = "$OpenBSD: scheck.c,v 1.4 1997/01/14 03:16:49 millert Exp $"; -#endif +#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) +static char elsieid[] = "@(#)scheck.c 8.15"; +static char rcsid[] = "$OpenBSD: scheck.c,v 1.5 1998/01/18 23:24:56 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /*LINTLIBRARY*/ #include "private.h" -extern char * imalloc P((int n)); -extern void ifree P((char * p)); - char * scheck(string, format) const char * const string; -char * const format; +const char * const format; { register char * fbuf; register const char * fp; diff --git a/lib/libc/time/time2posix.3 b/lib/libc/time/time2posix.3 index 2f2f9aafe79..36d4d67b699 100644 --- a/lib/libc/time/time2posix.3 +++ b/lib/libc/time/time2posix.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: time2posix.3,v 1.4 1997/01/14 03:16:50 millert Exp $ +.\" $OpenBSD: time2posix.3,v 1.5 1998/01/18 23:24:58 millert Exp $ .TH TIME2POSIX 3 .SH NAME time2posix, posix2time \- convert seconds since the Epoch @@ -12,14 +12,12 @@ time2posix, posix2time \- convert seconds since the Epoch .PP .B time_t posix2time(t) .B time_t t -.PP -.B cc ... -lz .fi .SH DESCRIPTION IEEE Standard 1003.1 (POSIX) legislates that a time_t value of -536457599 shall correspond to "Wed Dec 31 23:59:59 GMT 1986." +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, @@ -117,6 +115,6 @@ difftime(3), localtime(3), mktime(3), time(3) -.\" @(#)time2posix.3 7.5 +.\" @(#)time2posix.3 7.7 .\" This file is in the public domain, so clarified as of .\" 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). diff --git a/lib/libc/time/tzfile.5 b/lib/libc/time/tzfile.5 index bafaf75f370..10818e881a6 100644 --- a/lib/libc/time/tzfile.5 +++ b/lib/libc/time/tzfile.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tzfile.5,v 1.4 1997/01/14 03:16:51 millert Exp $ +.\" $OpenBSD: tzfile.5,v 1.5 1998/01/18 23:24:59 millert Exp $ .TH TZFILE 5 .SH NAME tzfile \- time zone information @@ -8,7 +8,9 @@ tzfile \- time zone information .SH DESCRIPTION The time zone information files used by .IR tzset (3) -begin with bytes reserved for future use, +begin with the magic characters "TZif" to identify then as +time zone information files, +followed by bytes reserved for future use, followed by six four-byte values of type .BR long , written in a ``standard'' byte order @@ -17,7 +19,7 @@ These values are, in order: .TP .I tzh_ttisgmtcnt -The number of GMT/local indicators stored in the file. +The number of UTC/local indicators stored in the file. .TP .I tzh_ttisstdcnt The number of standard/wall indicators stored in the file. @@ -78,7 +80,7 @@ and a one-byte value for .IR tt_abbrind . In each structure, .I tt_gmtoff -gives the number of seconds to be added to GMT, +gives the number of seconds to be added to UTC, .I tt_isdst tells whether .I tm_isdst @@ -113,9 +115,9 @@ time zone environment variables. .PP Finally there are .I tzh_ttisgmtcnt -GMT/local indicators, each stored as a one-byte value; +UTC/local indicators, each stored as a one-byte value; they tell whether the transition times associated with local time types -were specified as GMT or local time, +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. .PP @@ -132,6 +134,6 @@ is zero or the time argument is less than the first transition time recorded in the file. .SH SEE ALSO ctime(3) -.\" @(#)tzfile.5 7.5 +.\" @(#)tzfile.5 7.10 .\" This file is in the public domain, so clarified as of .\" 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). diff --git a/lib/libc/time/tzfile.h b/lib/libc/time/tzfile.h index 82e6852936e..40331f46bc6 100644 --- a/lib/libc/time/tzfile.h +++ b/lib/libc/time/tzfile.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tzfile.h,v 1.4 1997/01/14 03:16:52 millert Exp $ */ +/* $OpenBSD: tzfile.h,v 1.5 1998/01/18 23:25:00 millert Exp $ */ #ifndef TZFILE_H @@ -24,7 +24,7 @@ #if 0 #ifndef lint #ifndef NOID -static char tzfilehid[] = "@(#)tzfile.h 7.9"; +static char tzfilehid[] = "@(#)tzfile.h 7.14"; #endif /* !defined NOID */ #endif /* !defined lint */ #endif @@ -49,8 +49,11 @@ static char tzfilehid[] = "@(#)tzfile.h 7.9"; ** Each file begins with. . . */ +#define TZ_MAGIC "TZif" + struct tzhead { - char tzh_reserved[20]; /* reserved for future use */ + char tzh_magic[4]; /* TZ_MAGIC */ + char tzh_reserved[16]; /* reserved for future use */ char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ char tzh_leapcnt[4]; /* coded number of leap seconds */ @@ -65,7 +68,7 @@ struct tzhead { ** 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 (char [4]) coded UTC 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 @@ -78,7 +81,7 @@ struct tzhead { ** if absent, transition times are ** assumed to be wall clock time ** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition -** time is GMT, if FALSE, +** time is UTC, if FALSE, ** transition time is local time ** if absent, transition times are ** assumed to be local time diff --git a/lib/libc/time/tzset.3 b/lib/libc/time/tzset.3 index 9ff0575ecf4..d60aa1cee05 100644 --- a/lib/libc/time/tzset.3 +++ b/lib/libc/time/tzset.3 @@ -1,12 +1,10 @@ -.\" $OpenBSD: tzset.3,v 1.5 1997/01/14 03:16:54 millert Exp $ +.\" $OpenBSD: tzset.3,v 1.6 1998/01/18 23:25:01 millert Exp $ .TH TZSET 3 .SH NAME tzset \- initialize time conversion information .SH SYNOPSIS .nf .B void tzset() -.PP -.B cc ... -lz .fi .SH DESCRIPTION .I Tzset @@ -235,4 +233,4 @@ ctime(3), strftime(3), time(3), tzfile(5) -.\" @(#)newtzset.3 7.4 +.\" @(#)newtzset.3 7.5 diff --git a/lib/libc/time/zdump.c b/lib/libc/time/zdump.c index bf71ad5809e..5addc2d21c1 100644 --- a/lib/libc/time/zdump.c +++ b/lib/libc/time/zdump.c @@ -1,9 +1,6 @@ -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char elsieid[] = "@(#)zdump.c 7.24"; -#else -static char rcsid[] = "$OpenBSD: zdump.c,v 1.5 1997/01/21 04:52:45 millert Exp $"; -#endif +#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) +static char elsieid[] = "@(#)zdump.c 7.27"; +static char rcsid[] = "$OpenBSD: zdump.c,v 1.6 1998/01/18 23:25:02 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -113,19 +110,28 @@ static char rcsid[] = "$OpenBSD: zdump.c,v 1.5 1997/01/21 04:52:45 millert Exp $ #define TZ_DOMAIN "tz" #endif /* !defined TZ_DOMAIN */ +#ifndef P +#ifdef __STDC__ +#define P(x) x +#endif /* defined __STDC__ */ +#ifndef __STDC__ +#define P(x) () +#endif /* !defined __STDC__ */ +#endif /* !defined P */ + extern char ** environ; -extern int getopt(); +extern int getopt P((int argc, char * const argv[], + const char * options)); extern char * optarg; extern int optind; -extern time_t time(); extern char * tzname[2]; -static char * abbr(); -static long delta(); -static time_t hunt(); -static int longest; +static char * abbr P((struct tm * tmp)); +static long delta P((struct tm * newp, struct tm * oldp)); +static time_t hunt P((char * name, time_t lot, time_t hit)); +static size_t longest; static char * progname; -static void show(); +static void show P((char * zone, time_t t, int v)); int main(argc, argv) @@ -161,7 +167,7 @@ char * argv[]; if (c == 'v') vflag = 1; else cutoff = optarg; - if (c != EOF || + if (c != -1 || (optind == argc - 1 && strcmp(argv[optind], "=") == 0)) { (void) fprintf(stderr, _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"), @@ -193,8 +199,7 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"), fakeenv = (char **) malloc((size_t) ((i + 2) * sizeof *fakeenv)); if (fakeenv == NULL || - (fakeenv[0] = (char *) malloc((size_t) (longest + - 4))) == NULL) { + (fakeenv[0] = (char *) malloc(longest + 4)) == NULL) { (void) perror(progname); (void) exit(EXIT_FAILURE); } @@ -210,9 +215,10 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"), static char buf[MAX_STRING_LENGTH]; (void) strcpy(&fakeenv[0][3], argv[i]); - show(argv[i], now, FALSE); - if (!vflag) + if (!vflag) { + show(argv[i], now, FALSE); continue; + } /* ** Get lowest value of t. */ @@ -281,7 +287,6 @@ time_t hit; lotm = *localtime(&lot); (void) strncpy(loab, abbr(&lotm), (sizeof loab) - 1); - loab[(sizeof loab) - 1] = '\0'; while ((hit - lot) >= 2) { t = lot / 2 + hit / 2; if (t <= lot) @@ -328,8 +333,6 @@ struct tm * oldp; return result; } -extern struct tm * localtime(); - static void show(zone, t, v) char * zone; @@ -338,9 +341,9 @@ int v; { struct tm * tmp; - (void) printf("%-*s ", longest, zone); + (void) printf("%-*s ", (int) longest, zone); if (v) - (void) printf("%.24s GMT = ", asctime(gmtime(&t))); + (void) printf("%.24s UTC = ", asctime(gmtime(&t))); tmp = localtime(&t); (void) printf("%.24s", asctime(tmp)); if (*abbr(tmp) != '\0') diff --git a/lib/libc/time/zic.8 b/lib/libc/time/zic.8 index 004ff093e68..7f511211508 100644 --- a/lib/libc/time/zic.8 +++ b/lib/libc/time/zic.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: zic.8,v 1.4 1997/01/14 03:16:57 millert Exp $ +.\" $OpenBSD: zic.8,v 1.5 1998/01/18 23:25:03 millert Exp $ .TH ZIC 8 .SH NAME zic \- time zone compiler @@ -273,13 +273,13 @@ This is the name used in creating the time conversion information file for the zone. .TP .B GMTOFF -The amount of time to add to GMT to get standard time in this zone. +The amount of time to add to UTC to get standard time in this zone. This field has the same format as the .B AT and .B SAVE fields of rule lines; -begin the field with a minus sign if time must be subtracted from GMT. +begin the field with a minus sign if time must be subtracted from UTC. .TP .B RULES/SAVE The name of the rule(s) that apply in the time zone or, @@ -300,10 +300,10 @@ a slash (/) separates standard and daylight abbreviations. .TP .B UNTIL -The time at which the GMT offset or the rule(s) change for a location. +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 GMT offset +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 @@ -393,7 +393,7 @@ The field should be (an abbreviation of) .q Stationary -if the leap second time given by the other fields should be interpreted as GMT +if the leap second time given by the other fields should be interpreted as UTC or (an abbreviation of) .q Rolling @@ -409,4 +409,4 @@ the earliest transition time recorded in the compiled file is correct. /usr/share/zoneinfo standard directory used for created files .SH "SEE ALSO" ctime(3), tzfile(5), zdump(8) -.\" @(#)zic.8 7.14 +.\" @(#)zic.8 7.17 diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c index d50d1144b08..adfb3a1c8fb 100644 --- a/lib/libc/time/zic.c +++ b/lib/libc/time/zic.c @@ -1,9 +1,6 @@ -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char elsieid[] = "@(#)zic.c 7.80"; -#else -static char rcsid[] = "$OpenBSD: zic.c,v 1.6 1997/01/15 23:40:55 millert Exp $"; -#endif +#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) +static char elsieid[] = "@(#)zic.c 7.93"; +static char rcsid[] = "$OpenBSD: zic.c,v 1.7 1998/01/18 23:25:04 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include "private.h" @@ -81,15 +78,9 @@ struct zone { extern int getopt P((int argc, char * const argv[], const char * options)); -extern char * icatalloc P((char * old, const char * new)); -extern char * icpyalloc P((const char * string)); -extern void ifree P((char * p)); -extern char * imalloc P((int n)); -extern void * irealloc P((void * old, int n)); extern int link P((const char * fromname, const char * toname)); extern char * optarg; extern int optind; -extern char * scheck P((const char * string, const char * format)); static void addtt P((time_t starttime, int type)); static int addtype P((long gmtoff, const char * abbr, int isdst, @@ -149,8 +140,10 @@ static int leapcnt; static int linenum; static time_t max_time; static int max_year; +static int max_year_representable; static time_t min_time; static int min_year; +static int min_year_representable; static int noise; static const char * rfilename; static int rlinenum; @@ -438,7 +431,7 @@ const char * const string; cp = ecpyalloc("warning: "); cp = ecatalloc(cp, string); - error(string); + error(cp); ifree(cp); --errors; } @@ -657,6 +650,8 @@ setboundaries P((void)) } min_year = TM_YEAR_BASE + gmtime(&min_time)->tm_year; max_year = TM_YEAR_BASE + gmtime(&max_time)->tm_year; + min_year_representable = min_year; + max_year_representable = max_year; } static int @@ -1024,7 +1019,7 @@ const int iscont; } z.z_filename = filename; z.z_linenum = linenum; - z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid GMT offset"), TRUE); + z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid UTC offset"), TRUE); if ((cp = strchr(fields[i_format], '%')) != 0) { if (*++cp != 's' || strchr(cp, '%') != 0) { error(_("invalid abbreviation format")); @@ -1226,6 +1221,7 @@ const char * const timep; rp->r_todisstd = FALSE; rp->r_todisgmt = FALSE; *ep = '\0'; + break; case 'g': /* Greenwich */ case 'u': /* Universal */ case 'z': /* Zulu */ @@ -1257,6 +1253,11 @@ const char * const timep; } else if (sscanf(cp, scheck(cp, "%d"), &rp->r_loyear) != 1) { error(_("invalid starting year")); return; + } else if (noise) { + if (rp->r_loyear < min_year_representable) + warning(_("starting year too low to be represented")); + else if (rp->r_loyear > max_year_representable) + warning(_("starting year too high to be represented")); } cp = hiyearp; if ((lp = byword(cp, end_years)) != NULL) switch ((int) lp->l_value) { @@ -1277,6 +1278,11 @@ const char * const timep; } else if (sscanf(cp, scheck(cp, "%d"), &rp->r_hiyear) != 1) { error(_("invalid ending year")); return; + } else if (noise) { + if (rp->r_loyear < min_year_representable) + warning(_("starting year too low to be represented")); + else if (rp->r_loyear > max_year_representable) + warning(_("starting year too high to be represented")); } if (rp->r_loyear > rp->r_hiyear) { error(_("starting year greater than ending year")); @@ -1291,6 +1297,8 @@ const char * const timep; } rp->r_yrtype = ecpyalloc(typep); } + if (rp->r_loyear < min_year && rp->r_loyear > 0) + min_year = rp->r_loyear; /* ** Day work. ** Accept things such as: @@ -1399,8 +1407,10 @@ const char * const name; toi = 0; fromi = 0; + while (fromi < timecnt && attypes[fromi].at < min_time) + ++fromi; if (isdsts[0] == 0) - while (attypes[fromi].type == 0) + while (fromi < timecnt && attypes[fromi].type == 0) ++fromi; /* handled by default rule */ for ( ; fromi < timecnt; ++fromi) { if (toi != 0 @@ -1455,7 +1465,9 @@ const char * const name; convert(eitol(timecnt), tzh.tzh_timecnt); convert(eitol(typecnt), tzh.tzh_typecnt); convert(eitol(charcnt), tzh.tzh_charcnt); + (void) strncpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic); #define DO(field) (void) fwrite((void *) tzh.field, (size_t) sizeof tzh.field, (size_t) 1, fp) + DO(tzh_magic); DO(tzh_reserved); DO(tzh_ttisgmtcnt); DO(tzh_ttisstdcnt); @@ -1619,7 +1631,7 @@ const int zonecount; INITIALIZE(ktime); if (useuntil) { /* - ** Turn untiltime into GMT + ** Turn untiltime into UTC ** assuming the current gmtoff and ** stdoff values. */ @@ -1725,8 +1737,22 @@ error(_("can't determine time zone abbreviation to use just after until time")); static void addtt(starttime, type) const time_t starttime; -const int type; +int type; { + if (starttime <= min_time || + (timecnt == 1 && attypes[0].at < min_time)) { + gmtoffs[0] = gmtoffs[type]; + isdsts[0] = isdsts[type]; + ttisstds[0] = ttisstds[type]; + ttisgmts[0] = ttisgmts[type]; + if (abbrinds[type] != 0) + (void) strcpy(chars, &chars[abbrinds[type]]); + abbrinds[0] = 0; + charcnt = strlen(chars) + 1; + typecnt = 1; + timecnt = 0; + type = 0; + } if (timecnt >= TZ_MAX_TIMES) { error(_("too many transitions?!")); (void) exit(EXIT_FAILURE); @@ -1921,10 +1947,11 @@ register const struct lookup * const table; */ foundlp = NULL; for (lp = table; lp->l_word != NULL; ++lp) - if (itsabbr(word, lp->l_word)) + if (itsabbr(word, lp->l_word)) { if (foundlp == NULL) foundlp = lp; else return NULL; /* multiple inexact matches */ + } return foundlp; } @@ -2128,15 +2155,20 @@ char * const argname; if (!itsdir(name)) { /* ** It doesn't seem to exist, so we try to create it. + ** Creation may fail because of the directory being + ** created by some other multiprocessor, so we get + ** to do extra checking. */ - if (mkdir(name, 0755) != 0) { + if (mkdir(name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) != 0) { const char *e = strerror(errno); - (void) fprintf(stderr, - _("%s: Can't create directory %s: %s\n"), - progname, name, e); - ifree(name); - return -1; + if (errno != EEXIST || !itsdir(name)) { + (void) fprintf(stderr, +_("%s: Can't create directory %s: %s\n"), + progname, name, e); + ifree(name); + return -1; + } } } *cp = '/'; |