home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume8 / pd-localtime / part01 next >
Encoding:
Internet Message Format  |  1987-03-01  |  32.8 KB

  1. Path: mirror!adelie!necntc!husc6!seismo!munnari!sources-request
  2. From: sources-request@munnari.oz
  3. Newsgroups: mod.sources
  4. Subject: v08i085:  Public Domain (Table Driven) ``localtime'', Part01/03
  5. Message-ID: <1435@munnari.oz>
  6. Date: 28 Feb 87 11:49:08 GMT
  7. Sender: kre@munnari.oz
  8. Lines: 1058
  9. Approved: kre@munnari.oz.au
  10.  
  11. Submitted by: Arthur David Olson <ado@elsie.UUCP>
  12. Mod.sources: Volume 8, Issue 85
  13. Archive-name: pd-localtime/Part01
  14.  
  15.     [ This is the latest release of the table (file) driven
  16.       ctime(3), originally released as "settz" in Vol 4 issue 14.
  17.  
  18.       Normally, I don't post mod.sources articles that originate
  19.       outside Australia, but this is something of a special case,
  20.       in that I've been (slightly) involved in the development.
  21.  
  22.       This posting is important in North America (or just the USA?)
  23.       now, because of forthcoming changes to the Daylight Saving
  24.       Rules.  I suggest that source licensees install these library
  25.       functions in libc as soon as possible, then recompile everything
  26.       that uses localtime() or ctime().  You should never need to go
  27.       through that again!  (Later versions of this code will likely be
  28.       available, but they should merely add functionality for new
  29.       programs, old ones compiled with this release should continue
  30.       to work).
  31.  
  32.       If you have only a binary licence, you should insist that your
  33.       vendor install this code into its standard release ASAP, and
  34.       send you an update distribution.  In the meantime, you could
  35.       install this in your libc.a, and have any sources that you
  36.       do compile show the time correctly.  This is probably not
  37.       a real good idea though.
  38.  
  39.       It is possible to install this code in a separate library (in
  40.       fact, that's how it is distributed - as the details of exactly
  41.       how to update libc.a are too variable to include here), and
  42.       then explicitly reference it on all compilations that need
  43.       any of the time functions.
  44.  
  45.       There are a number of compilation options, described in the
  46.       Makefile (be sure to read that before compiling).  I suggest
  47.       that you define KRE_COMPAT (yes, that's me..) and STD_INSPIRED.
  48.       If you want compatibility with some of the less broken parts of
  49.       the time implementations in Sys V, or BSD releases, you can also
  50.       define USG_COMPAT or BSD_COMPAT respectively.  Finally, TZA_COMPAT
  51.       will give Vol 4 "settz" release timezone name scheme compatability.
  52.       You get tzname[] regardless of the setting of USG_COMPAT.  Having
  53.       it included this way is an arguable benefit, it might remove itself
  54.       into the USG_COMPAT version in later releases.
  55.  
  56.       One program that will cause some problems in compiling, is
  57.       date(1).  The date patches posted in Vol 6 Issue 12 should help
  58.       here (you will need TZA_COMPAT, and BSD_COMPAT on BSD systems).
  59.       A new (public domain) version of date(1) is expected soon.
  60.       It will use the STD_INSPIRED functions included here, so if
  61.       you plan on using that when it appears, define STD_INSPIRED now.
  62.  
  63.       Problems: With BSD_COMPAT ctime.c will become an empty file.
  64.       Without STD_INSPIRED timemk.c will become an empty file.
  65.       In general this is OK (the compiler doesn't mind), however
  66.       some versions of ranlib(1) simply can't deal with this.
  67.       Defining STD_INSPIRED will will fix timemk.c.  ctime.c on
  68.       BSD systems is harder.  If you are going to install this in
  69.       libc.a, then best if to remove the #ifndef/#endif that surround
  70.       ctime.c, and the duplicate version of ctime (in #ifdef BSD_COMPAT)
  71.       in localtime.c.  The problem that is supposed to circumvent
  72.       will not occur in that case.  If you want to keep these functions
  73.       in libz.a then easiest is probably to add some nonsense declaration
  74.       to ctime.c (outside the ifdefs) so that the file is not empty.
  75.  
  76.       Finally, you should be aware that this code is designed to work
  77.       correctly (without changes) regardless of whether time_t is a
  78.       signed or unsigned type, and however many bits it contains
  79.       (withing reason), provided only that it is a standard arithmetic
  80.       type (not an array or struct).  The compiled timezone files
  81.       produced are host independant (except unfortunately assume that
  82.       time_t's are 4 bytes long) - the same compiled files can be used
  83.       from a SUN or a Vax (assuming some remote file system to access
  84.       them).
  85.  
  86.       Vendors: you are expected to provide at least binaries of zic
  87.       and zdump, as well as the library functions of course, and the
  88.       sources of the time data files in any release of this code.
  89.       Providing sources of all this would be an entirely reasonable
  90.       thing to do.
  91.  
  92.       So ends what is probably the longest moderator's note in the
  93.       history of mod.sources.            ... kre ]
  94.  
  95.  
  96. echo x - "Theory" 2>&1
  97. sed "s/^X//" >"Theory" <<'!The!End!'
  98. X@(#)Theory    3.1
  99. X
  100. XThese time and date functions are much like the System V Release 2.0 (SVR2)
  101. Xtime and date functions; there are a few additions and changes to extend
  102. Xthe usefulness of the SVR2 functions:
  103. X
  104. X*    In SVR2, time display in a process is controlled by the environment
  105. X    variable TZ, which "must be a three-letter time zone name, followed
  106. X    by a number representing the difference between local time and
  107. X    Greenwich Mean Time in hours, followed by an optional three-letter
  108. X    name for a daylight time zone;" when the optional daylight time zone is
  109. X    present, "standard U.S.A. Daylight Savings Time conversion is applied."
  110. X    This means that SVR2 can't deal with other (for example, Australian) 
  111. X    daylight savings time rules, or situations where more than two
  112. X    time zone abbreviations are used in an area.
  113. X
  114. X*    In SVR2, time conversion information is compiled into each program
  115. X    that does time conversion.  This means that when time conversion
  116. X    rules change (as in the United States in 1987), all programs that
  117. X    do time conversion must be recompiled to ensure proper results.
  118. X
  119. X*    In SVR2, time conversion fails for near-minimum or near-maximum
  120. X    time_t values when doing conversions for places that don't use GMT.
  121. X
  122. X*    In SVR2, there's no tamper-proof way for a process to learn the
  123. X    system's best idea of local wall clock.  (This is important for 
  124. X    applications that an administrator wants used only at certain times--
  125. X    without regard to whether the user has fiddled the "TZ" environment
  126. X    variable.  While an administrator can "do everything in GMT" to get
  127. X    around the problem, doing so is inconvenient and precludes handling
  128. X    daylight savings time shifts--as might be required to limit phone
  129. X    calls to off-peak hours.)
  130. X
  131. XThese are the changes that have been made to the SVR2 functions:
  132. X
  133. X*    The "TZ" environment variable is used in generating the name of a file
  134. X    from which time zone information is read; "TZ" is no longer constrained
  135. X    to be a three-letter time zone name followed by a number of hours and
  136. X    an optional three-letter daylight time zone name.  The daylight saving
  137. X    time rules to be used for a particular time zone are encoded in the
  138. X    time zone file; the format of the file allows U.S., Australian, and
  139. X    other rules to be encoded, and allows for situations where more than
  140. X    two time zone abbreviations are used.
  141. X
  142. X    It was recognized that allowing the "TZ" environment variable to
  143. X    take on values such as "US/Eastern" might cause "old" programs
  144. X    (that expect "TZ" to have a certain form) to operate incorrectly;
  145. X    consideration was given to using some other environment variable
  146. X    (for example, "TIMEZONE") to hold the string used to generate the
  147. X    time zone information file name.  In the end, however, it was decided
  148. X    to continue using "TZ":  it is widely used for time zone purposes;
  149. X    separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance;
  150. X    and systems where "new" forms of "TZ" might cause problems can simply
  151. X    give time zone files names such as "EST5EDT" which can be used both by
  152. X    "new" programs (as file names) and "old" programs (as zone names and
  153. X    offsets).
  154. X
  155. X*    To handle places where more than two time zone abbreviations are used,
  156. X    the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst]
  157. X    (where "tmp" is the value the function returns) to the time zone
  158. X    abbreviation to be used.  This differs from SVR2, where the elements
  159. X    of tzname are only changed as a result of calls to tzset.
  160. X
  161. X*    Since the "TZ" environment variable can now be used to control time
  162. X    conversion, the "daylight" and "timezone" variables are no longer
  163. X    needed or supported.  (You can use a compile-time option to cause
  164. X    these variables to be defined and to be set by "tzset"; however, their
  165. X    values will not be used by "localtime.")
  166. X
  167. X*    The "localtime" function has been set up to deliver correct results
  168. X    for near-minimum or near-maximum time_t values.  (A comment in the
  169. X    source code tells how to get compatibly wrong results).
  170. X
  171. X*    A function "tzsetwall" has been added to arrange for the system's
  172. X    best approximation to local wall clock time to be delivered by
  173. X    subsequent calls to "localtime."  Source code for portable
  174. X    applications that "must" run on local wall clock time should call
  175. X    "tzsetwall();" if such code is moved to "old" systems that don't provide
  176. X    tzsetwall, you won't be able to generate an executable program.
  177. X    (These time zone functions also arrange for local wall clock time to be
  178. X    used if tzset is called--directly or indirectly--and there's no "TZ"
  179. X    environment variable; portable applications should not, however, rely
  180. X    on this behavior since it's not the way SVR2 systems behave.)
  181. X
  182. XPoints of interest to folks with Version 7 or BSD systems:
  183. X
  184. X*    The BSD "timezone" function is not present in this package;
  185. X    it's impossible to reliably map timezone's arguments (a "minutes west
  186. X    of GMT" value and a "daylight saving time in effect" flag) to a
  187. X    time zone abbreviation, and we refuse to guess. 
  188. X    Programs that in the past used the timezone function may now examine
  189. X    tzname[localtime(&clock)->tm_isdst] to learn the correct time
  190. X    zone abbreviation to use.  Alternatively, use localtime(&clock)->tm_zone
  191. X    if this has been enabled.
  192. X
  193. X*    The BSD gettimeofday function is not used in this package;
  194. X    this lets users control the time zone used in doing time conversions.
  195. X    Users who don't try to control things (that is, users who do not set
  196. X    the environment variable TZ) get the time conversion specified in the
  197. X    file "/etc/zoneinfo/localtime"; see the time zone compiler writeup for
  198. X    information on how to initialize this file.
  199. X
  200. X*    The BSD "dysize" function is only included if the preprocessor symbol
  201. X    BSD_COMPAT is defined.  For a year y, the BSD code returns the value
  202. X       ((y % 4) == 0) : 366 : 365
  203. X    while this code returns the value
  204. X       (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) ? 366 : 365
  205. X    There's a comment in the code telling how to get the BSD value.
  206. X
  207. XThe functions that are conditionally compiled if STD_INSPIRED is defined should,
  208. Xat this point, be looked on primarily as food for thought.  They are not in
  209. Xany sense "standard compatible"--some are not, in fact, specified in *any*
  210. Xstandard.  They do, however, represent responses of various authors to
  211. Xstandardization proposals.
  212. X
  213. XOther time conversion proposals, in particular the one developed by folks at
  214. XHewlett Packard, offer a wider selection of functions that provide capabilities
  215. Xbeyond those provided here.  The absence of such functions from this package
  216. Xis not meant to discourage the development, standardization, or use of such
  217. Xfunctions.  Rather, their absence reflects the decision to make this package
  218. Xclose to SVR2 (with the exceptions outlined above) to ensure its broad
  219. Xacceptability.  If more powerful time conversion functions can be standardized,
  220. Xso much the better.
  221. X
  222. XIt's probably not wise to standardize everything in this package.
  223. XWhile the command
  224. X    nroff -man newctime.3
  225. Xproduces a document that describes this package, the command
  226. X    nroff -man -rX3J11 newctime.3
  227. Xproduces a document that describes the "standardizable" parts.
  228. !The!End!
  229.  
  230. echo x - "README" 2>&1
  231. sed "s/^X//" >"README" <<'!The!End!'
  232. X@(#)README    3.1
  233. X
  234. XPlease send comments or information to
  235. X    seismo!elsie!tz
  236. Xfor forwarding to folks interested in time zone matters.
  237. X
  238. XBe sure to read the comments in "Makefile" and make any changes
  239. Xneeded to make things right for your system.
  240. X
  241. XThis version of the time zone software uses a new format
  242. X(based on the work of Guy Harris, a.k.a guy@sun.UUCP)
  243. Xfor the time zone information files.  They are now stored by default in a
  244. Xdirectory named "/etc/zoneinfo" rather than "/etc/tzdir" or "/etc/timezones"
  245. Xas before.  If you've already compiled programs with older time zone software,
  246. Xjust leave the "/etc/tzdir" and/or "/etc/timezones" files around until you
  247. Xhave a chance to recompile.
  248. X
  249. XFor better compatability with other versions of time conversion functions,
  250. Xthe time zone abbreviation to be used with localtime's return value is now
  251. Xpointed to by one of the two elements of the (char *) array tzname, rather
  252. Xthan by the (char *) tz_abbr.  If you have code that uses tz_abbr, add a
  253. X    -DTZA_COMPAT
  254. Xto the end of the
  255. X    CFLAGS=
  256. Xline in "Makefile".
  257. X
  258. XTo use the new functions, use a "-lz" option when compiling or linking.
  259. X
  260. XHistorical local time information has been included here not because it
  261. Xis particularly useful, but rather to:
  262. X
  263. X*    give an idea of the variety of local time rules that have
  264. X    existed in the past and thus an idea of the variety that may be
  265. X    expected in the future;
  266. X
  267. X*    provide a test of the generality of the local time rule description
  268. X    system.
  269. X
  270. XThe information in the time zone data files is by no means authoritative;
  271. Xif you know that the rules are different from those in a file, by all means
  272. Xfeel free to change file (and please send the changed version to seismo!elsie!tz
  273. Xfor use in the future).  Europeans take note!
  274. !The!End!
  275.  
  276. echo x - "Makefile" 2>&1
  277. sed "s/^X//" >"Makefile" <<'!The!End!'
  278. X# @(#)Makefile    3.1
  279. X
  280. X# If you want something other than Eastern United States time used on your
  281. X# system, change the line below (after finding the zone you want in the
  282. X# time zone files, or adding it to a time zone file).
  283. X# Alternately, if you discover you've got the wrong time zone, you can just
  284. X#    zic -l rightzone
  285. X
  286. XLOCALTIME=    US/Eastern
  287. X
  288. X# Use an absolute path name for TZDIR unless you're just testing the software.
  289. X
  290. XTZDIR=        /etc/zoneinfo
  291. X
  292. X# You may want to change this define if you're just testing the software.
  293. X# Alternatively, you can put these functions in /lib/libc.a, removing
  294. X# the old "ctime.o" (and "timezone.o" on a BSD system).  This is the
  295. X# ideal solution if you are able.  Build libz.a, extract the files, and
  296. X# then add them to libc.a.
  297. X
  298. XTZLIB=        /usr/lib/libz.a
  299. X
  300. X#
  301. X# If you're running on a System V-style system and don't want lint grief,
  302. X# add
  303. X#    -DUSG
  304. X# to the end of the "CFLAGS=" line.
  305. X#
  306. X# If you're running on a system where "strchr" is known as "index",
  307. X# (for example, a 4.[012]BSD system), add
  308. X#    -Dstrchr=index
  309. X# to the end of the "CFLAGS=" line.
  310. X#
  311. X# If you want to use System V compatibility code, add
  312. X#    -DUSG_COMPAT
  313. X# to the end of the "CFLAGS=" line.
  314. X#
  315. X# If you want BSD compatibility code, add
  316. X#    -DBSD_COMPAT
  317. X# to the end of the "CFLAGS=" line.
  318. X#
  319. X# If you've used older versions of this software and want "tz_abbr"
  320. X# compatibility code, add
  321. X#    -DTZA_COMPAT
  322. X# to the end of the "CFLAGS=" line.
  323. X#
  324. X# If you'd like to use Robert Elz's additions to the "struct tm" structure,
  325. X# add a
  326. X#    -DKRE_COMPAT
  327. X# to the end of the "CFLAGS=" line, and add the structure elements
  328. X#    long    tm_gmtoff;
  329. X#    char *    tm_zone;
  330. X# to the END of the "struct tm" structure defined in "/usr/include/time.h".
  331. X#
  332. X# If you want code inspired by certain emerging standards, add
  333. X#    -DSTD_INSPIRED
  334. X# to the end of the "CFLAGS=" line.
  335. X#
  336. X# If you want Source Code Control System ID's left out of object modules, add
  337. X#    -DNOID
  338. X# to the end of the "CFLAGS=" line.
  339. X#
  340. X# If you'll never want to handle solar-time-based time zones, add
  341. X#    -DNOSOLAR
  342. X# to the end of the "CFLAGS=" line
  343. X# (and remove solar87 from the DATA= line below).
  344. X#
  345. X
  346. XCFLAGS=
  347. X
  348. X# LINTFLAGS is set for 4.[123]BSD systems.
  349. X# If you're using System V, you'll want to comment out the "LINTFLAGS=" line.
  350. X
  351. XLINTFLAGS=    -phbaaxc
  352. X
  353. X# BUNDLE was set to "bundle" in the original, "shar" is more universal
  354. X
  355. XBUNDLE=        shar
  356. X
  357. X################################################################################
  358. X
  359. XCC=        cc -DTZDIR=\"$(TZDIR)\"
  360. X
  361. XTZCSRCS=    zic.c localtime.c asctime.c scheck.c ialloc.c mkdir.c
  362. XTZCOBJS=    zic.o localtime.o asctime.o scheck.o ialloc.o mkdir.o
  363. XTZDSRCS=    zdump.c localtime.c asctime.c ialloc.c
  364. XTZDOBJS=    zdump.o localtime.o asctime.o ialloc.o
  365. XLIBSRCS=    localtime.c asctime.c ctime.c dysize.c timemk.c
  366. XLIBOBJS=    localtime.o asctime.o ctime.o dysize.o timemk.o
  367. XDOCS=        Theory README Makefile newctime.3 tzfile.5 zic.8 zdump.8
  368. XSOURCES=    tzfile.h zic.c zdump.c \
  369. X        localtime.c asctime.c ctime.c dysize.c timemk.c \
  370. X        scheck.c ialloc.c mkdir.c
  371. XDATA=        asia australasia europe etcetera northamerica \
  372. X        pacificnew systemv solar87
  373. XENCHILADA=    $(DOCS) $(SOURCES) $(DATA)
  374. X
  375. Xall:        REDID_BINARIES zdump $(TZLIB)
  376. X
  377. XREDID_BINARIES:    zic $(DATA)
  378. X        PATH=.:$$PATH zic -l $(LOCALTIME) -d $(TZDIR) $(DATA) && > $@
  379. X
  380. Xzdump:        $(TZDOBJS)
  381. X        $(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) -o $@
  382. X
  383. X$(TZLIB):    $(LIBOBJS)
  384. X        ar ru $@ $(LIBOBJS)
  385. X        test -f /usr/bin/ranlib && ranlib $@
  386. X
  387. Xzic:        $(TZCOBJS)
  388. X        $(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) -o $@
  389. X
  390. XBUNDLES:    BUNDLE1 BUNDLE2 BUNDLE3
  391. X
  392. XBUNDLE1:    $(DOCS)
  393. X        $(BUNDLE) $(DOCS) > $@
  394. X
  395. XBUNDLE2:    $(SOURCES)
  396. X        $(BUNDLE) $(SOURCES) > $@
  397. X
  398. XBUNDLE3:    $(DATA)
  399. X        $(BUNDLE) $(DATA) > $@
  400. X
  401. X$(ENCHILADA):
  402. X        sccs get $(REL) $(REV) $@
  403. X
  404. Xsure:        $(TZCSRCS) $(TZDSRCS) tzfile.h
  405. X        lint $(LINTFLAGS) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZCSRCS)
  406. X        lint $(LINTFLAGS) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZDSRCS)
  407. X        lint $(LINTFLAGS) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(LIBSRCS)
  408. X
  409. Xclean:
  410. X        rm -f core *.o *.out REDID_BINARIES zdump zic BUNDLE* \#*
  411. X
  412. XCLEAN:        clean
  413. X        sccs clean
  414. X
  415. Xlisting:    $(ENCHILADA)
  416. X        pr $(ENCHILADA) | lpr
  417. X
  418. Xzdump.o zic.o newctime.o:    tzfile.h
  419. !The!End!
  420.  
  421. echo x - "newctime.3" 2>&1
  422. sed "s/^X//" >"newctime.3" <<'!The!End!'
  423. X.TH NEWCTIME 3 
  424. X.SH NAME
  425. Xctime, localtime, gmtime, asctime, tzset, tzsetwall \- convert date and time to ASCII
  426. X.SH SYNOPSIS
  427. X.nf
  428. X.B extern char *tzname[2];
  429. X.PP
  430. X.B void tzset()
  431. X.PP
  432. X.B void tzsetwall()
  433. X.PP
  434. X.B char *ctime(clock)
  435. X.B long *clock;
  436. X.PP
  437. X.B #include <time.h>
  438. X.PP
  439. X.B char *asctime(tm)
  440. X.B struct tm *tm;
  441. X.PP
  442. X.B struct tm *localtime(clock)
  443. X.B long *clock;
  444. X.PP
  445. X.B struct tm *gmtime(clock)
  446. X.B long *clock;
  447. X.PP
  448. Xcc ... -lz
  449. X.fi
  450. X.SH DESCRIPTION
  451. X.I Tzset
  452. Xuses the value of the environment variable
  453. X.B TZ
  454. Xto set time conversion information used by
  455. X.IR localtime .
  456. X.if \nX \{\
  457. XIF
  458. X.B TZ
  459. Xis absent from the environment,
  460. Xthe behavior is implementation defined.
  461. XIf
  462. X.B TZ
  463. Xdoes appear in the environment,
  464. X.I localtime
  465. Xwill only work correctly if
  466. Xits value is one of an
  467. Ximplementation-defined set of values.
  468. X\}
  469. X.if !\nX \{\
  470. XIf
  471. X.B TZ
  472. Xdoes not appear in the environment,
  473. Xthe best available approximation to local wall clock time is used by
  474. X.IR localtime .
  475. XIf
  476. X.B TZ
  477. Xappears in the environment but its value is a null string,
  478. XGreenwich Mean Time is used;
  479. Xif
  480. X.B TZ
  481. Xappears and
  482. Xbegins with a slash,
  483. Xit is used as the absolute pathname of the
  484. X.IR tzfile (5)-format
  485. Xfile from which to read the time conversion information;
  486. Xif
  487. X.B TZ
  488. Xappears and
  489. Xbegins with a character other than a slash,
  490. Xit's used as a pathname relative to a system time conversion information
  491. Xdirectory.
  492. X\}
  493. X.PP
  494. X.I Tzsetwall
  495. Xsets things up so that
  496. X.I localtime
  497. Xreturns the best available approximation of local wall clock time.
  498. X.PP
  499. X.I Ctime\^
  500. Xconverts a long integer, pointed to by
  501. X.IR clock ,
  502. Xrepresenting the time in seconds since
  503. X00:00:00 GMT, January 1, 1970,
  504. Xand returns a pointer to a
  505. X26-character string
  506. Xof the form
  507. X.br
  508. X.ce
  509. XThu Nov 24 18:22:48 1986\\n\\0
  510. X.br
  511. XAll the fields have constant width.
  512. X.PP
  513. X.IR Localtime\^
  514. Xand
  515. X.I gmtime\^
  516. Xreturn pointers to ``tm'' structures, described below.
  517. X.I Localtime\^
  518. Xcorrects for the time zone and any time zone adjustments
  519. X(such as Daylight Savings time in the U.S.A.).
  520. X.if \nX Whether, before doing so,
  521. X.if !\nX Before doing so,
  522. X.I localtime\^
  523. Xcalls
  524. X.I tzset\^
  525. X(if
  526. X.I tzset\^
  527. Xhas not been called in
  528. X.if \nX the current process) is implementation defined.
  529. X.if !\nX the current process).
  530. X.if !\nX \{\
  531. XAfter filling in the ``tm'' structure,
  532. X.I localtime
  533. Xsets the
  534. X.BR tm_isdst 'th
  535. Xelement of
  536. X.B tzname
  537. Xto a pointer to an 
  538. XASCII string that's the time zone abbreviation to be used with
  539. X.IR localtime 's
  540. Xreturn value.
  541. X\}
  542. X.PP
  543. X.I Gmtime\^
  544. Xconverts to Greenwich Mean Time (GMT).
  545. X.PP
  546. X.I Asctime\^
  547. Xconverts a time value contained in a
  548. X``tm'' structure to a 26-character string,
  549. Xas shown in the above example,
  550. Xand returns a pointer
  551. Xto the string.
  552. X.PP
  553. XDeclarations of all the functions and externals, and the ``tm'' structure,
  554. Xare in the
  555. X.B <time.h>\^
  556. Xheader file.
  557. XThe structure (of type)
  558. X.B struct tm
  559. Xincludes the following fields:
  560. X.RS
  561. X.PP
  562. X.nf
  563. X.ta .5i +\w'long tm_gmtoff;\0\0'u
  564. X    int tm_sec;    /\(** seconds (0 - 59) \(**/
  565. X    int tm_min;    /\(** minutes (0 - 59) \(**/
  566. X    int tm_hour;    /\(** hours (0 - 23) \(**/
  567. X    int tm_mday;    /\(** day of month (1 - 31) \(**/
  568. X    int tm_mon;    /\(** month of year (0 - 11) \(**/
  569. X    int tm_year;    /\(** year \- 1900 \(**/
  570. X    int tm_wday;    /\(** day of week (Sunday = 0) \(**/
  571. X    int tm_yday;    /\(** day of year (0 - 365) \(**/
  572. X    int tm_isdst;    /\(** is DST in effect? \(**/
  573. X    char \(**tm_zone;    /\(** abbreviation of timezone name \(**/
  574. X    long tm_gmtoff;    /\(** offset from GMT in seconds \(**/
  575. X.fi
  576. X.RE
  577. X.PP
  578. XThe
  579. X.I tm_zone
  580. Xand
  581. X.I tm_gmtoff
  582. Xfields exist, and are filled in, only if arrangements to do
  583. Xso were made when the library containing these functions was
  584. Xcreated.
  585. XThere is no guarantee that these fields will continue to exist
  586. Xin this form in future releases of this code.
  587. X.PP
  588. X.I Tm_isdst\^
  589. Xis non-zero if a 
  590. Xtime zone adjustment such as Daylight Savings time
  591. Xis in effect.
  592. X.PP
  593. X.I Tm_gmtoff
  594. Xis the offset (in seconds) of the time represented
  595. Xfrom GMT, with positive values indicating East
  596. Xof Greenwich.
  597. X.if !\nX \{\
  598. X.SH FILES
  599. X.ta \w'/etc/zoneinfo/localtime\0\0'u
  600. X/etc/zoneinfo    time zone information directory
  601. X.br
  602. X/etc/zoneinfo/localtime    local time zone file
  603. X\}
  604. X.SH SEE ALSO
  605. X.if !\nX tzfile(5),
  606. Xgetenv(3),
  607. Xtime(2)
  608. X.SH NOTE
  609. XThe return values point to static data
  610. Xwhose content is overwritten by each call.
  611. XThe
  612. X.B tm_zone
  613. Xfield of a returned
  614. X.B "struct tm"
  615. Xpoints to a static array of characters, which
  616. Xwill also be overwritten at the next call
  617. X(and by calls to
  618. X.I tzset
  619. Xor
  620. X.IR tzsetwall ).
  621. X.. @(#)newctime.3    3.1
  622. !The!End!
  623.  
  624. echo x - "tzfile.5" 2>&1
  625. sed "s/^X//" >"tzfile.5" <<'!The!End!'
  626. X.TH TZFILE 5
  627. X.SH NAME
  628. Xtzfile \- time zone information
  629. X.SH SYNOPSIS
  630. X.B
  631. X#include <tzfile.h>
  632. X.SH DESCRIPTION
  633. XThe time zone information files used by
  634. X.IR tzset (3)
  635. Xbegin with bytes reserved for future use,
  636. Xfollowed by three four-byte values of type
  637. X.BR long ,
  638. Xwritten in a ``standard'' byte order
  639. X(the high-order byte of the value is written first).
  640. XThese values are,
  641. Xin order:
  642. X.TP
  643. X.I tzh_timecnt
  644. XThe number of "transition times" for which data is stored
  645. Xin the file.
  646. X.TP
  647. X.I tzh_typecnt
  648. XThe number of "local time types" for which data is stored
  649. Xin the file (must not be zero).
  650. X.TP
  651. X.I tzh_charcnt
  652. XThe number of characters of "time zone abbreviation strings"
  653. Xstored in the file.
  654. X.PP
  655. XThe above header is followed by
  656. X.I tzh_timecnt
  657. Xfour-byte values of type
  658. X.BR long ,
  659. Xsorted in ascending order.
  660. XThese values are written in ``standard'' byte order.
  661. XEach is used as a transition time (as returned by
  662. X.IR time (2))
  663. Xat which the rules for computing local time change.
  664. XNext come
  665. X.I tzh_timecnt
  666. Xone-byte values of type
  667. X.BR "unsigned char" ;
  668. Xeach one tells which of the different types of ``local time'' types
  669. Xdescribed in the file is associated with the same-indexed transition time.
  670. XThese values serve as indices into an array of
  671. X.I ttinfo
  672. Xstructures that appears next in the file; 
  673. Xthese structures are defined as follows:
  674. X.in +.5i
  675. X.sp
  676. X.nf
  677. X.ta .5i +\w'unsigned int\0\0'u
  678. Xstruct ttinfo {    
  679. X    long    tt_gmtoff;
  680. X    int    tt_isdst;
  681. X    unsigned int    tt_abbrind;
  682. X};
  683. X.in -.5i
  684. X.fi
  685. X.sp
  686. XEach structure is written as a four-byte value for
  687. X.I tt_gmtoff
  688. Xof type
  689. X.BR long ,
  690. Xin a standard byte order, followed by a one-byte value for
  691. X.I tt_isdst
  692. Xand a one-byte value for
  693. X.IR tt_abbrind .
  694. XIn each structure,
  695. X.I tt_gmtoff
  696. Xgives the number of seconds to be added to GMT,
  697. X.I tt_isdst
  698. Xtells whether
  699. X.I tm_isdst
  700. Xshould be set by
  701. X.I localtime (3)
  702. Xand
  703. X.I tt_abbrind
  704. Xserves as an index into the array of time zone abbreviation characters
  705. Xthat follow the
  706. X.I ttinfo
  707. Xstructure(s) in the file.
  708. X.PP
  709. X.I Localtime
  710. Xuses the first standard-time
  711. X.I ttinfo
  712. Xstructure in the file
  713. X(or simply the first
  714. X.I ttinfo
  715. Xstructure in the absence of a standard-time structure)
  716. Xif either
  717. X.I tzh_timecnt
  718. Xis zero or the time argument is less than the first transition time recorded
  719. Xin the file.
  720. X.SH SEE ALSO
  721. Xnewctime(3)
  722. X.. @(#)tzfile.5    3.1
  723. !The!End!
  724.  
  725. echo x - "zic.8" 2>&1
  726. sed "s/^X//" >"zic.8" <<'!The!End!'
  727. X.TH ZIC 8
  728. X.SH NAME
  729. Xzic \- time zone compiler
  730. X.SH SYNOPSIS
  731. X.B zic
  732. X[
  733. X.B \-v
  734. X] [
  735. X.B \-d
  736. X.I directory
  737. X] [
  738. X.B \-l
  739. X.I localtime
  740. X] [
  741. X.I filename
  742. X\&... ]
  743. X.SH DESCRIPTION
  744. X.I Zic
  745. Xreads text from the file(s) named on the command line
  746. Xand creates the time conversion information files specified in this input.
  747. XIf a
  748. X.I filename
  749. Xis
  750. X.BR \- ,
  751. Xthe standard input is read.
  752. X.PP
  753. XThese options are available:
  754. X.TP
  755. X.BI "\-d " directory
  756. XCreate time conversion information files in the named directory rather than
  757. Xin the standard directory named below.
  758. X.TP
  759. X.BI "\-l " timezone
  760. XUse the given time zone as local time.
  761. X.I Zic
  762. Xwill act as if the file contained a link line of the form
  763. X.sp
  764. X.ti +.5i
  765. XLink    \fItimezone\fP        localtime
  766. X.TP
  767. X.B \-v
  768. XComplain if a year that appears in a data file is outside the range
  769. Xof years representable by
  770. X.IR time (2)
  771. Xvalues.
  772. X.sp
  773. XInput lines are made up of fields.
  774. XFields are separated from one another by any number of white space characters.
  775. XLeading and trailing white space on input lines is ignored.
  776. XAn unquoted sharp character (#) in the input introduces a comment which extends
  777. Xto the end of the line the sharp character appears on.
  778. XWhite space characters and sharp characters may be enclosed in double quotes
  779. X(") if they're to be used as part of a field.
  780. XAny line that is blank (after comment stripping) is ignored.
  781. XNon-blank lines are expected to be of one of three types:
  782. Xrule lines, zone lines, and link lines.
  783. X.PP
  784. XA rule line has the form
  785. X.nf
  786. X.B
  787. X.ti +.5i
  788. X.ta \w'Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'1973\0\0'u +\w'TYPE\0\0'u +\w'Apr\0\0'u +\w'lastSun\0\0'u +\w'2:00\0\0'u +\w'SAVE\0\0'u
  789. X.sp
  790. XRule    NAME    FROM    TO    TYPE    IN    ON    AT    SAVE    LETTER/S
  791. X.sp
  792. XFor example:
  793. X.ti +.5i
  794. X.sp
  795. XRule    USA    1969    1973    \-    Apr    lastSun    2:00    1:00    D
  796. X.sp
  797. X.fi
  798. XThe fields that make up a rule line are:
  799. X.TP "\w'LETTER/S'u"
  800. X.B NAME
  801. XGives the (arbitrary) name of the set of rules this rule is part of.
  802. X.TP
  803. X.B FROM
  804. XGives the first year in which the rule applies.
  805. XThe word
  806. X.B minimum
  807. X(or an abbreviation) means the minimum year with a representable time value.
  808. XThe word
  809. X.B maximum
  810. X(or an abbreviation) means the maximum year with a representable time value.
  811. X.TP
  812. X.B TO
  813. XGives the final year in which the rule applies.
  814. XIn addition to
  815. X.B minimum
  816. Xand
  817. X.B maximum
  818. X(as above),
  819. Xthe word
  820. X.B only
  821. X(or an abbreviation)
  822. Xmay be used to repeat the value of the
  823. X.B FROM
  824. Xfield.
  825. X.TP
  826. X.B TYPE
  827. XGives the type of year in which the year applies.
  828. XIf
  829. X.B TYPE
  830. Xis
  831. X.B \-
  832. Xthen the rule applies in all years between
  833. X.B FROM
  834. Xand
  835. X.B TO
  836. Xinclusive;
  837. Xif
  838. X.B TYPE
  839. Xis
  840. X.BR uspres ,
  841. Xthe rule applies in U.S. Presidential election years;
  842. Xif
  843. X.B TYPE
  844. Xis
  845. X.BR nonpres ,
  846. Xthe rule applies in years other than U.S. Presidential election years.
  847. XIf
  848. X.B TYPE
  849. Xis something else, then
  850. X.I zic
  851. Xexecutes the command
  852. X.ti +.5i
  853. X\fByearistype\fP \fIyear\fP \fItype\fP
  854. X.br
  855. Xto check the type of a year:
  856. Xan exit status of zero is taken to mean that the year is of the given type;
  857. Xan exit status of one is taken to mean that the year is not of the given type.
  858. X.TP
  859. X.B IN
  860. XNames the month in which the rule takes effect.
  861. XMonth names may be abbreviated.
  862. X.TP
  863. X.B ON
  864. XGives the day on which the rule takes effect.
  865. XRecognized forms include:
  866. X.nf
  867. X.in +.5i
  868. X.sp
  869. X.ta \w'Sun<=25\0\0'u
  870. X5    the fifth of the month
  871. XlastSun    the last Sunday in the month
  872. XlastMon    the last Monday in the month
  873. XSun>=8    first Sunday on or after the eighth
  874. XSun<=25    last Sunday on or before the 25th
  875. X.fi
  876. X.in -.5i
  877. X.sp
  878. XNames of days of the week may be abbreviated or spelled out in full.
  879. XNote that there must be no spaces within the
  880. X.B ON
  881. Xfield.
  882. X.TP
  883. X.B AT
  884. XGives the time of day at which the rule takes affect.
  885. XRecognized forms include:
  886. X.nf
  887. X.in +.5i
  888. X.sp
  889. X.ta \w'1:28:13\0\0'u
  890. X2    time in hours
  891. X2:00    time in hours and minutes
  892. X15:00    24-hour format time (for times after noon)
  893. X1:28:14    time in hours, minutes, and seconds
  894. X.fi
  895. X.in -.5i
  896. X.sp
  897. XAny of these forms may be followed by the letter
  898. X.B w
  899. Xif the given time is local ``wall clock'' time or
  900. X.B s
  901. Xif the given time is local ``standard'' time; in the absence of
  902. X.B w
  903. Xor
  904. X.BR s ,
  905. Xwall clock time is assumed.
  906. X.TP
  907. X.B SAVE
  908. XGives the amount of time to be added to local standard time when the rule is in
  909. Xeffect.
  910. XThis field has the same format as the
  911. X.B AT
  912. Xfield
  913. X(although, of course, the
  914. X.B w
  915. Xand
  916. X.B s
  917. Xsuffixes are not used).
  918. X.TP
  919. X.B LETTER/S
  920. XGives the ``variable part'' (for example, the ``S'' or ``D'' in ``EST''
  921. Xor ``EDT'') of time zone abbreviations to be used when this rule is in effect.
  922. XIf this field is
  923. X.BR \- ,
  924. Xthe variable part is null.
  925. X.PP
  926. XA zone line has the form
  927. X.sp
  928. X.nf
  929. X.ti +.5i
  930. X.ta \w'Zone\0\0'u +\w'Australia/South\-west\0\0'u +\w'GMTOFF\0\0'u +\w'RULES/SAVE\0\0'u +\w'FORMAT\0\0'u
  931. XZone    NAME    GMTOFF    RULES/SAVE    FORMAT    [UNTIL]
  932. X.sp
  933. XFor example:
  934. X.sp
  935. X.ti +.5i
  936. XZone    Australia/South\-west    9:30    Aus    CST    1987 Mar 15 2:00
  937. X.sp
  938. X.fi
  939. XThe fields that make up a zone line are:
  940. X.TP "\w'GMTOFF'u"
  941. X.B NAME
  942. XThe name of the time zone.
  943. XThis is the name used in creating the time conversion information file for the
  944. Xzone.
  945. X.TP
  946. X.B GMTOFF
  947. XThe amount of time to add to GMT to get standard time in this zone.
  948. XThis field has the same format as the
  949. X.B AT
  950. Xand
  951. X.B SAVE
  952. Xfields of rule lines;
  953. Xbegin the field with a minus sign if time must be subtracted from GMT.
  954. X.TP
  955. X.B RULES/SAVE
  956. XThe name of the rule(s) that apply in the time zone or,
  957. Xalternately, an amount of time to add to local standard time.
  958. XIf this field is
  959. X.B \-
  960. Xthen standard time always applies in the time zone.
  961. X.TP
  962. X.B FORMAT
  963. XThe format for time zone abbreviations in this time zone.
  964. XThe pair of characters
  965. X.B %s
  966. Xis used to show where the ``variable part'' of the time zone abbreviation goes.
  967. X.B UNTIL
  968. XThe time at which the GMT offset or the rule(s) change for a location.
  969. XIt is specified as a year, a month, a day, and a time of day.
  970. XIf this is specified,
  971. Xthe time zone information is generated from the given GMT offset
  972. Xand rule change until the time specified.
  973. X.IP
  974. XThe next line must be a
  975. X``continuation'' line; this has the same form as a zone line except that the
  976. Xstring ``Zone'' and the name are omitted, as the continuation line will
  977. Xplace information starting at the time specified as the
  978. X.B UNTIL
  979. Xfield in the previous line in the file used by the previous line.
  980. XContinuation lines may contain an
  981. X.B UNTIL
  982. Xfield, just as zone lines do, indicating that the next line is a further
  983. Xcontinuation.
  984. X.PP
  985. XA link line has the form
  986. X.sp
  987. X.nf
  988. X.ti +.5i
  989. X.if t .ta \w'Link\0\0'u +\w'LINK-FROM\0\0'u
  990. X.if n .ta \w'Link\0\0'u +\w'US/Eastern\0\0'u
  991. XLink    LINK-FROM    LINK-TO
  992. X.sp
  993. XFor example:
  994. X.sp
  995. X.ti +.5i
  996. XLink    US/Eastern    EST5EDT
  997. X.sp
  998. X.fi
  999. XThe
  1000. X.B LINK-FROM
  1001. Xfield should appear as the
  1002. X.B NAME
  1003. Xfield in some zone line;
  1004. Xthe
  1005. X.B LINK-TO
  1006. Xfield is used as an alternate name for that zone.
  1007. X.PP
  1008. XExcept for continuation lines,
  1009. Xlines may appear in any order in the input.
  1010. X.SH NOTE
  1011. XFor areas with more than two types of local time,
  1012. Xyou may need to use local standard time in the
  1013. X.B AT
  1014. Xfield of the earliest transition time's rule to ensure that
  1015. Xthe earliest transition time recorded in the compiled file is correct.
  1016. X.SH FILES
  1017. X/etc/zoneinfo    standard directory used for created files
  1018. X.SH "SEE ALSO"
  1019. Xnewctime(3), tzfile(5), zdump(8)
  1020. X.. @(#)zic.8    3.1
  1021. !The!End!
  1022.  
  1023. echo x - "zdump.8" 2>&1
  1024. sed "s/^X//" >"zdump.8" <<'!The!End!'
  1025. X.TH ZDUMP 8
  1026. X.SH NAME
  1027. Xzdump \- time zone dumper
  1028. X.SH SYNOPSIS
  1029. X.B zdump
  1030. X[
  1031. X.B \-v
  1032. X] [
  1033. X.B \-c
  1034. Xcutoffyear ] [ zonename ... ]
  1035. X.SH DESCRIPTION
  1036. X.I Zdump
  1037. Xprints the current time in each
  1038. X.I zonename
  1039. Xnamed on the command line.
  1040. X.PP
  1041. XThese options are available:
  1042. X.TP
  1043. X.B \-v
  1044. XFor each
  1045. X.I zonename
  1046. Xon the command line,
  1047. Xprint the current time,
  1048. Xthe time at the lowest possible time value,
  1049. Xthe time one day after the lowest possible time value,
  1050. Xthe times both one second before and exactly at
  1051. Xeach time at which the rules for computing local time change,
  1052. Xthe time at the highest possible time value,
  1053. Xand the time at one day less than the highest possible time value.
  1054. XEach line ends with
  1055. X.B isdst=1
  1056. Xif the given time is Daylight Saving Time or
  1057. X.B isdst=0
  1058. Xotherwise.
  1059. X.TP
  1060. X.BI "\-c " cutoffyear
  1061. XCut off the verbose output near the start of the given year.
  1062. X.SH FILES
  1063. X/etc/zoneinfo    standard zone information directory
  1064. X.SH "SEE ALSO"
  1065. Xnewctime(3), tzfile(5), zic(8)
  1066. X.. @(#)zdump.8    3.1
  1067. !The!End!
  1068. exit
  1069.