ref: ce5b6036f04ca6af1cb1fe2992c86eb6ad47cf22
parent: 4a1186ddfe422c94f16e0d21efda599bb4556355
author: Ori Bernstein <[email protected]>
date: Mon Sep 7 15:28:30 EDT 2020
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.
--- a/sys/man/2/tmdate
+++ b/sys/man/2/tmdate
@@ -57,12 +57,11 @@
.PP
Tmnow gets the current time of day in the requested time zone.
.PP
-Tmtime converts the millisecond-resolution timestamp 'abs'
+Tmtime converts the second resolution timestamp 'abs'
into a Tm struct in the requested timezone.
Tmtimens does the same, but with a nanosecond accuracy.
.PP
-Tmstime is identical to tmtime, but accepts the time in sec-
-onds.
+Tmtimens is identical to tmtime, but accepts a nanosecond argument.
.PP
Tmparse parses a time from a string according to the format argument.
Leading whitespace is ignored.
@@ -223,6 +222,7 @@
.IP
.EX
Tm a, b;
+char *e;
if(tmparse(&a, nil, "Tue Dec 10 12:36:00 PST 2019", &e) == nil)
sysfatal("failed to parse: %r");
@@ -251,7 +251,7 @@
sysfatal("load zone: %r");
if(tmnow(&here, zl) == nil)
sysfatal("get time: %r");
-if(tmtime(&there, tmnorm(&tm), zp) == nil)
+if(tmtime(&there, tmnorm(&here), zp) == nil)
sysfatal("shift time: %r");
.EE
@@ -258,12 +258,13 @@
.PP
Add a day. Because cross daylight savings, only 23 hours are added.
+.IP
.EX
Tm t;
char *date = "Sun Nov 2 13:11:11 PST 2019";
-if(tmparse(&t, "W MMM D hh:mm:ss z YYYY, date, &e) == nil)
- print("failed top parse");
-tm.day++;
+if(tmparse(&t, "W MMM D hh:mm:ss z YYYY, date, nil) == nil)
+ print("failed top arse");
+t.day++;
tmnorm(&t);
print("%τ", &t); /* Mon Nov 3 13:11:11 PST 2019 */
.EE
@@ -273,8 +274,6 @@
Checking the timezone name against the local timezone is a
dirty hack. The same date string may parse differently for
people in different timezones.
-.PP
-There is no way to format specifier for subsecond precision.
.PP
The timezone information that we ship is out of date.
.PP