home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / localtime3 / part01 next >
Text File  |  1989-04-19  |  47KB  |  1,649 lines

  1. Subject:  v18i111:  Table-driven ctime/time/localtime/date package, Part01/07
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by:  ado@ncifcrf.gov
  7. Posting-number: Volume 18, Issue 111
  8. Archive-name: localtime3/part01
  9.  
  10. : To unbundle, sh this file
  11. echo file 'Patchlevel.h' >&2
  12. cat >'Patchlevel.h' <<'End of Patchlevel.h'
  13. /* @(#)Patchlevel.h    7.1 */
  14.  
  15. #define PATCHLEVEL 1
  16. End of Patchlevel.h
  17. echo file 'README' >&2
  18. cat >'README' <<'End of README'
  19. @(#)README    7.1
  20.  
  21. "What time is it?" -- Richard Deacon as The King
  22. "Any time you want it to be." -- Frank Baxter as The Scientist
  23.                     (from the Bell System film on time)
  24.  
  25. This 1989 update of the time zone package features
  26.  
  27. *    POSIXization (including interpretation of POSIX-style TZ environment
  28.     variables, provided by Guy Harris),
  29. *    ANSIfication (including versions of "mktime" and "difftime"),
  30. *    SVIDulation (an "altzone" variable)
  31. *    MACHination (the "gtime" function)
  32. *    corrections to some time zone data (including corrections to the rules
  33.     for Great Britain and New Zealand)
  34. *    reference data from the United States Naval Observatory for folks who
  35.     want to do additional time zones
  36. *    and the 1989 data for Saudi Arabia.
  37.  
  38. (Since this code will be treated as "part of the implementation" in some places
  39. and as "part of the application" in others, there's no good way to name
  40. functions, such as timegm, that are not part of the proposed ANSI C standard;
  41. such functions have kept their old, underscore-free names in this update.)
  42.  
  43. Support for the tz_abbr variable has been eliminated from this version
  44. (to forestall "kitchen sink" complaints from certain quarters :-).
  45.  
  46. Support for Turbo C compilation has also been eliminated; it was present to
  47. allow checking in an ANSI-style environment, and such checking is now done with
  48. gcc.
  49.  
  50. And the "dysize" function has disappeared; it was present to allow compilation
  51. of the "date" command on old BSD systems, and a version of "date" is now
  52. provided in the package.  The "date" command is not created when you "make all"
  53. since it may lack options provided by the version distributed with your
  54. operating system, or may not interact with the system in the same way the
  55. native version does.
  56.  
  57. Since POSIX frowns on correct leap second handling, the default behavior of
  58. the "zic" command (in the absence of a "-L" option) has been changed to omit
  59. leap second information from its output files.
  60.  
  61. Please send comments or information to ado@ncifcrf.gov.
  62.  
  63. Be sure to read the comments in "Makefile" and make any changes
  64. needed to make things right for your system.
  65.  
  66. To use the new functions, use a "-lz" option when compiling or linking.
  67.  
  68. Historical local time information has been included here not because it
  69. is particularly useful, but rather to:
  70.  
  71. *    give an idea of the variety of local time rules that have
  72.     existed in the past and thus an idea of the variety that may be
  73.     expected in the future;
  74.  
  75. *    provide a test of the generality of the local time rule description
  76.     system.
  77.  
  78. The information in the time zone data files is by no means authoritative;
  79. if you know that the rules are different from those in a file, by all means
  80. feel free to change file (and please send the changed version to
  81. ado@ncifcrf.gov for use in the future).  Europeans take note!
  82.  
  83. Thanks to these Timezone Caballeros who've made major contributions to the
  84. time conversion package:  Keith Bostic; Bob Devine; Robert Elz; Guy Harris;
  85. Mark Horton; John Mackin; and Bradley White.  Thanks also to Michael Bloom,
  86. Art Neilson, Stephen Prince, John Sovereign, and Frank Wales for testing work.
  87. None of them are responsible for remaining errors.
  88. End of README
  89. echo file 'Theory' >&2
  90. cat >'Theory' <<'End of Theory'
  91. @(#)Theory    7.1
  92.  
  93. These time and date functions are much like the System V Release 2.0 (SVR2)
  94. time and date functions; there are a few additions and changes to extend
  95. the usefulness of the SVR2 functions:
  96.  
  97. *    In SVR2, time display in a process is controlled by the environment
  98.     variable TZ, which "must be a three-letter time zone name, followed
  99.     by a number representing the difference between local time and
  100.     Greenwich Mean Time in hours, followed by an optional three-letter
  101.     name for a daylight time zone;" when the optional daylight time zone is
  102.     present, "standard U.S.A. Daylight Savings Time conversion is applied."
  103.     This means that SVR2 can't deal with other (for example, Australian)
  104.     daylight savings time rules, or situations where more than two
  105.     time zone abbreviations are used in an area.
  106.  
  107. *    In SVR2, time conversion information is compiled into each program
  108.     that does time conversion.  This means that when time conversion
  109.     rules change (as in the United States in 1987), all programs that
  110.     do time conversion must be recompiled to ensure proper results.
  111.  
  112. *    In SVR2, time conversion fails for near-minimum or near-maximum
  113.     time_t values when doing conversions for places that don't use GMT.
  114.  
  115. *    In SVR2, there's no tamper-proof way for a process to learn the
  116.     system's best idea of local wall clock.  (This is important for
  117.     applications that an administrator wants used only at certain times--
  118.     without regard to whether the user has fiddled the "TZ" environment
  119.     variable.  While an administrator can "do everything in GMT" to get
  120.     around the problem, doing so is inconvenient and precludes handling
  121.     daylight savings time shifts--as might be required to limit phone
  122.     calls to off-peak hours.)
  123.  
  124. *    These functions can account for leap seconds, thanks to Bradley White
  125.     (bww@k.cs.cmu.edu).
  126.  
  127. These are the changes that have been made to the SVR2 functions:
  128.  
  129. *    The "TZ" environment variable is used in generating the name of a file
  130.     from which time zone information is read (or is interpreted a la
  131.     POSIX); "TZ" is no longer constrained to be a three-letter time zone
  132.     name followed by a number of hours and an optional three-letter
  133.     daylight time zone name.  The daylight saving time rules to be used
  134.     for a particular time zone are encoded in the time zone file;
  135.     the format of the file allows U.S., Australian, and other rules to be
  136.     encoded, and allows for situations where more than two time zone
  137.     abbreviations are used.
  138.  
  139.     It was recognized that allowing the "TZ" environment variable to
  140.     take on values such as "US/Eastern" might cause "old" programs
  141.     (that expect "TZ" to have a certain form) to operate incorrectly;
  142.     consideration was given to using some other environment variable
  143.     (for example, "TIMEZONE") to hold the string used to generate the
  144.     time zone information file name.  In the end, however, it was decided
  145.     to continue using "TZ":  it is widely used for time zone purposes;
  146.     separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance;
  147.     and systems where "new" forms of "TZ" might cause problems can simply
  148.     use TZ values such as "EST5EDT" which can be used both by
  149.     "new" programs (a la POSIX) and "old" programs (as zone names and
  150.     offsets).
  151.  
  152. *    To handle places where more than two time zone abbreviations are used,
  153.     the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst]
  154.     (where "tmp" is the value the function returns) to the time zone
  155.     abbreviation to be used.  This differs from SVR2, where the elements
  156.     of tzname are only changed as a result of calls to tzset.
  157.  
  158. *    Since the "TZ" environment variable can now be used to control time
  159.     conversion, the "daylight" and "timezone" variables are no longer
  160.     needed or supported.  (You can use a compile-time option to cause
  161.     these variables to be defined and to be set by "tzset"; however, their
  162.     values will not be used by "localtime.")
  163.  
  164. *    The "localtime" function has been set up to deliver correct results
  165.     for near-minimum or near-maximum time_t values.  (A comment in the
  166.     source code tells how to get compatibly wrong results).
  167.  
  168. *    A function "tzsetwall" has been added to arrange for the system's
  169.     best approximation to local wall clock time to be delivered by
  170.     subsequent calls to "localtime."  Source code for portable
  171.     applications that "must" run on local wall clock time should call
  172.     "tzsetwall();" if such code is moved to "old" systems that don't provide
  173.     tzsetwall, you won't be able to generate an executable program.
  174.     (These time zone functions also arrange for local wall clock time to be
  175.     used if tzset is called--directly or indirectly--and there's no "TZ"
  176.     environment variable; portable applications should not, however, rely
  177.     on this behavior since it's not the way SVR2 systems behave.)
  178.  
  179. Points of interest to folks with Version 7 or BSD systems:
  180.  
  181. *    The BSD "timezone" function is not present in this package;
  182.     it's impossible to reliably map timezone's arguments (a "minutes west
  183.     of GMT" value and a "daylight saving time in effect" flag) to a
  184.     time zone abbreviation, and we refuse to guess.
  185.     Programs that in the past used the timezone function may now examine
  186.     tzname[localtime(&clock)->tm_isdst] to learn the correct time
  187.     zone abbreviation to use.  Alternatively, use localtime(&clock)->tm_zone
  188.     if this has been enabled.
  189.  
  190. *    The BSD gettimeofday function is not used in this package;
  191.     this lets users control the time zone used in doing time conversions.
  192.     Users who don't try to control things (that is, users who do not set
  193.     the environment variable TZ) get the time conversion specified in the
  194.     file "/etc/zoneinfo/localtime"; see the time zone compiler writeup for
  195.     information on how to initialize this file.
  196.  
  197. The functions that are conditionally compiled if STD_INSPIRED is defined should,
  198. at this point, be looked on primarily as food for thought.  They are not in
  199. any sense "standard compatible"--some are not, in fact, specified in *any*
  200. standard.  They do, however, represent responses of various authors to
  201. standardization proposals.
  202.  
  203. Other time conversion proposals, in particular the one developed by folks at
  204. Hewlett Packard, offer a wider selection of functions that provide capabilities
  205. beyond those provided here.  The absence of such functions from this package
  206. is not meant to discourage the development, standardization, or use of such
  207. functions.  Rather, their absence reflects the decision to make this package
  208. close to SVR2 (with the exceptions outlined above) to ensure its broad
  209. acceptability.  If more powerful time conversion functions can be standardized,
  210. so much the better.
  211. End of Theory
  212. echo file 'newctime.3' >&2
  213. cat >'newctime.3' <<'End of newctime.3'
  214. .TH NEWCTIME 3
  215. .SH NAME
  216. asctime, ctime, difftime, gmtime, localtime, mktime, tzset \- convert date and time to ASCII
  217. .SH SYNOPSIS
  218. .nf
  219. .B extern char *tzname[2];
  220. .PP
  221. .B void tzset()
  222. .PP
  223. .B #include <sys/types.h>
  224. .PP
  225. .B char *ctime(clock)
  226. .B time_t *clock;
  227. .PP
  228. .B double difftime(time1, time0)
  229. .B time_t time1;
  230. .B time_t time0;
  231. .PP
  232. .B #include <time.h>
  233. .PP
  234. .B char *asctime(tm)
  235. .B struct tm *tm;
  236. .PP
  237. .B struct tm *localtime(clock)
  238. .B long *clock;
  239. .PP
  240. .B struct tm *gmtime(clock)
  241. .B long *clock;
  242. .PP
  243. .B time_t mktime(tm)
  244. .B struct tm *tm;
  245. .PP
  246. .B cc ... -lz
  247. .fi
  248. .SH DESCRIPTION
  249. .I Tzset
  250. uses the value of the environment variable
  251. .B TZ
  252. to set time conversion information used by
  253. .IR localtime .
  254. If
  255. .B TZ
  256. does not appear in the environment,
  257. the best available approximation to local wall clock time, as specified
  258. by the
  259. .IR tzfile (5)-format
  260. file
  261. .B localtime
  262. in the system time conversion information directory, is used by
  263. .IR localtime .
  264. If
  265. .B TZ
  266. appears in the environment but its value is a null string,
  267. Coordinated Universal Time (UTC) is used (without leap second
  268. correction).  If
  269. .B TZ
  270. appears in the environment and its value is not a null string:
  271. .IP
  272. if the value begins with a colon, it is used as a pathname of a file
  273. from which to read the time conversion information;
  274. .IP
  275. if the value does not begin with a colon, it is first used as the
  276. pathname of a file from which to read the time conversion information,
  277. and, if that file cannot be read, is used directly as a specification of
  278. the time conversion information.
  279. .PP
  280. When
  281. .B TZ
  282. is used as a pathname, if it begins with a slash,
  283. it is used as an absolute pathname; otherwise,
  284. it is used as a pathname relative to a system time conversion information
  285. directory.
  286. The file must be in the format specified in
  287. .IR tzfile (5).
  288. .PP
  289. When
  290. .B TZ
  291. is used directly as a specification of the time conversion information,
  292. it must have the following syntax (spaces inserted for clarity):
  293. .IP
  294. \fIstd\|offset\fR[\fIdst\fR[\fIoffset\fR][\fB,\fIrule\fR]]
  295. .PP
  296. Where:
  297. .RS
  298. .TP 15
  299. .IR std " and " dst
  300. Three or more bytes that are the designation for the standard
  301. .RI ( std )
  302. or summer
  303. .RI ( dst )
  304. time zone.  Only
  305. .I std
  306. is required; if
  307. .I dst
  308. is missing, then summer time does not apply in this locale.
  309. Upper- and lowercase letters are explicitly allowed.  Any characters
  310. except a leading colon
  311. .RB ( : ),
  312. digits, comma
  313. .RB ( , ),
  314. minus
  315. .RB ( \(mi ),
  316. plus
  317. .RB ( \(pl ),
  318. and ASCII NUL are allowed.
  319. .TP
  320. .I offset
  321. Indicates the value one must add to the local time to arrive at
  322. Coordinated Universal Time.  The
  323. .I offset
  324. has the form:
  325. .RS
  326. .IP
  327. \fIhh\fR[\fB:\fImm\fR[\fB:\fIss\fR]]
  328. .RE
  329. .IP
  330. The minutes
  331. .RI ( mm )
  332. and seconds
  333. .RI ( ss )
  334. are optional.  The hour
  335. .RI ( hh )
  336. is required and may be a single digit.  The
  337. .I offset
  338. following
  339. .I std
  340. is required.  If no
  341. .I offset
  342. follows
  343. .IR dst ,
  344. summer time is assumed to be one hour ahead of standard time.  One or
  345. more digits may be used; the value is always interpreted as a decimal
  346. number.  The hour must be between zero and 24, and the minutes (and
  347. seconds) \(em if present \(em between zero and 59.  If preceded by a
  348. .RB `` \(mi '',
  349. the time zone shall be east of the Prime Meridian; otherwise it shall be
  350. west (which may be indicated by an optional preceding
  351. .RB `` \(pl '').
  352. .TP
  353. .I rule
  354. Indicates when to change to and back from summer time.  The
  355. .I rule
  356. has the form:
  357. .RS
  358. .IP
  359. \fIdate\fB/\fItime\fB,\fIdate\fB/\fItime\fR
  360. .RE
  361. .IP
  362. where the first
  363. .I date
  364. describes when the change from standard to summer time occurs and the
  365. second
  366. .I date
  367. describes when the change back happens.  Each
  368. .I time
  369. field describes when, in current local time, the change to the other
  370. time is made.
  371. .IP
  372. The format of
  373. .I date
  374. is one of the following:
  375. .RS
  376. .TP 10
  377. .BI J n
  378. The Julian day
  379. .I n
  380. .RI "(1\ \(<=" "\ n\ " "\(<=\ 365).
  381. Leap days are not counted; that is, in all years \(em including leap
  382. years \(em February 28 is day 59 and March 1 is day 60.  It is
  383. impossible to explicitly refer to the occasional February 29.
  384. .TP
  385. .I n
  386. The zero-based Julian day
  387. .RI "(0\ \(<=" "\ n\ " "\(<=\ 365).
  388. Leap days are counted, and it is possible to refer to February 29.
  389. .TP
  390. .BI M m . n . d
  391. The
  392. .IR d' th
  393. day
  394. .RI "(0\ \(<=" "\ d\ " "\(<=\ 6)
  395. of week
  396. .I n
  397. of month
  398. .I m
  399. of the year
  400. .RI "(1\ \(<=" "\ n\ " "\(<=\ 5,
  401. .RI "1\ \(<=" "\ m\ " "\(<=\ 12,
  402. where week 5 means ``the last
  403. .I d
  404. day in month
  405. .IR m ''
  406. which may occur in either the fourth or the fifth week).  Week 1 is the
  407. first week in which the
  408. .IR d' th
  409. day occurs.  Day zero is Sunday.
  410. .RE
  411. .IP "" 15
  412. The
  413. .I time
  414. has the same format as
  415. .I offset
  416. except that no leading sign
  417. .RB (`` \(mi ''
  418. or
  419. .RB `` \(pl '')
  420. is allowed.  The default, if
  421. .I time
  422. is not given, is
  423. .BR 02:00:00 .
  424. .RE
  425. .LP
  426. If no
  427. .I rule
  428. is present in
  429. .BR TZ ,
  430. the rules specified
  431. by the
  432. .IR tzfile (5)-format
  433. file
  434. .B posixrules
  435. in the system time conversion information directory are used, with the
  436. standard and summer time offsets from UTC replaced by those specified by
  437. the
  438. .I offset
  439. values in
  440. .BR TZ .
  441. .PP
  442. For compatibility with System V Release 3.1, a semicolon
  443. .RB ( ; )
  444. may be used to separate the
  445. .I rule
  446. from the rest of the specification.
  447. .PP
  448. If the
  449. .B TZ
  450. environment variable does not specify a
  451. .IR tzfile (5)-format
  452. and cannot be interpreted as a direct specification,
  453. UTC is used with the standard time abbreviation set to
  454. the value of the
  455. .B TZ
  456. environment variable
  457. (or to the leading characters of its value if it is lengthy).
  458. .PP
  459. .I Ctime\^
  460. converts a long integer, pointed to by
  461. .IR clock ,
  462. representing the time in seconds since
  463. 00:00:00 UTC, January 1, 1970,
  464. and returns a pointer to a
  465. 26-character string
  466. of the form
  467. .br
  468. .ce
  469. .eo
  470. Thu Nov 24 18:22:48 1986\n\0
  471. .ec
  472. .br
  473. All the fields have constant width.
  474. .PP
  475. .IR Localtime\^
  476. and
  477. .I gmtime\^
  478. return pointers to ``tm'' structures, described below.
  479. .I Localtime\^
  480. corrects for the time zone and any time zone adjustments
  481. (such as Daylight Saving Time in the U.S.A.).
  482. Before doing so,
  483. .I localtime\^
  484. calls
  485. .I tzset\^
  486. (if
  487. .I tzset\^
  488. has not been called in the current process).
  489. After filling in the ``tm'' structure,
  490. .I localtime
  491. sets the
  492. .BR tm_isdst 'th
  493. element of
  494. .B tzname
  495. to a pointer to an
  496. ASCII string that's the time zone abbreviation to be used with
  497. .IR localtime 's
  498. return value.
  499. .PP
  500. .I Gmtime\^
  501. converts to Coordinated Universal Time.
  502. .PP
  503. .I Asctime\^
  504. converts a time value contained in a
  505. ``tm'' structure to a 26-character string,
  506. as shown in the above example,
  507. and returns a pointer
  508. to the string.
  509. .PP
  510. .I Mktime\^
  511. converts the broken-down time,
  512. expressed as local time,
  513. in the structure pointed to by
  514. .I tm
  515. into a calendar time value with the same encoding as that of the values
  516. returned by the
  517. .I time
  518. function.
  519. The original values of the
  520. .B tm_wday
  521. and
  522. .B tm_yday
  523. components of the structure are ignored,
  524. and the original values of the other components are not restricted
  525. to their normal ranges.
  526. (A positive or zero value for
  527. .B tm_isdst
  528. causes
  529. .I mktime
  530. to presume initially that summer time (for example, Daylight Saving Time
  531. in the U.S.A.)
  532. respectively,
  533. is or is not in effect for the specified time.
  534. A negative value for
  535. .B tm_isdst
  536. causes the
  537. .I mktime
  538. function to attempt to divine whether summer time is in effect
  539. for the specified time.)
  540. On successful completion, the values of the
  541. .B tm_wday
  542. and
  543. .B tm_yday
  544. components of the structure are set appropriately,
  545. and the other components are set to represent the specified calendar time,
  546. but with their values forced to their normal ranges; the final value of
  547. .B tm_mday
  548. is not set until
  549. .B tm_mon
  550. and
  551. .B tm_year
  552. are determined.
  553. .I Mktime\^
  554. returns the specified calendar time;
  555. If the calendar time cannot be represented,
  556. it returns
  557. .BR -1 .
  558. .PP
  559. .I Difftime\^
  560. returns the difference between two calendar times,
  561. .I time1
  562. -
  563. .IR time0,
  564. expressed in seconds.
  565. .PP
  566. Declarations of all the functions and externals, and the ``tm'' structure,
  567. are in the
  568. .B <time.h>\^
  569. header file.
  570. The structure (of type)
  571. .B struct tm
  572. includes the following fields:
  573. .RS
  574. .PP
  575. .nf
  576. .ta .5i +\w'long tm_gmtoff;\0\0'u
  577.     int tm_sec;    /\(** seconds (0 - 60) \(**/
  578.     int tm_min;    /\(** minutes (0 - 59) \(**/
  579.     int tm_hour;    /\(** hours (0 - 23) \(**/
  580.     int tm_mday;    /\(** day of month (1 - 31) \(**/
  581.     int tm_mon;    /\(** month of year (0 - 11) \(**/
  582.     int tm_year;    /\(** year \- 1900 \(**/
  583.     int tm_wday;    /\(** day of week (Sunday = 0) \(**/
  584.     int tm_yday;    /\(** day of year (0 - 365) \(**/
  585.     int tm_isdst;    /\(** is summer time in effect? \(**/
  586.     char \(**tm_zone;    /\(** abbreviation of timezone name \(**/
  587.     long tm_gmtoff;    /\(** offset from UTC in seconds \(**/
  588. .fi
  589. .RE
  590. .PP
  591. The
  592. .I tm_zone
  593. and
  594. .I tm_gmtoff
  595. fields exist, and are filled in, only if arrangements to do
  596. so were made when the library containing these functions was
  597. created.
  598. There is no guarantee that these fields will continue to exist
  599. in this form in future releases of this code.
  600. .PP
  601. .I Tm_isdst\^
  602. is non-zero if summer time is in effect.
  603. .PP
  604. .I Tm_gmtoff
  605. is the offset (in seconds) of the time represented
  606. from UTC, with positive values indicating east
  607. of the Prime Meridian.
  608. .SH FILES
  609. .ta \w'/usr/local/etc/zoneinfo/posixrules\0\0'u
  610. /usr/local/etc/zoneinfo    time zone information directory
  611. .br
  612. /usr/local/etc/zoneinfo/localtime    local time zone file
  613. .br
  614. /usr/local/etc/zoneinfo/posixrules    used with POSIX-style TZ's
  615. .br
  616. /usr/local/etc/zoneinfo/GMT    for UTC leap seconds
  617. .sp
  618. If
  619. .B /usr/local/etc/zoneinfo/GMT
  620. is absent,
  621. UTC leap seconds are loaded from
  622. .BR /usr/local/etc/zoneinfo/posixrules .
  623. .SH SEE ALSO
  624. tzfile(5),
  625. getenv(3),
  626. time(2)
  627. .SH NOTES
  628. The return values point to static data
  629. whose content is overwritten by each call.
  630. The
  631. .B tm_zone
  632. field of a returned
  633. .B "struct tm"
  634. points to a static array of characters, which
  635. will also be overwritten at the next call
  636. (and by calls to
  637. .IR tzset ).
  638. .PP
  639. Avoid using out-of-range values with
  640. .I mktime
  641. when setting up lunch with promptness sticklers in Riyadh.
  642. .. @(#)newctime.3    7.1
  643. End of newctime.3
  644. echo file 'tzfile.5' >&2
  645. cat >'tzfile.5' <<'End of tzfile.5'
  646. .TH TZFILE 5
  647. .SH NAME
  648. tzfile \- time zone information
  649. .SH SYNOPSIS
  650. .B
  651. #include <tzfile.h>
  652. .SH DESCRIPTION
  653. The time zone information files used by
  654. .IR tzset (3)
  655. begin with bytes reserved for future use,
  656. followed by four four-byte values of type
  657. .BR long ,
  658. written in a ``standard'' byte order
  659. (the high-order byte of the value is written first).
  660. These values are,
  661. in order:
  662. .TP
  663. .I tzh_ttisstdcnt
  664. The number of standard/wall indicators stored in the file.
  665. .TP
  666. .I tzh_leapcnt
  667. The number of leap seconds for which data is stored in the file.
  668. .TP
  669. .I tzh_timecnt
  670. The number of "transition times" for which data is stored
  671. in the file.
  672. .TP
  673. .I tzh_typecnt
  674. The number of "local time types" for which data is stored
  675. in the file (must not be zero).
  676. .TP
  677. .I tzh_charcnt
  678. The number of characters of "time zone abbreviation strings"
  679. stored in the file.
  680. .PP
  681. The above header is followed by
  682. .I tzh_timecnt
  683. four-byte values of type
  684. .BR long ,
  685. sorted in ascending order.
  686. These values are written in ``standard'' byte order.
  687. Each is used as a transition time (as returned by
  688. .IR time (2))
  689. at which the rules for computing local time change.
  690. Next come
  691. .I tzh_timecnt
  692. one-byte values of type
  693. .BR "unsigned char" ;
  694. each one tells which of the different types of ``local time'' types
  695. described in the file is associated with the same-indexed transition time.
  696. These values serve as indices into an array of
  697. .I ttinfo
  698. structures that appears next in the file;
  699. these structures are defined as follows:
  700. .in +.5i
  701. .sp
  702. .nf
  703. .ta .5i +\w'unsigned int\0\0'u
  704. struct ttinfo {
  705.     long    tt_gmtoff;
  706.     int    tt_isdst;
  707.     unsigned int    tt_abbrind;
  708. };
  709. .in -.5i
  710. .fi
  711. .sp
  712. Each structure is written as a four-byte value for
  713. .I tt_gmtoff
  714. of type
  715. .BR long ,
  716. in a standard byte order, followed by a one-byte value for
  717. .I tt_isdst
  718. and a one-byte value for
  719. .IR tt_abbrind .
  720. In each structure,
  721. .I tt_gmtoff
  722. gives the number of seconds to be added to GMT,
  723. .I tt_isdst
  724. tells whether
  725. .I tm_isdst
  726. should be set by
  727. .I localtime (3)
  728. and
  729. .I tt_abbrind
  730. serves as an index into the array of time zone abbreviation characters
  731. that follow the
  732. .I ttinfo
  733. structure(s) in the file.
  734. .PP
  735. Then there are
  736. .I tzh_leapcnt
  737. pairs of four-byte values, written in standard byte order;
  738. the first value of each pair gives the time
  739. (as returned by
  740. .IR time(2))
  741. at which a leap second occurs;
  742. the second gives the
  743. .I total
  744. number of leap seconds to be applied after the given time.
  745. The pairs of values are sorted in ascending order by time.
  746. .PP
  747. Finally there are
  748. .I tzh_ttisstdcnt
  749. standard/wall indicators, each stored as a one-byte value;
  750. they tell whether the transition times associated with local time types
  751. were specified as standard time or wall clock time,
  752. and are used when a time zone file is used in handling POSIX-style
  753. time zone environment variables.
  754. .PP
  755. .I Localtime
  756. uses the first standard-time
  757. .I ttinfo
  758. structure in the file
  759. (or simply the first
  760. .I ttinfo
  761. structure in the absence of a standard-time structure)
  762. if either
  763. .I tzh_timecnt
  764. is zero or the time argument is less than the first transition time recorded
  765. in the file.
  766. .SH SEE ALSO
  767. newctime(3)
  768. .. @(#)tzfile.5    7.1
  769. End of tzfile.5
  770. echo file 'zic.8' >&2
  771. cat >'zic.8' <<'End of zic.8'
  772. .TH ZIC 8
  773. .SH NAME
  774. zic \- time zone compiler
  775. .SH SYNOPSIS
  776. .B zic
  777. [
  778. .B \-v
  779. ] [
  780. .B \-d
  781. .I directory
  782. ] [
  783. .B \-l
  784. .I localtime
  785. ] [
  786. .B \-p
  787. .I posixrules
  788. ] [
  789. .B \-L
  790. .I leapsecondfilename
  791. ] [
  792. .B \-s
  793. ] [
  794. .I filename
  795. \&... ]
  796. .SH DESCRIPTION
  797. .if t .ds lq ``
  798. .if t .ds rq ''
  799. .if n .ds lq \&"\"
  800. .if n .ds rq \&"\"
  801. .de q
  802. \\$3\*(lq\\$1\*(rq\\$2
  803. ..
  804. .I Zic
  805. reads text from the file(s) named on the command line
  806. and creates the time conversion information files specified in this input.
  807. If a
  808. .I filename
  809. is
  810. .BR \- ,
  811. the standard input is read.
  812. .PP
  813. These options are available:
  814. .TP
  815. .BI "\-d " directory
  816. Create time conversion information files in the named directory rather than
  817. in the standard directory named below.
  818. .TP
  819. .BI "\-l " timezone
  820. Use the given time zone as local time.
  821. .I Zic
  822. will act as if the input contained a link line of the form
  823. .sp
  824. .ti +.5i
  825. Link    \fItimezone\fP        localtime
  826. .TP
  827. .BI "\-p " timezone
  828. Use the given time zone's rules when handling POSIX-format
  829. time zone environment variables.
  830. .I Zic
  831. will act as if the input contained a link line of the form
  832. .sp
  833. .ti +.5i
  834. Link    \fItimezone\fP        posixrules
  835. .TP
  836. .BI "\-L " leapsecondfilename
  837. Read leap second information from the file with the given name.
  838. If this option is not used,
  839. no leap second information appears in output files.
  840. .TP
  841. .B \-v
  842. Complain if a year that appears in a data file is outside the range
  843. of years representable by
  844. .IR time (2)
  845. values.
  846. .TP
  847. .B \-s
  848. Limit time values stored in output files to values that are the same
  849. whether they're taken to be signed or unsigned.
  850. You can use this option to generate SVVS-compatible files.
  851. .sp
  852. Input lines are made up of fields.
  853. Fields are separated from one another by any number of white space characters.
  854. Leading and trailing white space on input lines is ignored.
  855. An unquoted sharp character (#) in the input introduces a comment which extends
  856. to the end of the line the sharp character appears on.
  857. White space characters and sharp characters may be enclosed in double quotes
  858. (") if they're to be used as part of a field.
  859. Any line that is blank (after comment stripping) is ignored.
  860. Non-blank lines are expected to be of one of three types:
  861. rule lines, zone lines, and link lines.
  862. .PP
  863. A rule line has the form
  864. .nf
  865. .B
  866. .ti +.5i
  867. .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
  868. .sp
  869. Rule    NAME    FROM    TO    TYPE    IN    ON    AT    SAVE    LETTER/S
  870. .sp
  871. For example:
  872. .ti +.5i
  873. .sp
  874. Rule    USA    1969    1973    \-    Apr    lastSun    2:00    1:00    D
  875. .sp
  876. .fi
  877. The fields that make up a rule line are:
  878. .TP "\w'LETTER/S'u"
  879. .B NAME
  880. Gives the (arbitrary) name of the set of rules this rule is part of.
  881. .TP
  882. .B FROM
  883. Gives the first year in which the rule applies.
  884. The word
  885. .B minimum
  886. (or an abbreviation) means the minimum year with a representable time value.
  887. The word
  888. .B maximum
  889. (or an abbreviation) means the maximum year with a representable time value.
  890. .TP
  891. .B TO
  892. Gives the final year in which the rule applies.
  893. In addition to
  894. .B minimum
  895. and
  896. .B maximum
  897. (as above),
  898. the word
  899. .B only
  900. (or an abbreviation)
  901. may be used to repeat the value of the
  902. .B FROM
  903. field.
  904. .TP
  905. .B TYPE
  906. Gives the type of year in which the rule applies.
  907. If
  908. .B TYPE
  909. is
  910. .B \-
  911. then the rule applies in all years between
  912. .B FROM
  913. and
  914. .B TO
  915. inclusive;
  916. if
  917. .B TYPE
  918. is
  919. .BR uspres ,
  920. the rule applies in U.S. Presidential election years;
  921. if
  922. .B TYPE
  923. is
  924. .BR nonpres ,
  925. the rule applies in years other than U.S. Presidential election years.
  926. If
  927. .B TYPE
  928. is something else, then
  929. .I zic
  930. executes the command
  931. .ti +.5i
  932. \fByearistype\fP \fIyear\fP \fItype\fP
  933. .br
  934. to check the type of a year:
  935. an exit status of zero is taken to mean that the year is of the given type;
  936. an exit status of one is taken to mean that the year is not of the given type.
  937. .TP
  938. .B IN
  939. Names the month in which the rule takes effect.
  940. Month names may be abbreviated.
  941. .TP
  942. .B ON
  943. Gives the day on which the rule takes effect.
  944. Recognized forms include:
  945. .nf
  946. .in +.5i
  947. .sp
  948. .ta \w'Sun<=25\0\0'u
  949. 5    the fifth of the month
  950. lastSun    the last Sunday in the month
  951. lastMon    the last Monday in the month
  952. Sun>=8    first Sunday on or after the eighth
  953. Sun<=25    last Sunday on or before the 25th
  954. .fi
  955. .in -.5i
  956. .sp
  957. Names of days of the week may be abbreviated or spelled out in full.
  958. Note that there must be no spaces within the
  959. .B ON
  960. field.
  961. .TP
  962. .B AT
  963. Gives the time of day at which the rule takes effect.
  964. Recognized forms include:
  965. .nf
  966. .in +.5i
  967. .sp
  968. .ta \w'1:28:13\0\0'u
  969. 2    time in hours
  970. 2:00    time in hours and minutes
  971. 15:00    24-hour format time (for times after noon)
  972. 1:28:14    time in hours, minutes, and seconds
  973. .fi
  974. .in -.5i
  975. .sp
  976. Any of these forms may be followed by the letter
  977. .B w
  978. if the given time is local
  979. .q "wall clock"
  980. time or
  981. .B s
  982. if the given time is local
  983. .q standard
  984. time; in the absence of
  985. .B w
  986. or
  987. .BR s ,
  988. wall clock time is assumed.
  989. .TP
  990. .B SAVE
  991. Gives the amount of time to be added to local standard time when the rule is in
  992. effect.
  993. This field has the same format as the
  994. .B AT
  995. field
  996. (although, of course, the
  997. .B w
  998. and
  999. .B s
  1000. suffixes are not used).
  1001. .TP
  1002. .B LETTER/S
  1003. Gives the
  1004. .q "variable part"
  1005. (for example, the
  1006. .q S
  1007. or
  1008. .q D
  1009. in
  1010. .q EST
  1011. or
  1012. .q EDT )
  1013. of time zone abbreviations to be used when this rule is in effect.
  1014. If this field is
  1015. .BR \- ,
  1016. the variable part is null.
  1017. .PP
  1018. A zone line has the form
  1019. .sp
  1020. .nf
  1021. .ti +.5i
  1022. .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
  1023. Zone    NAME    GMTOFF    RULES/SAVE    FORMAT    [UNTIL]
  1024. .sp
  1025. For example:
  1026. .sp
  1027. .ti +.5i
  1028. Zone    Australia/South\-west    9:30    Aus    CST    1987 Mar 15 2:00
  1029. .sp
  1030. .fi
  1031. The fields that make up a zone line are:
  1032. .TP "\w'GMTOFF'u"
  1033. .B NAME
  1034. The name of the time zone.
  1035. This is the name used in creating the time conversion information file for the
  1036. zone.
  1037. .TP
  1038. .B GMTOFF
  1039. The amount of time to add to GMT to get standard time in this zone.
  1040. This field has the same format as the
  1041. .B AT
  1042. and
  1043. .B SAVE
  1044. fields of rule lines;
  1045. begin the field with a minus sign if time must be subtracted from GMT.
  1046. .TP
  1047. .B RULES/SAVE
  1048. The name of the rule(s) that apply in the time zone or,
  1049. alternately, an amount of time to add to local standard time.
  1050. If this field is
  1051. .B \-
  1052. then standard time always applies in the time zone.
  1053. .TP
  1054. .B FORMAT
  1055. The format for time zone abbreviations in this time zone.
  1056. The pair of characters
  1057. .B %s
  1058. is used to show where the
  1059. .q "variable part"
  1060. of the time zone abbreviation goes.
  1061. .TP
  1062. .B UNTIL
  1063. The time at which the GMT offset or the rule(s) change for a location.
  1064. It is specified as a year, a month, a day, and a time of day.
  1065. If this is specified,
  1066. the time zone information is generated from the given GMT offset
  1067. and rule change until the time specified.
  1068. .IP
  1069. The next line must be a
  1070. .q continuation
  1071. line; this has the same form as a zone line except that the
  1072. string
  1073. .q Zone
  1074. and the name are omitted, as the continuation line will
  1075. place information starting at the time specified as the
  1076. .B UNTIL
  1077. field in the previous line in the file used by the previous line.
  1078. Continuation lines may contain an
  1079. .B UNTIL
  1080. field, just as zone lines do, indicating that the next line is a further
  1081. continuation.
  1082. .PP
  1083. A link line has the form
  1084. .sp
  1085. .nf
  1086. .ti +.5i
  1087. .if t .ta \w'Link\0\0'u +\w'LINK-FROM\0\0'u
  1088. .if n .ta \w'Link\0\0'u +\w'US/Eastern\0\0'u
  1089. Link    LINK-FROM    LINK-TO
  1090. .sp
  1091. For example:
  1092. .sp
  1093. .ti +.5i
  1094. Link    US/Eastern    EST5EDT
  1095. .sp
  1096. .fi
  1097. The
  1098. .B LINK-FROM
  1099. field should appear as the
  1100. .B NAME
  1101. field in some zone line;
  1102. the
  1103. .B LINK-TO
  1104. field is used as an alternate name for that zone.
  1105. .PP
  1106. Except for continuation lines,
  1107. lines may appear in any order in the input.
  1108. .PP
  1109. Lines in the file that describes leap seconds have the following form:
  1110. .nf
  1111. .B
  1112. .ti +.5i
  1113. .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
  1114. Leap    YEAR    MONTH    DAY    HH:MM:SS    CORR    R/S
  1115. .sp
  1116. For example:
  1117. .ti +.5i
  1118. .sp
  1119. Leap    1974    Dec    31    23:59:60    +    S
  1120. .sp
  1121. .fi
  1122. The
  1123. .BR YEAR ,
  1124. .BR MONTH ,
  1125. .BR DAY ,
  1126. and
  1127. .B HH:MM:SS
  1128. fields tell when the leap second happened.
  1129. The
  1130. .B CORR
  1131. field
  1132. should be
  1133. .q +
  1134. if a second was added
  1135. or
  1136. .q -
  1137. if a second was skipped.
  1138. The
  1139. .B R/S
  1140. field
  1141. should be (an abbreviation of)
  1142. .q Stationary
  1143. if the leap second time given by the other fields should be interpreted as GMT
  1144. or
  1145. (an abbreviation of)
  1146. .q Rolling
  1147. if the leap second time given by the other fields should be interpreted as
  1148. local wall clock time.
  1149. .SH NOTE
  1150. For areas with more than two types of local time,
  1151. you may need to use local standard time in the
  1152. .B AT
  1153. field of the earliest transition time's rule to ensure that
  1154. the earliest transition time recorded in the compiled file is correct.
  1155. .SH FILE
  1156. /usr/local/etc/zoneinfo    standard directory used for created files
  1157. .SH "SEE ALSO"
  1158. newctime(3), tzfile(5), zdump(8)
  1159. .. @(#)zic.8    7.1
  1160. End of zic.8
  1161. echo file 'zdump.8' >&2
  1162. cat >'zdump.8' <<'End of zdump.8'
  1163. .TH ZDUMP 8
  1164. .SH NAME
  1165. zdump \- time zone dumper
  1166. .SH SYNOPSIS
  1167. .B zdump
  1168. [
  1169. .B \-v
  1170. ] [
  1171. .B \-c
  1172. cutoffyear ] [ zonename ... ]
  1173. .SH DESCRIPTION
  1174. .I Zdump
  1175. prints the current time in each
  1176. .I zonename
  1177. named on the command line.
  1178. .PP
  1179. These options are available:
  1180. .TP
  1181. .B \-v
  1182. For each
  1183. .I zonename
  1184. on the command line,
  1185. print the current time,
  1186. the time at the lowest possible time value,
  1187. the time one day after the lowest possible time value,
  1188. the times both one second before and exactly at
  1189. each detected time discontinuity,
  1190. the time at one day less than the highest possible time value,
  1191. and the time at the highest possible time value,
  1192. Each line ends with
  1193. .B isdst=1
  1194. if the given time is Daylight Saving Time or
  1195. .B isdst=0
  1196. otherwise.
  1197. .TP
  1198. .BI "\-c " cutoffyear
  1199. Cut off the verbose output near the start of the given year.
  1200. .SH "SEE ALSO"
  1201. newctime(3), tzfile(5), zic(8)
  1202. .. @(#)zdump.8    7.1
  1203. End of zdump.8
  1204. echo file 'date.1' >&2
  1205. cat >'date.1' <<'End of date.1'
  1206. .TH DATE 1
  1207. .SH NAME
  1208. date \- show and set date and time
  1209. .SH SYNOPSIS
  1210. .if n .nh
  1211. .if n .na
  1212. .B date
  1213. [
  1214. .B \-u
  1215. ] [
  1216. .B \-c
  1217. ] [
  1218. .B \-n
  1219. ] [
  1220. .B \-d
  1221. dsttype
  1222. ] [
  1223. .B \-t
  1224. minutes-west
  1225. ] [
  1226. \fB\-a \fR[\fB+\fR|\fB-]\fIsss\fB.\fIfff\fR
  1227. ] [
  1228. .BI + format
  1229. ] [
  1230. \fR[\fIyyyy\fR]\fImmddhhmm\fR[\fIyy\fR][\fB.\fIss\fR]
  1231. ]
  1232. .SH DESCRIPTION
  1233. .I Date
  1234. without arguments writes the date and time to the standard output in
  1235. the form
  1236. .ce 1
  1237. Wed Mar  8 14:54:40 EST 1989
  1238. .br
  1239. with
  1240. .B EST
  1241. replaced by the local time zone's abbreviation
  1242. (or by the abbreviation for the time zone specified in the
  1243. .B TZ
  1244. environment variable if set).
  1245. .PP
  1246. If a command-line argument starts with a plus sign
  1247. .RB (` + '),
  1248. the rest of the argument is used as a
  1249. .I format
  1250. that controls what appears in the output.
  1251. In the format, when a percent sign
  1252. .RB (` % ')
  1253. appears,
  1254. it and the character after it are not output,
  1255. but rather identify part of the date or time
  1256. to be output in a particular way
  1257. (or identify a special character to output):
  1258. .nf
  1259. .if t .in +.5i
  1260. .if n .in +2
  1261. .ta \w'%M\0\0'u +\w'Wed Mar  8 14:54:40 1989\0\0'u
  1262.     Sample output    Explanation
  1263. %a    Wed    Abbreviated weekday name
  1264. %A    Wednesday    Full weekday name
  1265. %b    Mar    Abbreviated month name
  1266. %B    March    Full month name
  1267. %c    03/08/89 14:54:40    Month/day/year Hour:minute:second
  1268. %C    Wed Mar  8 14:54:40 1989    a la \fIasctime\^\fP(3)
  1269. %d    08    Day of month (always two digits)
  1270. %D    03/08/89    Month/day/year (eight characters)
  1271. %e     8    Day of month (leading zero blanked)
  1272. %h    Mar    Abbreviated month name
  1273. %H    14    24-hour-clock hour (two digits)
  1274. %I    02    12-hour-clock hour (two digits)
  1275. %j    067    Julian day number (three digits)
  1276. %k     2    12-hour-clock hour (leading zero blanked)
  1277. %l    14    24-hour-clock hour (leading zero blanked)
  1278. %m    03    Month number (two digits)
  1279. %M    54    Minute (two digits)
  1280. %n    \\n    newline character
  1281. %p    PM    AM/PM designation
  1282. %r    02:54:40 PM    Hour:minute:second AM/PM designation
  1283. %R    14:54    Hour:minute
  1284. %S    40    Second (two digits)
  1285. %t    \\t    tab character
  1286. %T    14:54:40    Hour:minute:second
  1287. %U    10    Sunday-based week number (two digits)
  1288. %w    3    Day number (one digit, Sunday is 0)
  1289. %W    10    Monday-based week number (two digits)
  1290. %x    03/08/89    Month/day/year (eight characters)
  1291. %X    14:54:40    Hour:minute:second
  1292. %y    89    Last two digits of year
  1293. %Y    1989    Year in full
  1294. %Z    EST    Time zone abbreviation
  1295. .if t .in -.5i
  1296. .if n .in -2
  1297. .fi
  1298. If a character other than one of those shown above appears after
  1299. a percent sign in the format,
  1300. that following character is output.
  1301. All other characters in the format are copied unchanged to the output;
  1302. a newline character is always added at the end of the output.
  1303. .PP
  1304. In Sunday-based week numbering,
  1305. the first Sunday of the year begins week 1;
  1306. days preceding it are part of ``week 0.''
  1307. In Monday-based week numbering,
  1308. the first Monday of the year begins week 1.
  1309. .PP
  1310. To set the date, use a command line argument with one of the following forms:
  1311. .nf
  1312. .if t .in +.5i
  1313. .if n .in +2
  1314. .ta \w'198903081454\0'u
  1315. 1454    24-hour-clock hours (first two digits) and minutes
  1316. 081454    Month day (first two digits), hours, and minutes
  1317. 03081454    Month (two digits, January is 01), month day, hours, minutes
  1318. 8903081454    Year, month, month day, hours, minutes
  1319. 0308145489    Month, month day, hours, minutes, year
  1320.     (on System V-compatible systems)
  1321. 030814541989    Month, month day, hours, minutes, four-digit year
  1322. 198903081454    Four-digit year, month, month day, hours, minutes
  1323. .if t .in -.5i
  1324. .if n .in -2
  1325. .fi
  1326. If the century, year, month, or month day is not given,
  1327. the current value is used.
  1328. Any of the above forms may be followed by a period and two digits that give
  1329. the seconds part of the new time; if no seconds are given, zero is assumed.
  1330. .PP
  1331. These options are available:
  1332. .TP
  1333. .BR \-u " or " \-c
  1334. Use GMT when setting and showing the date and time.
  1335. .TP
  1336. .B \-n
  1337. Do not notify other networked systems of the time change.
  1338. .TP
  1339. .BI "\-d " dsttype
  1340. Set the kernel-stored Daylight Saving Time type to the given value.
  1341. (The kernel-stored DST type is used mostly by ``old'' binaries.)
  1342. .TP
  1343. .BI "\-t " minutes-west
  1344. Set the kernel-stored ``minutes west of GMT'' value to the one given on the
  1345. command line.
  1346. (The kernel-stored DST type is used mostly by ``old'' binaries.)
  1347. .TP
  1348. .BI "\-a " adjustment
  1349. Change the time forward (or backward) by the number of seconds
  1350. (and fractions thereof) specified in the
  1351. .I adjustment\^
  1352. argument.
  1353. Either the seconds part or the fractions part of the argument (but not both)
  1354. may be omitted.
  1355. On BSD-based systems,
  1356. the adjustment is made by changing the rate at which time advances;
  1357. on System-V-based systems, the adjustment is made by changing the time.
  1358. .. @(#)date.1    7.1
  1359. End of date.1
  1360. echo file 'Makefile' >&2
  1361. cat >'Makefile' <<'End of Makefile'
  1362. # @(#)Makefile    7.1
  1363.  
  1364. # Change the line below for your time zone (after finding the zone you want in
  1365. # the time zone files, or adding it to a time zone file).
  1366. # Alternately, if you discover you've got the wrong time zone, you can just
  1367. #    zic -l rightzone
  1368. # to correct things.
  1369. # Use the command
  1370. #    make zonenames
  1371. # to get a list of the values you can use for LOCALTIME.
  1372.  
  1373. LOCALTIME=    Factory
  1374.  
  1375. # If you want something other than Eastern United States time as a template
  1376. # for handling POSIX-style time zone environment variables,
  1377. # change the line below (after finding the zone you want in the
  1378. # time zone files, or adding it to a time zone file).
  1379. # (When a POSIX-style environment variable is handled, the rules in the template
  1380. # file are used to determine "spring forward" and "fall back" days and
  1381. # times; the environment variable itself specifies GMT offsets of standard and
  1382. # summer time.)
  1383. # Alternately, if you discover you've got the wrong time zone, you can just
  1384. #    zic -p rightzone
  1385. # to correct things.
  1386. # Use the command
  1387. #    make zonenames
  1388. # to get a list of the values you can use for POSIXRULES.
  1389. # If you want POSIX compatibility, use "US/Eastern".
  1390.  
  1391. POSIXRULES=    US/Eastern
  1392.  
  1393. # Everything gets put in subdirectories of. . .
  1394.  
  1395. TOPDIR=        /usr/local
  1396.  
  1397. # "Compiled" time zone information is placed in the "TZDIR" directory
  1398. # (and subdirectories).
  1399. # Use an absolute path name for TZDIR unless you're just testing the software.
  1400.  
  1401. TZDIR=        $(TOPDIR)/etc/zoneinfo
  1402.  
  1403. # The "zic" and "zdump" commands get installed in. . .
  1404.  
  1405. ETCDIR=        $(TOPDIR)/etc
  1406.  
  1407. # If you "make INSTALL", the "date" command gets installed in. . .
  1408.  
  1409. BINDIR=        $(TOPDIR)/bin
  1410.  
  1411. # Manual pages go in subdirectories of. . .
  1412.  
  1413. MANDIR=        $(TOPDIR)/man
  1414.  
  1415. # Library functions are put in an archive in LIBDIR.
  1416.  
  1417. LIBDIR=        $(TOPDIR)/lib
  1418. TZLIB=        $(LIBDIR)/libz.a
  1419.  
  1420. # If you always want time values interpreted as "seconds since the epoch
  1421. # (not counting leap seconds)", use
  1422. #     REDO=        posix_only
  1423. # below.  If you always want right time values interpreted as "seconds since
  1424. # the epoch" (counting leap seconds)", use
  1425. #    REDO=        right_only
  1426. # below.  If you want both sets of data available, with leap seconds not
  1427. # counted normally, use
  1428. #    REDO=        posix_right
  1429. # below.  If you want both sets of data available, with leap seconds counted
  1430. # normally, use
  1431. #    REDO=        right_posix
  1432. # below.
  1433. # POSIX mandates that leap seconds not be counted; for compatibility with it,
  1434. # use either "posix_only" or "posix_right".
  1435.  
  1436. REDO=        posix_right
  1437.  
  1438. # If you're on an AT&T-based system (rather than a BSD-based system), add
  1439. #    -DUSG
  1440. # to the end of the "CFLAGS=" line.
  1441. #
  1442. # If you're on an AT&T-based system and use csh, add
  1443. #    -DSHELL=/bin/sh
  1444. # to the end of the "CFLAGS=" line.
  1445. #
  1446. # If you're running on a system where "strchr" is known as "index"
  1447. # (for example, a 4.[012]BSD system), add
  1448. #    -Dstrchr=index
  1449. # to the end of the "CFLAGS=" line.
  1450. #
  1451. # If you're running on a system with a "mkdir" function, feel free to add
  1452. #    -Demkdir=mkdir
  1453. # to the end of the "CFLAGS=" line
  1454. #
  1455. # If you want to use System V compatibility code, add
  1456. #    -DUSG_COMPAT
  1457. # to the end of the "CFLAGS=" line.  This arrange for "timezone" and "daylight"
  1458. # variables to be kept up-to-date by the time conversion functions.  Neither
  1459. # "timezone" nor "daylight" is described in X3J11's work.
  1460. #
  1461. # If your system has a "GMT offset" field in its "struct tm"s
  1462. # (or if you decide to add such a field in your system's "time.h" file),
  1463. # add the name to a define such as
  1464. #    -DTM_GMTOFF=tm_gmtoff
  1465. # or
  1466. #    -DTM_GMTOFF=_tm_gmtoff
  1467. # to the end of the "CFLAGS=" line.
  1468. # Neither tm_gmtoff nor _tm_gmtoff is described in X3J11's work;
  1469. # in its work, use of "tm_gmtoff" is described as non-conforming.
  1470. # Both UCB and Sun have done the equivalent of defining TM_GMTOFF in
  1471. # their recent releases.
  1472. #
  1473. # If your system has a "zone abbreviation" field in its "struct tm"s
  1474. # (or if you decide to add such a field in your system's "time.h" file),
  1475. # add the name to a define such as
  1476. #    -DTM_ZONE=tm_zone
  1477. # or
  1478. #    -DTM_ZONE=_tm_zone
  1479. # to the end of the "CFLAGS=" line.
  1480. # Neither tm_zone nor _tm_zone is described in X3J11's work;
  1481. # in its work, use of "tm_zone" is described as non-conforming.
  1482. # Both UCB and Sun have done the equivalent of defining TM_ZONE in
  1483. # their recent releases.
  1484. #
  1485. # If you want functions that were inspired by early versions of X3J11's work,
  1486. # add
  1487. #    -DSTD_INSPIRED
  1488. # to the end of the "CFLAGS=" line.  This arranges for the functions
  1489. # "tzsetwall", "offtime", "timelocal", "timegm", and "timeoff"
  1490. # to be added to the time conversion library.
  1491. # "tzsetwall" is like "tzset" except that it arranges for local wall clock
  1492. # time (rather than the time specified in the TZ environment variable)
  1493. # to be used.
  1494. # "offtime" is like "gmtime" except that it accepts a second (long) argument
  1495. # that gives an offset to add to the time_t when converting it.
  1496. # "timelocal" is equivalent to "mktime".
  1497. # "timegm" is like "timelocal" except that it turns a struct tm into
  1498. # a time_t using GMT (rather than local time as "timelocal" does).
  1499. # "timeoff" is like "timegm" except that it accepts a second (long) argument
  1500. # that gives an offset to use when converting to a time_t.
  1501. # None of these functions are described in X3J11's current work.
  1502. # Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
  1503. # These functions may well disappear in future releases of the time
  1504. # conversion package.
  1505. #
  1506. # If you want Source Code Control System ID's left out of object modules, add
  1507. #    -DNOID
  1508. # to the end of the "CFLAGS=" line.
  1509. #
  1510. # If you'll never want to handle solar-time-based time zones, add
  1511. #    -DNOSOLAR
  1512. # to the end of the "CFLAGS=" line
  1513. # (and comment out the "SDATA=" line below).
  1514. # This reduces (slightly) the run-time data-space requirements of
  1515. # the time conversion functions; it may reduce the acceptability of your system
  1516. # to folks in oil- and cash-rich places.
  1517. #
  1518. # If you want to allocate state structures in localtime, add
  1519. #    -DALL_STATE
  1520. # to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
  1521. #
  1522. # If you want an "altzone" variable (a la System V Release 3.1), add
  1523. #    -DALTZONE
  1524. # to the end of the "CFLAGS=" line.
  1525. # This variable is not described in X3J11's work.
  1526. #
  1527. # If you want a "gtime" function (a la MACH), add
  1528. #    -DCMUCS
  1529. # to the end of the "CFLAGS=" line
  1530. # This function is not described in X3J11's work.
  1531.  
  1532. CFLAGS=
  1533.  
  1534. ################################################################################
  1535.  
  1536. CC=        cc -DTZDIR=\"$(TZDIR)\"
  1537.  
  1538. TZCSRCS=    zic.c localtime.c asctime.c scheck.c ialloc.c emkdir.c getopt.c
  1539. TZCOBJS=    zic.o localtime.o asctime.o scheck.o ialloc.o emkdir.o getopt.o
  1540. TZDSRCS=    zdump.c localtime.c asctime.c ialloc.c getopt.c
  1541. TZDOBJS=    zdump.o localtime.o asctime.o ialloc.o getopt.o
  1542. DATESRCS=    date.c localtime.c getopt.c logwtmp.c strftime.c
  1543. DATEOBJS=    date.o localtime.o getopt.o logwtmp.o strftime.o asctime.o
  1544. LIBSRCS=    localtime.c asctime.c difftime.c
  1545. LIBOBJS=    localtime.o asctime.o difftime.o
  1546. HEADERS=    tzfile.h private.h
  1547. NONLIBSRCS=    zic.c zdump.c scheck.c ialloc.c emkdir.c getopt.c
  1548. NEWUCBSRCS=    date.c logwtmp.c strftime.c
  1549. SOURCES=    $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS)
  1550. MANS=        newctime.3 tzfile.5 zic.8 zdump.8
  1551. DOCS=        Patchlevel.h README Theory $(MANS) date.1 Makefile
  1552. YDATA=        africa antarctica asia australasia \
  1553.         europe northamerica southamerica pacificnew etcetera factory
  1554. NDATA=        systemv
  1555. SDATA=        solar87 solar88 solar89
  1556. TDATA=        $(YDATA) $(NDATA) $(SDATA)
  1557. DATA=        $(YDATA) $(NDATA) $(SDATA) leapseconds
  1558. USNO=        usno1988 usno1989
  1559. ENCHILADA=    $(DOCS) $(SOURCES) $(DATA) $(USNO)
  1560.  
  1561. all:        zic zdump $(LIBOBJS)
  1562.  
  1563. ALL:        all date
  1564.  
  1565. install:    all $(DATA) $(REDO) $(TZLIB) $(MANS)
  1566.         ./zic -d $(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
  1567.         -mkdir $(TOPDIR) $(ETCDIR)
  1568.         cp zic zdump $(ETCDIR)/.
  1569.         -mkdir $(TOPDIR) $(MANDIR) \
  1570.             $(MANDIR)/man3 $(MANDIR)/man5 $(MANDIR)/man8
  1571.         -rm -f $(MANDIR)/man3/newctime.3 \
  1572.             $(MANDIR)/man5/tzfile.5 \
  1573.             $(MANDIR)/man8/zdump.8 \
  1574.             $(MANDIR)/man8/zic.8
  1575.         cp newctime.3 $(MANDIR)/man3/.
  1576.         cp tzfile.5 $(MANDIR)/man5/.
  1577.         cp zdump.8 zic.8 $(MANDIR)/man8/.
  1578.  
  1579. INSTALL:    ALL install date.1
  1580.         -mkdir $(TOPDIR) $(BINDIR)
  1581.         cp date $(BINDIR)/.
  1582.         -mkdir $(TOPDIR) $(MANDIR) $(MANDIR)/man1
  1583.         -rm -f $(MANDIR)/man1/date.1
  1584.         cp date.1 $(MANDIR)/man1/.
  1585.  
  1586. zdump:        $(TZDOBJS)
  1587.         $(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) -o $@
  1588.  
  1589. zic:        $(TZCOBJS)
  1590.         $(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) -o $@
  1591.  
  1592. posix_only:    zic $(TDATA)
  1593.         ./zic -d $(TZDIR) -L /dev/null $(TDATA)
  1594.  
  1595. right_only:    zic leapseconds $(TDATA)
  1596.         ./zic -d $(TZDIR) -L leapseconds $(TDATA)
  1597.  
  1598. other_two:    zic leapseconds $(TDATA)
  1599.         ./zic -d $(TZDIR)/posix -L /dev/null $(TDATA)
  1600.         ./zic -d $(TZDIR)/right -L leapseconds $(TDATA)
  1601.  
  1602. posix_right:    posix_only other_two
  1603.  
  1604. right_posix:    right_only other_two
  1605.  
  1606. # The "ar d"s below ensure that obsolete object modules
  1607. # (based on source provided with earlier versions of the time conversion stuff)
  1608. # are removed from the library.
  1609.  
  1610. $(TZLIB):    $(LIBOBJS)
  1611.         ar ru $@ $(LIBOBJS)
  1612.         if ar t $@ timemk.o 2>/dev/null ; then ar d $@ timemk.o ; fi
  1613.         if ar t $@ ctime.o 2>/dev/null ; then ar d $@ ctime.o ; fi
  1614.         if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
  1615.             then ranlib $@ ; fi
  1616.  
  1617. # We use the system's logwtmp and strftime in preference to ours if available.
  1618.  
  1619. date:        $(DATEOBJS)
  1620.         ar r ,lib.a logwtmp.o strftime.o
  1621.         if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
  1622.             then ranlib ,lib.a ; fi
  1623.         $(CC) $(CFLAGS) date.o localtime.o asctime.o getopt.o \
  1624.             -lc ,lib.a -o $@
  1625.         rm -f ,lib.a
  1626.  
  1627. clean:
  1628.         rm -f core *.o *.out zdump zic date ,*
  1629.  
  1630. names:
  1631.         @echo $(ENCHILADA)
  1632.  
  1633. zonenames:    $(TDATA)
  1634.         @awk '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
  1635.  
  1636. asctime.o:    private.h tzfile.h
  1637. date.o:        private.h
  1638. difftime.o:    private.h
  1639. emkdir.o:    private.h
  1640. ialloc.o:    private.h
  1641. localtime.o:    private.h tzfile.h
  1642. scheck.o:    private.h
  1643. strftime.o:    tzfile.h
  1644. zic.o:        private.h tzfile.h
  1645.  
  1646. .KEEP_STATE:
  1647. End of Makefile
  1648. exit
  1649.