home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / localtime3 / part01 next >
Encoding:
Internet Message Format  |  1988-03-31  |  34.7 KB

  1. Subject:  v14i030:  Public time (zone) conversion routines, Part01/03
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Arthur David Olson <elsie!ado>
  7. Posting-number: Volume 14, Issue 30
  8. Archive-name: localtime3/part01
  9.  
  10. [  NOTE:  Since a US daylight savings time change starts today, this
  11.    posting is out of order.  Vplot will resume after the weekend.  -r$ ]
  12.  
  13. : To unbundle, sh this file
  14. echo 'Patchlevel.h' 1>&2
  15. cat >'Patchlevel.h' <<'End of Patchlevel.h'
  16. /* @(#)Patchlevel.h    4.1 */
  17.  
  18. #define PATCHLEVEL 1
  19. End of Patchlevel.h
  20. echo 'README' 1>&2
  21. cat >'README' <<'End of README'
  22. @(#)README    4.1
  23.  
  24. Please send comments or information to
  25.     vax2.nlm.nih.gov!elsie!tz
  26. for forwarding to folks interested in time zone matters.
  27.  
  28. Be sure to read the comments in "Makefile" and make any changes
  29. needed to make things right for your system.
  30.  
  31. This version of the time zone software uses a new format
  32. (based on the work of Guy Harris, a.k.a guy@sun.UUCP)
  33. for the time zone information files.  They are now stored by default in a
  34. directory named "/etc/zoneinfo" rather than "/etc/tzdir" or "/etc/timezones"
  35. as before.  If you've already compiled programs with older time zone software,
  36. just leave the "/etc/tzdir" and/or "/etc/timezones" files around until you
  37. have a chance to recompile.
  38.  
  39. For better compatability with other versions of time conversion functions,
  40. the time zone abbreviation to be used with localtime's return value is now
  41. pointed to by one of the two elements of the (char *) array tzname, rather
  42. than by the (char *) tz_abbr.  If you have code that uses tz_abbr, add a
  43.     -DTZA_COMPAT
  44. to the end of the
  45.     CFLAGS=
  46. line in "Makefile".
  47.  
  48. To use the new functions, use a "-lz" option when compiling or linking.
  49.  
  50. Historical local time information has been included here not because it
  51. is particularly useful, but rather to:
  52.  
  53. *    give an idea of the variety of local time rules that have
  54.     existed in the past and thus an idea of the variety that may be
  55.     expected in the future;
  56.  
  57. *    provide a test of the generality of the local time rule description
  58.     system.
  59.  
  60. The information in the time zone data files is by no means authoritative;
  61. if you know that the rules are different from those in a file, by all means
  62. feel free to change file (and please send the changed version to
  63. vax2.nlm.nih.gov!elsie!tz for use in the future).  Europeans take note!
  64. End of README
  65. echo 'Theory' 1>&2
  66. cat >'Theory' <<'End of Theory'
  67. @(#)Theory    4.1
  68.  
  69. These time and date functions are much like the System V Release 2.0 (SVR2)
  70. time and date functions; there are a few additions and changes to extend
  71. the usefulness of the SVR2 functions:
  72.  
  73. *    In SVR2, time display in a process is controlled by the environment
  74.     variable TZ, which "must be a three-letter time zone name, followed
  75.     by a number representing the difference between local time and
  76.     Greenwich Mean Time in hours, followed by an optional three-letter
  77.     name for a daylight time zone;" when the optional daylight time zone is
  78.     present, "standard U.S.A. Daylight Savings Time conversion is applied."
  79.     This means that SVR2 can't deal with other (for example, Australian) 
  80.     daylight savings time rules, or situations where more than two
  81.     time zone abbreviations are used in an area.
  82.  
  83. *    In SVR2, time conversion information is compiled into each program
  84.     that does time conversion.  This means that when time conversion
  85.     rules change (as in the United States in 1987), all programs that
  86.     do time conversion must be recompiled to ensure proper results.
  87.  
  88. *    In SVR2, time conversion fails for near-minimum or near-maximum
  89.     time_t values when doing conversions for places that don't use GMT.
  90.  
  91. *    In SVR2, there's no tamper-proof way for a process to learn the
  92.     system's best idea of local wall clock.  (This is important for 
  93.     applications that an administrator wants used only at certain times--
  94.     without regard to whether the user has fiddled the "TZ" environment
  95.     variable.  While an administrator can "do everything in GMT" to get
  96.     around the problem, doing so is inconvenient and precludes handling
  97.     daylight savings time shifts--as might be required to limit phone
  98.     calls to off-peak hours.)
  99.  
  100. *    These functions can account for leap seconds, thanks to Bradley White
  101.     (bww@k.cs.cmu.edu).
  102.  
  103. These are the changes that have been made to the SVR2 functions:
  104.  
  105. *    The "TZ" environment variable is used in generating the name of a file
  106.     from which time zone information is read; "TZ" is no longer constrained
  107.     to be a three-letter time zone name followed by a number of hours and
  108.     an optional three-letter daylight time zone name.  The daylight saving
  109.     time rules to be used for a particular time zone are encoded in the
  110.     time zone file; the format of the file allows U.S., Australian, and
  111.     other rules to be encoded, and allows for situations where more than
  112.     two time zone abbreviations are used.
  113.  
  114.     It was recognized that allowing the "TZ" environment variable to
  115.     take on values such as "US/Eastern" might cause "old" programs
  116.     (that expect "TZ" to have a certain form) to operate incorrectly;
  117.     consideration was given to using some other environment variable
  118.     (for example, "TIMEZONE") to hold the string used to generate the
  119.     time zone information file name.  In the end, however, it was decided
  120.     to continue using "TZ":  it is widely used for time zone purposes;
  121.     separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance;
  122.     and systems where "new" forms of "TZ" might cause problems can simply
  123.     give time zone files names such as "EST5EDT" which can be used both by
  124.     "new" programs (as file names) and "old" programs (as zone names and
  125.     offsets).
  126.  
  127. *    To handle places where more than two time zone abbreviations are used,
  128.     the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst]
  129.     (where "tmp" is the value the function returns) to the time zone
  130.     abbreviation to be used.  This differs from SVR2, where the elements
  131.     of tzname are only changed as a result of calls to tzset.
  132.  
  133. *    Since the "TZ" environment variable can now be used to control time
  134.     conversion, the "daylight" and "timezone" variables are no longer
  135.     needed or supported.  (You can use a compile-time option to cause
  136.     these variables to be defined and to be set by "tzset"; however, their
  137.     values will not be used by "localtime.")
  138.  
  139. *    The "localtime" function has been set up to deliver correct results
  140.     for near-minimum or near-maximum time_t values.  (A comment in the
  141.     source code tells how to get compatibly wrong results).
  142.  
  143. *    A function "tzsetwall" has been added to arrange for the system's
  144.     best approximation to local wall clock time to be delivered by
  145.     subsequent calls to "localtime."  Source code for portable
  146.     applications that "must" run on local wall clock time should call
  147.     "tzsetwall();" if such code is moved to "old" systems that don't provide
  148.     tzsetwall, you won't be able to generate an executable program.
  149.     (These time zone functions also arrange for local wall clock time to be
  150.     used if tzset is called--directly or indirectly--and there's no "TZ"
  151.     environment variable; portable applications should not, however, rely
  152.     on this behavior since it's not the way SVR2 systems behave.)
  153.  
  154. Points of interest to folks with Version 7 or BSD systems:
  155.  
  156. *    The BSD "timezone" function is not present in this package;
  157.     it's impossible to reliably map timezone's arguments (a "minutes west
  158.     of GMT" value and a "daylight saving time in effect" flag) to a
  159.     time zone abbreviation, and we refuse to guess. 
  160.     Programs that in the past used the timezone function may now examine
  161.     tzname[localtime(&clock)->tm_isdst] to learn the correct time
  162.     zone abbreviation to use.  Alternatively, use localtime(&clock)->tm_zone
  163.     if this has been enabled.
  164.  
  165. *    The BSD gettimeofday function is not used in this package;
  166.     this lets users control the time zone used in doing time conversions.
  167.     Users who don't try to control things (that is, users who do not set
  168.     the environment variable TZ) get the time conversion specified in the
  169.     file "/etc/zoneinfo/localtime"; see the time zone compiler writeup for
  170.     information on how to initialize this file.
  171.  
  172. *    The BSD "dysize" function is only included if the preprocessor symbol
  173.     BSD_COMPAT is defined.  For a year y, the BSD code returns the value
  174.        ((y % 4) == 0) : 366 : 365
  175.     while this code returns the value
  176.        (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) ? 366 : 365
  177.     There's a comment in the code telling how to get the BSD value.
  178.  
  179. The functions that are conditionally compiled if STD_INSPIRED is defined should,
  180. at this point, be looked on primarily as food for thought.  They are not in
  181. any sense "standard compatible"--some are not, in fact, specified in *any*
  182. standard.  They do, however, represent responses of various authors to
  183. standardization proposals.
  184.  
  185. Other time conversion proposals, in particular the one developed by folks at
  186. Hewlett Packard, offer a wider selection of functions that provide capabilities
  187. beyond those provided here.  The absence of such functions from this package
  188. is not meant to discourage the development, standardization, or use of such
  189. functions.  Rather, their absence reflects the decision to make this package
  190. close to SVR2 (with the exceptions outlined above) to ensure its broad
  191. acceptability.  If more powerful time conversion functions can be standardized,
  192. so much the better.
  193.  
  194. It's probably not wise to standardize everything in this package.
  195. While the command
  196.     nroff -man newctime.3
  197. produces a document that describes this package, the command
  198.     nroff -man -rX3J11 newctime.3
  199. produces a document that describes the "standardizable" parts.
  200. End of Theory
  201. echo 'newctime.3' 1>&2
  202. cat >'newctime.3' <<'End of newctime.3'
  203. .TH NEWCTIME 3 
  204. .SH NAME
  205. ctime, localtime, gmtime, asctime, tzset, tzsetwall \- convert date and time to ASCII
  206. .SH SYNOPSIS
  207. .nf
  208. .B extern char *tzname[2];
  209. .PP
  210. .B void tzset()
  211. .PP
  212. .B void tzsetwall()
  213. .PP
  214. .B char *ctime(clock)
  215. .B long *clock;
  216. .PP
  217. .B #include <time.h>
  218. .PP
  219. .B char *asctime(tm)
  220. .B struct tm *tm;
  221. .PP
  222. .B struct tm *localtime(clock)
  223. .B long *clock;
  224. .PP
  225. .B struct tm *gmtime(clock)
  226. .B long *clock;
  227. .if !\nX \{\
  228. .PP
  229. cc ... -lz
  230. .fi
  231. \}
  232. .SH DESCRIPTION
  233. .I Tzset
  234. uses the value of the environment variable
  235. .B TZ
  236. to set time conversion information used by
  237. .IR localtime .
  238. .if \nX \{\
  239. IF
  240. .B TZ
  241. is absent from the environment,
  242. the behavior is implementation defined.
  243. If
  244. .B TZ
  245. does appear in the environment,
  246. .I localtime
  247. will only work correctly if
  248. its value is one of an
  249. implementation-defined set of values.
  250. \}
  251. .if !\nX \{\
  252. If
  253. .B TZ
  254. does not appear in the environment,
  255. the best available approximation to local wall clock time is used by
  256. .IR localtime .
  257. If
  258. .B TZ
  259. appears in the environment but its value is a null string,
  260. Greenwich Mean Time is used (without leap second correction);
  261. if
  262. .B TZ
  263. appears and
  264. begins with a slash,
  265. it is used as the absolute pathname of the
  266. .IR tzfile (5)-format
  267. file from which to read the time conversion information;
  268. if
  269. .B TZ
  270. appears and
  271. begins with a character other than a slash,
  272. it's used as a pathname relative to a system time conversion information
  273. directory.
  274. \}
  275. .PP
  276. .I Tzsetwall
  277. sets things up so that
  278. .I localtime
  279. returns the best available approximation of local wall clock time.
  280. .PP
  281. .I Ctime\^
  282. converts a long integer, pointed to by
  283. .IR clock ,
  284. representing the time in seconds since
  285. 00:00:00 GMT, January 1, 1970,
  286. and returns a pointer to a
  287. 26-character string
  288. of the form
  289. .br
  290. .ce
  291. Thu Nov 24 18:22:48 1986\\n\\0
  292. .br
  293. All the fields have constant width.
  294. .PP
  295. .IR Localtime\^
  296. and
  297. .I gmtime\^
  298. return pointers to ``tm'' structures, described below.
  299. .I Localtime\^
  300. corrects for the time zone and any time zone adjustments
  301. (such as Daylight Saving Time in the U.S.A.).
  302. .if \nX Whether, before doing so,
  303. .if !\nX Before doing so,
  304. .I localtime\^
  305. calls
  306. .I tzset\^
  307. (if
  308. .I tzset\^
  309. has not been called in
  310. .if \nX the current process) is implementation defined.
  311. .if !\nX the current process).
  312. .if !\nX \{\
  313. After filling in the ``tm'' structure,
  314. .I localtime
  315. sets the
  316. .BR tm_isdst 'th
  317. element of
  318. .B tzname
  319. to a pointer to an 
  320. ASCII string that's the time zone abbreviation to be used with
  321. .IR localtime 's
  322. return value.
  323. \}
  324. .PP
  325. .I Gmtime\^
  326. converts to Greenwich Mean Time (GMT).
  327. .PP
  328. .I Asctime\^
  329. converts a time value contained in a
  330. ``tm'' structure to a 26-character string,
  331. as shown in the above example,
  332. and returns a pointer
  333. to the string.
  334. .PP
  335. Declarations of all the functions and externals, and the ``tm'' structure,
  336. are in the
  337. .B <time.h>\^
  338. header file.
  339. The structure (of type)
  340. .B struct tm
  341. includes the following fields:
  342. .RS
  343. .PP
  344. .nf
  345. .ta .5i +\w'long tm_gmtoff;\0\0'u
  346.     int tm_sec;    /\(** seconds (0 - 60) \(**/
  347.     int tm_min;    /\(** minutes (0 - 59) \(**/
  348.     int tm_hour;    /\(** hours (0 - 23) \(**/
  349.     int tm_mday;    /\(** day of month (1 - 31) \(**/
  350.     int tm_mon;    /\(** month of year (0 - 11) \(**/
  351.     int tm_year;    /\(** year \- 1900 \(**/
  352.     int tm_wday;    /\(** day of week (Sunday = 0) \(**/
  353.     int tm_yday;    /\(** day of year (0 - 365) \(**/
  354.     int tm_isdst;    /\(** is DST in effect? \(**/
  355.     char \(**tm_zone;    /\(** abbreviation of timezone name \(**/
  356.     long tm_gmtoff;    /\(** offset from GMT in seconds \(**/
  357. .fi
  358. .RE
  359. .PP
  360. The
  361. .I tm_zone
  362. and
  363. .I tm_gmtoff
  364. fields exist, and are filled in, only if arrangements to do
  365. so were made when the library containing these functions was
  366. created.
  367. There is no guarantee that these fields will continue to exist
  368. in this form in future releases of this code.
  369. .PP
  370. .I Tm_isdst\^
  371. is non-zero if a 
  372. time zone adjustment such as Daylight Saving Time
  373. is in effect.
  374. .PP
  375. .I Tm_gmtoff
  376. is the offset (in seconds) of the time represented
  377. from GMT, with positive values indicating East
  378. of Greenwich.
  379. .if !\nX \{\
  380. .SH FILES
  381. .ta \w'/etc/zoneinfo/localtime\0\0'u
  382. /etc/zoneinfo    time zone information directory
  383. .br
  384. /etc/zoneinfo/localtime    local time zone file
  385. \}
  386. .br
  387. /etc/zoneinfo/GMT    GMT file (needed for leap seconds)
  388. .SH SEE ALSO
  389. .if !\nX tzfile(5),
  390. getenv(3),
  391. time(2)
  392. .SH NOTE
  393. The return values point to static data
  394. whose content is overwritten by each call.
  395. The
  396. .B tm_zone
  397. field of a returned
  398. .B "struct tm"
  399. points to a static array of characters, which
  400. will also be overwritten at the next call
  401. (and by calls to
  402. .I tzset
  403. or
  404. .IR tzsetwall ).
  405. .. @(#)newctime.3    4.1
  406. End of newctime.3
  407. echo 'tzfile.5' 1>&2
  408. cat >'tzfile.5' <<'End of tzfile.5'
  409. .TH TZFILE 5
  410. .SH NAME
  411. tzfile \- time zone information
  412. .SH SYNOPSIS
  413. .B
  414. #include <tzfile.h>
  415. .SH DESCRIPTION
  416. The time zone information files used by
  417. .IR tzset (3)
  418. begin with bytes reserved for future use,
  419. followed by four four-byte values of type
  420. .BR long ,
  421. written in a ``standard'' byte order
  422. (the high-order byte of the value is written first).
  423. These values are,
  424. in order:
  425. .TP
  426. .I tzh_leapcnt
  427. The number of leap seconds for which data is stored in the file.
  428. .TP
  429. .I tzh_timecnt
  430. The number of "transition times" for which data is stored
  431. in the file.
  432. .TP
  433. .I tzh_typecnt
  434. The number of "local time types" for which data is stored
  435. in the file (must not be zero).
  436. .TP
  437. .I tzh_charcnt
  438. The number of characters of "time zone abbreviation strings"
  439. stored in the file.
  440. .PP
  441. The above header is followed by
  442. .I tzh_timecnt
  443. four-byte values of type
  444. .BR long ,
  445. sorted in ascending order.
  446. These values are written in ``standard'' byte order.
  447. Each is used as a transition time (as returned by
  448. .IR time (2))
  449. at which the rules for computing local time change.
  450. Next come
  451. .I tzh_timecnt
  452. one-byte values of type
  453. .BR "unsigned char" ;
  454. each one tells which of the different types of ``local time'' types
  455. described in the file is associated with the same-indexed transition time.
  456. These values serve as indices into an array of
  457. .I ttinfo
  458. structures that appears next in the file; 
  459. these structures are defined as follows:
  460. .in +.5i
  461. .sp
  462. .nf
  463. .ta .5i +\w'unsigned int\0\0'u
  464. struct ttinfo {    
  465.     long    tt_gmtoff;
  466.     int    tt_isdst;
  467.     unsigned int    tt_abbrind;
  468. };
  469. .in -.5i
  470. .fi
  471. .sp
  472. Each structure is written as a four-byte value for
  473. .I tt_gmtoff
  474. of type
  475. .BR long ,
  476. in a standard byte order, followed by a one-byte value for
  477. .I tt_isdst
  478. and a one-byte value for
  479. .IR tt_abbrind .
  480. In each structure,
  481. .I tt_gmtoff
  482. gives the number of seconds to be added to GMT,
  483. .I tt_isdst
  484. tells whether
  485. .I tm_isdst
  486. should be set by
  487. .I localtime (3)
  488. and
  489. .I tt_abbrind
  490. serves as an index into the array of time zone abbreviation characters
  491. that follow the
  492. .I ttinfo
  493. structure(s) in the file.
  494. .PP
  495. Finally, there are
  496. .I tzh_leapcnt
  497. pairs of four-byte values, written in standard byte order;
  498. the first value of each pair gives the time
  499. (as returned by 
  500. .IR time(2))
  501. at which a leap second occurs;
  502. the second gives the
  503. .I total
  504. number of leap seconds to be applied after the given time.
  505. The pairs of values are sorted in ascending order by time.
  506. .PP
  507. .I Localtime
  508. uses the first standard-time
  509. .I ttinfo
  510. structure in the file
  511. (or simply the first
  512. .I ttinfo
  513. structure in the absence of a standard-time structure)
  514. if either
  515. .I tzh_timecnt
  516. is zero or the time argument is less than the first transition time recorded
  517. in the file.
  518. .SH SEE ALSO
  519. newctime(3)
  520. .. @(#)tzfile.5    4.1
  521. End of tzfile.5
  522. echo 'zic.8' 1>&2
  523. cat >'zic.8' <<'End of zic.8'
  524. .TH ZIC 8
  525. .SH NAME
  526. zic \- time zone compiler
  527. .SH SYNOPSIS
  528. .B zic
  529. [
  530. .B \-v
  531. ] [
  532. .B \-d
  533. .I directory
  534. ] [
  535. .B \-l
  536. .I localtime
  537. ] [
  538. .B \-L
  539. .I leapsecondfilename
  540. ] [
  541. .B \-s
  542. ] [
  543. .I filename
  544. \&... ]
  545. .SH DESCRIPTION
  546. .if t .ds lq ``
  547. .if t .ds rq ''
  548. .if n .ds lq \&"\"
  549. .if n .ds rq \&"\"
  550. .de q
  551. \\$3\*(lq\\$1\*(rq\\$2
  552. ..
  553. .I Zic
  554. reads text from the file(s) named on the command line
  555. and creates the time conversion information files specified in this input.
  556. If a
  557. .I filename
  558. is
  559. .BR \- ,
  560. the standard input is read.
  561. .PP
  562. These options are available:
  563. .TP
  564. .BI "\-d " directory
  565. Create time conversion information files in the named directory rather than
  566. in the standard directory named below.
  567. .TP
  568. .BI "\-l " timezone
  569. Use the given time zone as local time.
  570. .I Zic
  571. will act as if the file contained a link line of the form
  572. .sp
  573. .ti +.5i
  574. Link    \fItimezone\fP        localtime
  575. .TP
  576. .BI "\-L " leapsecondfilename
  577. Read leap second information from the file with the given name.
  578. If this option is not used,
  579. leap second information is read from a file named "leapseconds".
  580. .TP
  581. .B \-v
  582. Complain if a year that appears in a data file is outside the range
  583. of years representable by
  584. .IR time (2)
  585. values.
  586. .TP
  587. .B \-s
  588. Limit time values stored in output files to values that are the same
  589. whether they're taken to be signed or unsigned.
  590. You can use this option to generate SVVS-compatible files.
  591. .sp
  592. Input lines are made up of fields.
  593. Fields are separated from one another by any number of white space characters.
  594. Leading and trailing white space on input lines is ignored.
  595. An unquoted sharp character (#) in the input introduces a comment which extends
  596. to the end of the line the sharp character appears on.
  597. White space characters and sharp characters may be enclosed in double quotes
  598. (") if they're to be used as part of a field.
  599. Any line that is blank (after comment stripping) is ignored.
  600. Non-blank lines are expected to be of one of three types:
  601. rule lines, zone lines, and link lines.
  602. .PP
  603. A rule line has the form
  604. .nf
  605. .B
  606. .ti +.5i
  607. .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
  608. .sp
  609. Rule    NAME    FROM    TO    TYPE    IN    ON    AT    SAVE    LETTER/S
  610. .sp
  611. For example:
  612. .ti +.5i
  613. .sp
  614. Rule    USA    1969    1973    \-    Apr    lastSun    2:00    1:00    D
  615. .sp
  616. .fi
  617. The fields that make up a rule line are:
  618. .TP "\w'LETTER/S'u"
  619. .B NAME
  620. Gives the (arbitrary) name of the set of rules this rule is part of.
  621. .TP
  622. .B FROM
  623. Gives the first year in which the rule applies.
  624. The word
  625. .B minimum
  626. (or an abbreviation) means the minimum year with a representable time value.
  627. The word
  628. .B maximum
  629. (or an abbreviation) means the maximum year with a representable time value.
  630. .TP
  631. .B TO
  632. Gives the final year in which the rule applies.
  633. In addition to
  634. .B minimum
  635. and
  636. .B maximum
  637. (as above),
  638. the word
  639. .B only
  640. (or an abbreviation)
  641. may be used to repeat the value of the
  642. .B FROM
  643. field.
  644. .TP
  645. .B TYPE
  646. Gives the type of year in which the rule applies.
  647. If
  648. .B TYPE
  649. is
  650. .B \-
  651. then the rule applies in all years between
  652. .B FROM
  653. and
  654. .B TO
  655. inclusive;
  656. if
  657. .B TYPE
  658. is
  659. .BR uspres ,
  660. the rule applies in U.S. Presidential election years;
  661. if
  662. .B TYPE
  663. is
  664. .BR nonpres ,
  665. the rule applies in years other than U.S. Presidential election years.
  666. If
  667. .B TYPE
  668. is something else, then
  669. .I zic
  670. executes the command
  671. .ti +.5i
  672. \fByearistype\fP \fIyear\fP \fItype\fP
  673. .br
  674. to check the type of a year:
  675. an exit status of zero is taken to mean that the year is of the given type;
  676. an exit status of one is taken to mean that the year is not of the given type.
  677. .TP
  678. .B IN
  679. Names the month in which the rule takes effect.
  680. Month names may be abbreviated.
  681. .TP
  682. .B ON
  683. Gives the day on which the rule takes effect.
  684. Recognized forms include:
  685. .nf
  686. .in +.5i
  687. .sp
  688. .ta \w'Sun<=25\0\0'u
  689. 5    the fifth of the month
  690. lastSun    the last Sunday in the month
  691. lastMon    the last Monday in the month
  692. Sun>=8    first Sunday on or after the eighth
  693. Sun<=25    last Sunday on or before the 25th
  694. .fi
  695. .in -.5i
  696. .sp
  697. Names of days of the week may be abbreviated or spelled out in full.
  698. Note that there must be no spaces within the
  699. .B ON
  700. field.
  701. .TP
  702. .B AT
  703. Gives the time of day at which the rule takes effect.
  704. Recognized forms include:
  705. .nf
  706. .in +.5i
  707. .sp
  708. .ta \w'1:28:13\0\0'u
  709. 2    time in hours
  710. 2:00    time in hours and minutes
  711. 15:00    24-hour format time (for times after noon)
  712. 1:28:14    time in hours, minutes, and seconds
  713. .fi
  714. .in -.5i
  715. .sp
  716. Any of these forms may be followed by the letter
  717. .B w
  718. if the given time is local
  719. .q "wall clock"
  720. time or
  721. .B s
  722. if the given time is local
  723. .q standard
  724. time; in the absence of
  725. .B w
  726. or
  727. .BR s ,
  728. wall clock time is assumed.
  729. .TP
  730. .B SAVE
  731. Gives the amount of time to be added to local standard time when the rule is in
  732. effect.
  733. This field has the same format as the
  734. .B AT
  735. field
  736. (although, of course, the
  737. .B w
  738. and
  739. .B s
  740. suffixes are not used).
  741. .TP
  742. .B LETTER/S
  743. Gives the
  744. .q "variable part"
  745. (for example, the
  746. .q S
  747. or
  748. .q D
  749. in
  750. .q EST
  751. or
  752. .q EDT )
  753. of time zone abbreviations to be used when this rule is in effect.
  754. If this field is
  755. .BR \- ,
  756. the variable part is null.
  757. .PP
  758. A zone line has the form
  759. .sp
  760. .nf
  761. .ti +.5i
  762. .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
  763. Zone    NAME    GMTOFF    RULES/SAVE    FORMAT    [UNTIL]
  764. .sp
  765. For example:
  766. .sp
  767. .ti +.5i
  768. Zone    Australia/South\-west    9:30    Aus    CST    1987 Mar 15 2:00
  769. .sp
  770. .fi
  771. The fields that make up a zone line are:
  772. .TP "\w'GMTOFF'u"
  773. .B NAME
  774. The name of the time zone.
  775. This is the name used in creating the time conversion information file for the
  776. zone.
  777. .TP
  778. .B GMTOFF
  779. The amount of time to add to GMT to get standard time in this zone.
  780. This field has the same format as the
  781. .B AT
  782. and
  783. .B SAVE
  784. fields of rule lines;
  785. begin the field with a minus sign if time must be subtracted from GMT.
  786. .TP
  787. .B RULES/SAVE
  788. The name of the rule(s) that apply in the time zone or,
  789. alternately, an amount of time to add to local standard time.
  790. If this field is
  791. .B \-
  792. then standard time always applies in the time zone.
  793. .TP
  794. .B FORMAT
  795. The format for time zone abbreviations in this time zone.
  796. The pair of characters
  797. .B %s
  798. is used to show where the
  799. .q "variable part"
  800. of the time zone abbreviation goes.
  801. .TP
  802. .B UNTIL
  803. The time at which the GMT offset or the rule(s) change for a location.
  804. It is specified as a year, a month, a day, and a time of day.
  805. If this is specified,
  806. the time zone information is generated from the given GMT offset
  807. and rule change until the time specified.
  808. .IP
  809. The next line must be a
  810. .q continuation
  811. line; this has the same form as a zone line except that the
  812. string
  813. .q Zone
  814. and the name are omitted, as the continuation line will
  815. place information starting at the time specified as the
  816. .B UNTIL
  817. field in the previous line in the file used by the previous line.
  818. Continuation lines may contain an
  819. .B UNTIL
  820. field, just as zone lines do, indicating that the next line is a further
  821. continuation.
  822. .PP
  823. A link line has the form
  824. .sp
  825. .nf
  826. .ti +.5i
  827. .if t .ta \w'Link\0\0'u +\w'LINK-FROM\0\0'u
  828. .if n .ta \w'Link\0\0'u +\w'US/Eastern\0\0'u
  829. Link    LINK-FROM    LINK-TO
  830. .sp
  831. For example:
  832. .sp
  833. .ti +.5i
  834. Link    US/Eastern    EST5EDT
  835. .sp
  836. .fi
  837. The
  838. .B LINK-FROM
  839. field should appear as the
  840. .B NAME
  841. field in some zone line;
  842. the
  843. .B LINK-TO
  844. field is used as an alternate name for that zone.
  845. .PP
  846. Except for continuation lines,
  847. lines may appear in any order in the input.
  848. .PP
  849. Lines in the file that describes leap seconds have the following form:
  850. .nf
  851. .B
  852. .ti +.5i
  853. .ta \w'Leap\0\0'u +\w'YEAR\0\0'u +\w'MONTH\0\0'u +\w'DAY\0\0'u +\w'HH:MM:SS\0\0'u +\w'CORR\0\0'u
  854. Leap    YEAR    MONTH    DAY    HH:MM:SS    CORR    R/S
  855. .sp
  856. For example:
  857. .ti +.5i
  858. .sp
  859. Leap    1974    Dec    31    23:59:60    +    S
  860. .sp
  861. .fi
  862. The 
  863. .BR YEAR ,
  864. .BR MONTH ,
  865. .BR DAY ,
  866. and
  867. .B HH:MM:SS
  868. fields tell when the leap second happened.
  869. The
  870. .B CORR
  871. field
  872. should be
  873. .q +
  874. if a second was added
  875. or 
  876. .q -
  877. if a second was skipped.
  878. The
  879. .B R/S
  880. field
  881. should be (an abbreviaton of)
  882. .q Stationary
  883. if the leap second time given by the other fields should be interpreted as GMT
  884. or
  885. (an abbreviation of)
  886. .q Rolling
  887. if the leap second time given by the other fields should be interpreted as
  888. local wall clock time.
  889. .SH NOTE
  890. For areas with more than two types of local time,
  891. you may need to use local standard time in the
  892. .B AT
  893. field of the earliest transition time's rule to ensure that
  894. the earliest transition time recorded in the compiled file is correct.
  895. .SH FILES
  896. .ta \w'/etc/zoneinfo\0\0'u
  897. /etc/zoneinfo    standard directory used for created files
  898. leapseconds    default leap second information file
  899. .SH "SEE ALSO"
  900. newctime(3), tzfile(5), zdump(8)
  901. .. @(#)zic.8    4.1
  902. End of zic.8
  903. echo 'zdump.8' 1>&2
  904. cat >'zdump.8' <<'End of zdump.8'
  905. .TH ZDUMP 8
  906. .SH NAME
  907. zdump \- time zone dumper
  908. .SH SYNOPSIS
  909. .B zdump
  910. [
  911. .B \-v
  912. ] [
  913. .B \-c
  914. cutoffyear ] [ zonename ... ]
  915. .SH DESCRIPTION
  916. .I Zdump
  917. prints the current time in each
  918. .I zonename
  919. named on the command line.
  920. .PP
  921. These options are available:
  922. .TP
  923. .B \-v
  924. For each
  925. .I zonename
  926. on the command line,
  927. print the current time,
  928. the time at the lowest possible time value,
  929. the time one day after the lowest possible time value,
  930. the times both one second before and exactly at
  931. each time at which the rules for computing local time change,
  932. the times one second before and exactly at and one second after
  933. each leap second,
  934. the time at one day less than the highest possible time value,
  935. and the time at the highest possible time value,
  936. Each line ends with
  937. .B isdst=1
  938. if the given time is Daylight Saving Time or
  939. .B isdst=0
  940. otherwise.
  941. .TP
  942. .BI "\-c " cutoffyear
  943. Cut off the verbose output near the start of the given year.
  944. .SH FILES
  945. /etc/zoneinfo    standard zone information directory
  946. .SH "SEE ALSO"
  947. newctime(3), tzfile(5), zic(8)
  948. .. @(#)zdump.8    4.1
  949. End of zdump.8
  950. echo 'Makefile' 1>&2
  951. cat >'Makefile' <<'End of Makefile'
  952. # @(#)Makefile    4.1
  953.  
  954. # If you want something other than Eastern United States time used on your
  955. # system, change the line below (after finding the zone you want in the
  956. # time zone files, or adding it to a time zone file).
  957. # Alternately, if you discover you've got the wrong time zone, you can just
  958. #    zic -l rightzone
  959.  
  960. LOCALTIME=    US/Eastern
  961.  
  962. # Use an absolute path name for TZDIR unless you're just testing the software.
  963.  
  964. TZDIR=        /etc/zoneinfo
  965.  
  966. # You may want to change this define if you're just testing the software.
  967. # Alternatively, you can put these functions in /lib/libc.a, removing
  968. # the old "ctime.o" (and "timezone.o" on a BSD system).  This is the
  969. # ideal solution if you are able.  Build libz.a, extract the files, and
  970. # then add them to libc.a.
  971.  
  972. TZLIB=        /usr/lib/libz.a
  973.  
  974. # If you don't want leap second correction done, change "leapseconds" to
  975. # /dev/null below.
  976.  
  977. LEAPSECONDS=    leapseconds
  978.  
  979. # If you're running on a System V-style system and don't want lint grief,
  980. # add
  981. #    -DUSG
  982. # to the end of the "CFLAGS=" line.
  983. #
  984. # If you're running on a system where "strchr" is known as "index",
  985. # (for example, a 4.[012]BSD system), add
  986. #    -Dstrchr=index
  987. # to the end of the "CFLAGS=" line.
  988. #
  989. # If you want to use System V compatibility code, add
  990. #    -DUSG_COMPAT
  991. # to the end of the "CFLAGS=" line.
  992. #
  993. # If you want BSD compatibility code, add
  994. #    -DBSD_COMPAT
  995. # to the end of the "CFLAGS=" line.
  996. #
  997. # If you've used older versions of this software and want "tz_abbr"
  998. # compatibility code, add
  999. #    -DTZA_COMPAT
  1000. # to the end of the "CFLAGS=" line.
  1001. #
  1002. # If you'd like to use Robert Elz's additions to the "struct tm" structure,
  1003. # add a
  1004. #    -DKRE_COMPAT
  1005. # to the end of the "CFLAGS=" line, and add the structure elements
  1006. #    long    tm_gmtoff;
  1007. #    char *    tm_zone;
  1008. # to the END of the "struct tm" structure defined in "/usr/include/time.h".
  1009. #
  1010. # If you want code inspired by certain emerging standards, add
  1011. #    -DSTD_INSPIRED
  1012. # to the end of the "CFLAGS=" line.
  1013. #
  1014. # If you want Source Code Control System ID's left out of object modules, add
  1015. #    -DNOID
  1016. # to the end of the "CFLAGS=" line.
  1017. #
  1018. # If you'll never want to handle solar-time-based time zones, add
  1019. #    -DNOSOLAR
  1020. # to the end of the "CFLAGS=" line
  1021. # (and comment out the "SDATA=" line below).
  1022.  
  1023. CFLAGS=
  1024.  
  1025. # LINTFLAGS is set for 4.[123]BSD systems.
  1026. # If you're using System V, you'll want to comment out the "LINTFLAGS=" line.
  1027.  
  1028. LINTFLAGS=    -phbaaxc
  1029.  
  1030. SHAR=        shar
  1031.  
  1032. ################################################################################
  1033.  
  1034. CC=        cc -DTZDIR=\"$(TZDIR)\"
  1035.  
  1036. TZCSRCS=    zic.c localtime.c asctime.c \
  1037.         scheck.c ialloc.c emkdir.c getopt.c link.c
  1038. TZCOBJS=    zic.o localtime.o asctime.o \
  1039.         scheck.o ialloc.o emkdir.o getopt.o link.o
  1040. TZDSRCS=    zdump.c localtime.c asctime.c \
  1041.         ialloc.c getopt.c link.c
  1042. TZDOBJS=    zdump.o localtime.o asctime.o \
  1043.         ialloc.o getopt.o link.o
  1044. LIBSRCS=    localtime.c asctime.c ctime.c dysize.c timemk.c
  1045. LIBOBJS=    localtime.o asctime.o ctime.o dysize.o timemk.o
  1046. DOCS=        Patchlevel.h \
  1047.         README Theory \
  1048.         newctime.3 tzfile.5 zic.8 zdump.8 \
  1049.         Makefile Makefile.tc
  1050. SOURCES=    tzfile.h nonstd.h stdio.h stdlib.h time.h \
  1051.         zic.c zdump.c \
  1052.         localtime.c asctime.c ctime.c dysize.c timemk.c \
  1053.         scheck.c ialloc.c emkdir.c getopt.c link.c
  1054. YDATA=        africa antarctica asia australasia \
  1055.         europe northamerica southamerica pacificnew
  1056. NDATA=        systemv
  1057. SDATA=        solar87 solar88
  1058. DATA=        $(YDATA) $(NDATA) $(SDATA) leapseconds
  1059. ENCHILADA=    $(DOCS) $(SOURCES) $(DATA)
  1060.  
  1061. all:        REDID_BINARIES zdump $(TZLIB)
  1062.  
  1063. REDID_BINARIES:    zic $(DATA)
  1064.         ./zic -d $(TZDIR) -L $(LEAPSECONDS) $(YDATA)
  1065.         ./zic -d $(TZDIR) -L $(LEAPSECONDS) $(SDATA)
  1066.         ./zic -d $(TZDIR) -L /dev/null $(NDATA)
  1067.         ./zic -d $(TZDIR) -l $(LOCALTIME)
  1068.         touch $@
  1069.  
  1070. zdump:        $(TZDOBJS)
  1071.         $(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) -o $@
  1072.  
  1073. $(TZLIB):    $(LIBOBJS)
  1074.         ar ru $@ $(LIBOBJS)
  1075.         test -f /usr/bin/ranlib && ranlib $@
  1076.  
  1077. zic:        $(TZCOBJS)
  1078.         $(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) -o $@
  1079.  
  1080. SHARS:        SHAR1 SHAR2 SHAR3
  1081.  
  1082. SHAR1:        $(DOCS)
  1083.         $(SHAR) $(DOCS) > $@
  1084.  
  1085. SHAR2:        $(SOURCES)
  1086.         $(SHAR) $(SOURCES) > $@
  1087.  
  1088. SHAR3:        $(DATA)
  1089.         $(SHAR) $(DATA) > $@
  1090.  
  1091. tz.shar.Z.uue:    $(ENCHILADA)
  1092.         $(SHAR) $(ENCHILADA) | compress | uuencode tz.shar.Z > $@
  1093.  
  1094. $(ENCHILADA):
  1095.         sccs get $(REL) $(REV) $@
  1096.  
  1097. sure:        $(SOURCES)
  1098.         lint $(LINTFLAGS) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZCSRCS)
  1099.         lint $(LINTFLAGS) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZDSRCS)
  1100.         lint $(LINTFLAGS) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(LIBSRCS)
  1101.  
  1102. LINTUCB=    PATH=/usr/ucb:/bin:/usr/bin lint -phbaaxc
  1103. LINT5BIN=    PATH=/usr/5bin lint -phbaax
  1104.  
  1105. SURE:        sure
  1106.         $(LINTUCB) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZCSRCS)
  1107.         $(LINTUCB) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZDSRCS)
  1108.         $(LINTUCB) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(LIBSRCS)
  1109.         $(LINT5BIN) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZCSRCS)
  1110.         $(LINT5BIN) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(TZDSRCS)
  1111.         $(LINT5BIN) $(CFLAGS) -DTZDIR=\"$(TZDIR)\" $(LIBSRCS)
  1112.  
  1113. clean:
  1114.         rm -f core *.o *.out REDID_BINARIES zdump zic \
  1115.         SHAR* tz.shar.Z.uue ,*
  1116.  
  1117. CLEAN:        clean
  1118.         sccs clean
  1119.  
  1120. names:
  1121.         @echo $(ENCHILADA)
  1122.  
  1123. asctime.o:    nonstd.h stdio.h time.h tzfile.h
  1124. ctime.o:    nonstd.h time.h
  1125. dysize.o:    tzfile.h
  1126. emkdir.o:    nonstd.h stdlib.h
  1127. ialloc.o:    nonstd.h stdlib.h
  1128. link.o:        nonstd.h stdio.h
  1129. localtime.o:    nonstd.h stdio.h stdlib.h time.h tzfile.h
  1130. scheck.o:    nonstd.h stdio.h stdlib.h
  1131. timemk.o:    nonstd.h time.h tzfile.h
  1132. zdump.o:    nonstd.h stdio.h stdlib.h time.h tzfile.h
  1133. zic.o:        nonstd.h stdio.h stdlib.h time.h tzfile.h
  1134. End of Makefile
  1135. echo 'Makefile.tc' 1>&2
  1136. cat >'Makefile.tc' <<'End of Makefile.tc'
  1137. # @(#)Makefile.tc    4.1
  1138.  
  1139. # If you want something other than Eastern United States time used on your
  1140. # system, change the line below (after finding the zone you want in the
  1141. # time zone files, or adding it to a time zone file).
  1142. # Alternately, if you discover you've got the wrong time zone, you can just
  1143. #    zic -l rightzone
  1144.  
  1145. LOCALTIME=    US/Eastern
  1146.  
  1147. # Use an absolute path name for TZDIR unless you're just testing the software.
  1148. # Forward slashes, please!
  1149.  
  1150. TZDIR=        c:/etc/zoneinfo
  1151.  
  1152. # You may want to change this define if you're just testing the software.
  1153. # Backward slashes, please!
  1154.  
  1155. TZLIB=        c:\turboc\lib\z.lib
  1156.  
  1157. # If you don't want leap second correction done, change "leapseconds" to
  1158. # nul below.
  1159.  
  1160. LEAPSECONDS=    leapseconds
  1161.  
  1162. # If you want to use System V compatibility code, add
  1163. #    -DUSG_COMPAT
  1164. # to the end of the "CFLAGS=" line.
  1165. #
  1166. # If you want BSD compatibility code, add
  1167. #    -DBSD_COMPAT
  1168. # to the end of the "CFLAGS=" line.
  1169. #
  1170. # If you'd like to use Robert Elz's additions to the "struct tm" structure,
  1171. # add a
  1172. #    -DKRE_COMPAT
  1173. # to the end of the "CFLAGS=" line, and add the structure elements
  1174. #    long    tm_gmtoff;
  1175. #    char *    tm_zone;
  1176. # to the END of the "struct tm" structure defined in <time.h>.
  1177. #
  1178. # If you want code inspired by certain emerging standards, add
  1179. #    -DSTD_INSPIRED
  1180. # to the end of the "CFLAGS=" line.
  1181. #
  1182. # If you want Source Code Control System ID's left out of object modules, add
  1183. #    -DNOID
  1184. # to the end of the "CFLAGS=" line.
  1185. #
  1186. # If you'll never want to handle solar-time-based time zones, add
  1187. #    -DNOSOLAR
  1188. # to the end of the "CFLAGS=" line
  1189. # (and comment out the "SDATA=" line below).
  1190.  
  1191. CFLAGS=
  1192.  
  1193. ################################################################################
  1194.  
  1195. # Need -mc so solar87 and solar88 can be handled.
  1196. # Need -A to get __STDC__ defined (and PC-specific nonsense dispensed with).
  1197.  
  1198. CC=        tcc -DTZDIR="$(TZDIR)" -mc -A
  1199.  
  1200. TZCSRCS=    zic.c localtime.c asctime.c \
  1201.         scheck.c ialloc.c emkdir.c getopt.c link.c
  1202. TZCOBJS=    zic.obj localtime.obj asctime.obj \
  1203.         scheck.obj ialloc.obj emkdir.obj getopt.obj link.obj
  1204. TZDSRCS=    zdump.c localtime.c asctime.c \
  1205.         ialloc.c getopt.c link.c
  1206. TZDOBJS=    zdump.obj localtime.obj asctime.obj \
  1207.         ialloc.obj getopt.obj link.obj
  1208. LIBSRCS=    localtime.c asctime.c ctime.c dysize.c timemk.c
  1209. LIBOBJS=    localtime.obj asctime.obj ctime.obj dysize.obj timemk.obj
  1210. YDATA=        africa antarctica asia australasia \
  1211.         europe northamerica southamerica pacificnew
  1212. NDATA=        systemv
  1213. SDATA=        solar87 solar88
  1214. DATA=        $(YDATA) $(NDATA) $(SDATA) leapseconds
  1215.  
  1216. all:        REDID_BINARIES zdump.exe $(TZLIB)
  1217.  
  1218. REDID_BINARIES:    zic.exe $(DATA)
  1219.         zic -d $(TZDIR) -L $(LEAPSECONDS) $(YDATA)
  1220.         zic -d $(TZDIR) -L $(LEAPSECONDS) $(SDATA)
  1221.         zic -d $(TZDIR) -L nul $(NDATA)
  1222.         zic -d $(TZDIR) -l $(LOCALTIME)
  1223.         copy Makefile $<
  1224.         touch $<
  1225.  
  1226. zdump.exe:    $(TZDOBJS)
  1227.         $(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS)
  1228.  
  1229. $(TZLIB):    z.lib
  1230.         copy z.lib $<
  1231.  
  1232. z.lib:        $(LIBOBJS)
  1233.         copy nul $<
  1234.         command /c for %i in ($(LIBOBJS)) do tlib $< +%i
  1235.  
  1236. zic.exe:    $(TZCOBJS)
  1237.         $(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS)
  1238.  
  1239. clean:
  1240.         command /c for %i in (obj exe lib bak) do \
  1241.             if exist *.%i del *.%i
  1242.         command /c if exist REDID_BINARIES do del REDID_BINARIES
  1243.  
  1244. .c.obj:
  1245.         $(CC) -c $(CFLAGS) $*
  1246.  
  1247. asctime.obj:    nonstd.h stdio.h time.h tzfile.h
  1248. ctime.obj:    nonstd.h time.h
  1249. dysize.obj:    tzfile.h
  1250. emkdir.obj:    nonstd.h stdlib.h
  1251. ialloc.obj:    nonstd.h stdlib.h
  1252. link.obj:    nonstd.h stdio.h
  1253. localtime.obj:    nonstd.h stdio.h stdlib.h time.h tzfile.h
  1254. scheck.obj:    nonstd.h stdio.h stdlib.h
  1255. timemk.obj:    nonstd.h time.h tzfile.h
  1256. zdump.obj:    nonstd.h stdio.h stdlib.h time.h tzfile.h
  1257. zic.obj:    nonstd.h stdio.h stdlib.h time.h tzfile.h
  1258. End of Makefile.tc
  1259. exit
  1260.  
  1261.