tmdate(2): fix examples, stale references (thanks deuteron)

There were a number of ideas that were tried out as the tmdate
api evolved. As a result, there were some references in the
manpage to things that are no more.

Fix them.
This commit is contained in:
Ori Bernstein 2020-09-07 19:28:30 -07:00
parent 4a1186ddfe
commit ce5b6036f0

View file

@ -57,12 +57,11 @@ does not leak.
.PP .PP
Tmnow gets the current time of day in the requested time zone. Tmnow gets the current time of day in the requested time zone.
.PP .PP
Tmtime converts the millisecond-resolution timestamp 'abs' Tmtime converts the second resolution timestamp 'abs'
into a Tm struct in the requested timezone. into a Tm struct in the requested timezone.
Tmtimens does the same, but with a nanosecond accuracy. Tmtimens does the same, but with a nanosecond accuracy.
.PP .PP
Tmstime is identical to tmtime, but accepts the time in sec- Tmtimens is identical to tmtime, but accepts a nanosecond argument.
onds.
.PP .PP
Tmparse parses a time from a string according to the format argument. Tmparse parses a time from a string according to the format argument.
Leading whitespace is ignored. Leading whitespace is ignored.
@ -223,6 +222,7 @@ Done with full, strict error checking.
.IP .IP
.EX .EX
Tm a, b; Tm a, b;
char *e;
if(tmparse(&a, nil, "Tue Dec 10 12:36:00 PST 2019", &e) == nil) if(tmparse(&a, nil, "Tue Dec 10 12:36:00 PST 2019", &e) == nil)
sysfatal("failed to parse: %r"); sysfatal("failed to parse: %r");
@ -251,19 +251,20 @@ if((zp = tzload("US_Pacific")) == nil)
sysfatal("load zone: %r"); sysfatal("load zone: %r");
if(tmnow(&here, zl) == nil) if(tmnow(&here, zl) == nil)
sysfatal("get time: %r"); sysfatal("get time: %r");
if(tmtime(&there, tmnorm(&tm), zp) == nil) if(tmtime(&there, tmnorm(&here), zp) == nil)
sysfatal("shift time: %r"); sysfatal("shift time: %r");
.EE .EE
.PP .PP
Add a day. Because cross daylight savings, only 23 hours are added. Add a day. Because cross daylight savings, only 23 hours are added.
.IP
.EX .EX
Tm t; Tm t;
char *date = "Sun Nov 2 13:11:11 PST 2019"; char *date = "Sun Nov 2 13:11:11 PST 2019";
if(tmparse(&t, "W MMM D hh:mm:ss z YYYY, date, &e) == nil) if(tmparse(&t, "W MMM D hh:mm:ss z YYYY, date, nil) == nil)
print("failed top parse"); print("failed top arse");
tm.day++; t.day++;
tmnorm(&t); tmnorm(&t);
print("%τ", &t); /* Mon Nov 3 13:11:11 PST 2019 */ print("%τ", &t); /* Mon Nov 3 13:11:11 PST 2019 */
.EE .EE
@ -274,8 +275,6 @@ Checking the timezone name against the local timezone is a
dirty hack. The same date string may parse differently for dirty hack. The same date string may parse differently for
people in different timezones. people in different timezones.
.PP .PP
There is no way to format specifier for subsecond precision.
.PP
The timezone information that we ship is out of date. The timezone information that we ship is out of date.
.PP .PP
The Plan 9 timezone format has no way to express leap seconds. The Plan 9 timezone format has no way to express leap seconds.