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 \- seconds resolution time conversion support
47 library supports conversion between
48 string date specifications,
54 contains the elements of
56 along with these additions:
58 .L "unsigned _ast_int4_t tm_nsec"
59 The subsecond portion of the time in nanoseconds.
61 .L "Tm_zone_t* tm_zone"
69 are used to determine local time zone and savings time information.
72 values are the number of seconds since the epoch,
73 .BR "Jan 1 00:00:00 GMT 1970" ,
74 with leap seconds omitted.
77 .L "int tm_info.flags"
78 contains flags that allow all programs using the library
79 to be controlled in a consistent manner.
83 routine described below, and may be explicitly reset after
95 do not compensate for leap seconds.
99 values are interpreted as if they include leap seconds.
106 environment variable.
109 Times are relative to
111 (universal coordinated time, i.e.,
113 Otherwise times are relative to the local time zone.
116 if the time zone name matches one of
117 .L tm_info.format[43]
119 .L tm_info.format[46]
121 If the time zone name is not determined by
123 then the environment variables
125 (as described in BSD 4.3) and
127 (as described in System V)
128 are checked, in order.
129 If this fails then the time zone name is constructed using
130 the local time zone offset.
134 .L "time_t tmdate(const char* date, char** end, time_t* clock)"
135 Parses the date specification
139 string table (described below)
140 and returns the equivalent
146 is set to the position of the first unrecognized character in
149 is used to provide default values for omitted components in
155 then the current time is used.
157 .L "Tm_t* tmfix(Tm_t* tp)"
158 Corrects any out of bounds fields in
163 The corrections start with
165 and propagate down to
169 were 61 then it would change to 1 and
171 would be incremented by 1, and so on.
173 is not changed -- call
175 to determine its proper value after the
179 .L "char* tmfmt(char* buf, size_t len, const char* format, time_t* clock)"
180 Formats the date pointed to by
186 bytes according to the format specification
192 or empty then the string
193 .L tm_info.format[40]
199 then the current time is used.
200 A pointer to the end of
202 (i.e., the terminating
212 names a fixed size field, zero padded if necessary,
217 sequences are as in C. Invalid
219 specifications and all other characters are copied
224 to turn off padding or
226 to pad with space, otherwise numeric fields
229 and string fields are padded with space.
231 may also be preceded by
233 for alternate era representation or
235 for alternate digit representation (if supported by the current locale.)
240 truncates the field to
243 sequences are interpreted as in the C language.
244 String field values are taken from the
257 Abbreviated weekday name.
263 Abbreviated month name.
267 style date without the trailing
282 Blank padded day of month number.
285 Unpadded day of month number.
288 Locale default override date format.
291 Locale default date format
292 .RL ( tm_info.format[40] .)
295 Abbreviated month name.
303 date that includes the time zone type name
304 .RL ( tm_info.format[107] .)
310 1-offset Julian date.
313 0-offset Julian date.
318 .RL ( tm_info.format[106] .)
321 Language neutral, all numeric, no embedded space date
322 with larger to smaller time units from left to right,
323 suitable for sorting:
324 .LR '"%Y-%m-%d+%H:%M:%S"' .
329 date that lists recent dates with
331 and distant dates with
345 The time zone type or nation code.
354 The nanosecond part of the time.
356 \fB%Q\fP\fI<delim>recent<delim>distant<delim>\fP
357 Recent dates are formatted with
359 and distand dates are formatted with
363 is any character not appearing in
378 Seconds since the epoch.
391 .I seconds.subseconds
403 Weeday number with 1 for Monday, 7 for Sunday.
406 Week number with Sunday as the first day.
409 ISO week number (i18n is \fIfun\fP.)
412 Weekday number with 0 for Sunday, 6 for Saturday.
415 Week number with Monday as the first day.
418 Local date style, using
419 .LR tm_info.format[39] ,
420 that includes the month, day and year.
423 Local time style, using
424 .LR tm_info.format[38] ,
425 that includes the hours and minutes.
428 2-digit year (you'll be sorry.)
436 west of GMT offset where
447 Set (default or +) or clear (-)
453 or for the remainder of the process if
462 Enable leap second adjustments.
480 \fP?\fP\fIalternate\fP
483 format is a default format override has not been specified.
489 \f5TM_OPTIONS="format='\fP\fIoverride\fP\f5'"\fP
490 to override the default.
494 .L "void tminit(Tm_zone_t* zone)"
495 Implicitly called by the other
497 library routines to initialize global data, including the
502 Global data should only be modified after an explicit call to
506 then it specifies a time zone other that the local time zone.
508 .L "void tmset(Tm_zone_t* zone);"
510 sets the reference timezoe to
513 points to the local timezone and
515 points to the current reference timezone.
517 .L "time_t tmleap(time_t* clock)"
520 value for the time pointed to by
522 with leap seconds adjusted for external
523 routines that do not handle leap seconds.
528 then the current time is used.
529 Adjustments are only done if the
534 .L "Tm_t* tmmake(time_t* clock)"
535 Returns a pointer to the
537 struct corresponding to the time pointed to by
543 then the current time is used.
545 .L "time_t tmtime(Tm_t* tp, int west)"
548 value corresponding to
556 is relative to the local time zone,
559 is the number of minutes west of
561 with daylight savings time taken into account.
566 are ignored in the conversion.
568 The library routines use a table of date strings pointed to by
569 .LR "char** tm_info.format" .
572 are fixed by category.
574 may be changed to point to other tables
575 according to local language and date conventions.
576 The contents by index (showing the USA English values) are:
581 3-character abbreviated month names.
587 3-character abbreviated weekday names.
594 local time format used by the
600 local date format used by the
613 Meridian names: AM, PM.
617 time zone names: GMT, UTC, UCT, CUT.
620 Daylight savings time suffix names: DST.
623 Suffixes to be ignored when matching strings in
627 Time part names: second, hour, minute, day, week, month, year.
630 Hours of the day names: midnight, morning, noon, evening.
633 Relative day names: yesterday, today, tomorrow.
636 Past relative time references: last, ago, past.
639 Current relative time references: this, now, current.
642 Future relative time references: next, hence, coming.
645 Exact relative time references: exactly.
648 Noise words to be ignored: at, in, on.
651 Ordinal suffixes: st, nd, rd, th, th, th, th, th, th, th.
659 format equivalent for
661 .LR '"%a %b %e %T %Y"' .
668 .LR '"%a %b %e %T %Z %Y"' .
674 international format:
675 .LR '"%a %b %e %T %z %Z %Y"' .
682 .LR '"%b %e %H:%M"' .
695 meridian date format:
696 .LR '"%I:%M:%S %p"' .
717 Ordinal names: first, \fIno second!\fP, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth.
720 Final time references, as in \fIthe last in the list\fP: final, ending, nth.
724 Low level support functions and data are described in
738 "2 months ago", "%C",
739 "this Wednesday noon", "%x %I:%M %p",
740 "last December 25", "%A",
743 for (i = 0; x[i].date; i++) {
744 t = tmdate(x[i].date, (char*)0, (time_t*)0);
745 (void)tmfmt(buf, sizeof(buf), x[i].format, &t);
752 Fri Sep 30 12:10:14 USA EDT 1988
753 Fri Jul 1 00:00:00 EDT 1988
764 values may get clobbered by
766 library routines as the
770 routines typically return pointers to a single static
774 uses an internal international time zone name table that will
775 probably always be incomplete.