3 .ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
4 .if !
\a\\$4
\a\a .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
7 .ie
\a\\$3
\a\a .ft \\$1
11 .Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
16 .aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
19 .aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
22 .aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
24 .de EX \" start example
41 tm \- time conversion support
47 library supports conversion between
48 string date specifications,
58 are used to determine local time zone information.
61 values are the number of seconds since the epoch,
62 .BR "Jan 1 00:00:00 GMT 1970" ,
63 with leap seconds omitted.
66 .L "int tm_info.flags"
67 contains flags that allow all programs using the library
68 to be controlled in a consistent manner.
72 routine described below, and may be explicitly reset after
84 do not compensate for leap seconds.
88 values are interpreted as if they include leap seconds.
100 (universal coordinated time, i.e.,
102 Otherwise times are relative to the local time zone.
105 if the time zone name matches one of
106 .L tm_info.format[43]
108 .L tm_info.format[46]
110 If the time zone name is not determined by
112 then the environment variables
114 (as described in BSD 4.3) and
116 (as described in System V)
117 are checked, in order.
118 If this fails then the time zone name is constructed using
119 the local time zone offset.
123 .L "time_t tmdate(const char* date, char** end, time_t* clock)"
124 Parses the date specification
128 string table (described below)
129 and returns the equivalent
135 is set to the position of the first unrecognized character in
138 is used to provide default values for omitted components in
144 then the current time is used.
146 .L "struct tm* tmfix(struct tm* tp)"
147 Corrects any out of bounds fields in
152 The corrections start with
154 and propagate down to
158 were 61 then it would change to 1 and
160 would be incremented by 1, and so on.
165 are not changed as these can be computed from the other fields.
167 .L "char* tmfmt(char* buf, size_t len, const char* format, time_t* clock)"
168 Formats the date pointed to by
174 bytes according to the format specification
180 or empty then the string
181 .L tm_info.format[40]
187 then the current time is used.
188 A pointer to the end of
190 (i.e., the terminating
200 causes the corresponding fixed size field to be placed in
202 zero padded if necessary, and \e\fIc\fP and \e\fInnn\fP
203 sequences are interpreted as in the C language.
206 specifications and all other characters in
211 String field values are taken from the
224 Abbreviated weekday name.
230 Abbreviated month name.
234 style date without the trailing
249 Blank padded day of month number.
252 Unpadded day of month number.
255 Abbreviated month name.
263 date that includes the time zone type name.
269 1-offset Julian date.
272 0-offset Julian date.
277 date that lists recent dates with
279 and distant dates with
319 Week number with Sunday as the first day.
325 Week number with Monday as the first day.
328 Local date style, using
329 .LR tm_info.format[39] ,
330 that includes the month, day and year.
333 Local time style, using
334 .LR tm_info.format[38] ,
335 that includes the hours and minutes.
354 returns) sets (+) or clears (\-) the
368 Number of seconds since the epoch.
372 .L "void tminit(Tm_zone_t* zone)"
373 Implicitly called by the other
375 library routines to initialize global data, including the
380 Global data should only be modified after an explicit call to
384 then it specifies a time zone other that the local time zone.
386 .L "void tmset(Tm_zone_t* zone);"
388 sets the reference timezoe to
391 points to the local timezone and
393 points to the current reference timezone.
395 .L "time_t tmleap(time_t* clock)"
398 value for the time pointed to by
400 with leap seconds adjusted for external
401 routines that do not handle leap seconds.
406 then the current time is used.
407 Adjustments are only done if the
412 .L "struct tm* tmmake(time_t* clock)"
413 Returns a pointer to the
415 struct corresponding to the time pointed to by
421 then the current time is used.
423 .L "time_t tmtime(struct tm* tp, int west)"
426 value corresponding to
434 is relative to the local time zone,
437 is the number of minutes west of
439 with daylight savings time taken into account.
444 are ignored in the conversion.
446 The library routines use a table of date strings pointed to by
447 .LR "char** tm_info.format" .
450 are fixed by category.
452 may be changed to point to other tables
453 according to local language and date conventions.
454 The contents by index (showing the USA English values) are:
459 3-character abbreviated month names.
465 3-character abbreviated weekday names.
472 local time format used by the
478 local date format used by the
491 Meridian names: AM, PM.
495 time zone names: GMT, UTC, UCT, CUT.
498 Daylight savings time suffix names: DST.
501 Suffixes to be ignored when matching strings in
505 Time part names: second, hour, minute, day, week, month, year.
508 Hours of the day names: midnight, morning, noon, evening.
511 Relative day names: yesterday, today, tomorrow.
514 Past relative time references: last, ago, past.
517 Current relative time references: this, now, current.
520 Future relative time references: next, hence, coming.
523 Exact relative time references: exactly.
526 Noise words to be ignored: at, in, on.
530 Low level support functions and data are described in
544 "2 months ago", "%C",
545 "this Wednesday noon", "%x %I:%M %p",
546 "last December 25", "%A",
549 for (i = 0; x[i].date; i++) {
550 t = tmdate(x[i].date, (char*)0, (time_t*)0);
551 (void)tmform(buf, x[i].format, &t);
558 Fri Sep 30 12:10:14 USA EDT 1988
559 Fri Jul 1 00:00:00 EDT 1988
564 date(1), time(2), ctime(3)
567 values may get clobbered by the
569 library routines as the
571 routines typically return pointers to a single static
575 uses an internal international time zone name table that will
576 probably always be incomplete.