Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time Split out FUNCTIONS to make this tolerable to ...



details:   https://anonhg.NetBSD.org/src/rev/c43443a29781
branches:  trunk
changeset: 764144:c43443a29781
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Tue Apr 12 13:46:38 2011 +0000

description:
Split out FUNCTIONS to make this tolerable to read. Also improve readability
with lists. Describe the functions in the order of appearance in SYNOPSIS.
Use CAVEATS instead of NOTES. Remove "man page spam". Etc.

diffstat:

 lib/libc/time/ctime.3 |  257 ++++++++++++++++++++++++++++---------------------
 1 files changed, 148 insertions(+), 109 deletions(-)

diffs (truncated from 451 to 300 lines):

diff -r 48adcee5fa9f -r c43443a29781 lib/libc/time/ctime.3
--- a/lib/libc/time/ctime.3     Tue Apr 12 08:42:12 2011 +0000
+++ b/lib/libc/time/ctime.3     Tue Apr 12 13:46:38 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ctime.3,v 1.39 2011/04/12 08:39:26 jruoho Exp $
+.\" $NetBSD: ctime.3,v 1.40 2011/04/12 13:46:38 jruoho Exp $
 .\"
 .\" XXX: Lincense missing?
 .\"
@@ -29,6 +29,10 @@
 .In time.h
 .Vt extern char *tzname[2];
 .Ft char *
+.Fn asctime "const struct tm *tm"
+.Ft char *
+.Fn asctime_r "const struct tm restrict tm" "char * restrict buf"
+.Ft char *
 .Fn ctime "const time_t *clock"
 .Ft char *
 .Fn ctime_r "const time_t *clock"  "char *buf"
@@ -36,131 +40,169 @@
 .Fn ctime_rz "const timezone_t tz" "const time_t *clock"  "char *buf"
 .Ft double
 .Fn difftime "time_t time1" "time_t time0"
-.Ft char *
-.Fn asctime "const struct tm *tm"
-.Ft char *
-.Fn asctime_r "const struct tm restrict tm" "char * restrict buf"
+.Ft struct tm *
+.Fn gmtime "const time_t *clock"
+.Ft struct tm *
+.Fn gmtime_r "const time_t * restrict clock" "struct tm * restrict result"
 .Ft struct tm *
 .Fn localtime "const time_t *clock"
 .Ft struct tm *
 .Fn localtime_r "const time_t * restrict clock" "struct tm * restrict result"
 .Ft struct tm *
 .Fn localtime_rz "const timezone_t tz" "const time_t * restrict clock" "struct tm * restrict result"
-.Ft struct tm *
-.Fn gmtime "const time_t *clock"
-.Ft struct tm *
-.Fn gmtime_r "const time_t * restrict clock" "struct tm * restrict result"
 .Ft time_t
 .Fn mktime "struct tm *tm"
 .Ft time_t
 .Fn mktime_z "const timezone_t tz" "struct tm *tm"
 .Ft timezone_t
 .Fn tzalloc "const char *zone"
-.Ft const char *
-.Fn tzgetname "const timezone_t tz" "int isdst"
 .Ft void
 .Fn tzfree "const timezone_t tz"
+.Ft const char *
+.Fn tzgetname "const timezone_t tz" "int isdst"
 .Sh DESCRIPTION
+The
+.Nm
+family of functions provide various standard library routines
+to operate with time and conversions related to time.
+.Sh FUNCTIONS
+.Bl -tag -width abcd
+.It Fn asctime "tm"
+The
+.Fn asctime
+function converts a time value contained in the
+.Fa tm
+structure to a string with the following general format:
+.Bd -literal -offset indent
+.D1 Thu Nov 24 18:22:48 1986\en\e0
+.Ed
+.Pp
+The
+.Fa tm
+structure is described in
+.Xr tm 3 .
+.It Fn asctime_r "tm" "buf"
+The
+.Fn asctime_r
+has the same behavior as
+.Fn asctime ,
+but the result is stored to
+.Fa buf ,
+which should have a size of at least 26 bytes.
+.It Fn ctime "clock"
+The
 .Fn ctime
-converts a
+function converts a
 .Vt time_t ,
 pointed to by
 .Fa clock ,
-representing the time in seconds since
-00:00:00 UTC, 1970-01-01,
-and returns a pointer to a
-string of the form
-.D1 Thu Nov 24 18:22:48 1986\en\e0
+representing the time in seconds since 00:00:00 UTC, 1970-01-01,
+and returns a pointer to a string with the format described above.
 Years requiring fewer than four characters are padded with leading zeroes.
 For years longer than four characters, the string is of the form
+.Bd -literal -offset indent
 .D1 Thu Nov 24 18:22:48     81986\en\e0
+.Ed
+.Pp
 with five spaces before the year.
 These unusual formats are designed to make it less likely that older
 software that expects exactly 26 bytes of output will mistakenly output
 misleading values for out-of-range years.
-.Pp
+.It Fn ctime_r "clock" "buf"
+The
 .Fn ctime_r
 is similar to
 .Fn ctime ,
 except it places the result of the conversion on the
 .Fa buf
-argument which should be 26 or more bytes long, instead of using a global
-static buffer.
-.Pp
+argument, which should be 26 or more bytes long,
+instead of using a global static buffer.
+.It Fn ctime_rz "tz" "clock" "buf"
+The
 .Fn ctime_rz
-is similar to
+function is similar to
 .Fn ctime_r ,
 but it also takes a
 .Ft "const timezone_t"
-argument, returned by a previous call to
+argument, as returned by a previous call to
 .Fn tzalloc .
-.Pp
+.It Fn difftime "time1" "time2"
+The
+.Fn difftime
+function returns the difference between two calendar times,
+.Fa ( time1 No - Fa time0 ) ,
+expressed in seconds.
+.It Fn gmtime "clock"
+The
+.Fn gmtime
+function converts to Coordinated Universal Time
+.Pq Tn UTC
+and returns a pointer to the
+.Va tm
+structure described in
+.Xr tm 3 .
+.It Fn gmtime_r "clock" "result"
+The
+.Fn gmtime_r
+provides the same functionality as
+.Fn gmtime ,
+differing in that the caller must supply a buffer area
+.Fa result
+to which the result is stored.
+.It Fn localtime "clock"
+Also
 .Fn localtime
-and
-.Fn gmtime
-return pointers to
-.Va tm
-structures, described below.
+is comparable to
+.Fn gmtime .
+However,
 .Fn localtime
 corrects for the time zone and any time zone adjustments
 (such as Daylight Saving Time in the U.S.A.).
 After filling in the
 .Va tm
-structure described in
-.Xr tm 3 ,
-.Fn localtime
-sets the
+structure, the function sets the
 .Fa tm_isdst Ns 'th
 element of
 .Fa tzname
 to a pointer to an
-ASCII string that's the time zone abbreviation to be used with
+ASCII string that is the time zone abbreviation to be used with
 .Fn localtime Ns 's
 return value.
-.Pp
-.Fn gmtime
-converts to Coordinated Universal Time.
-.Pp
-The
-.Fn gmtime_r
-and
+.It Fn localtime_r "clock" "result"
+As
+.Fn gmtime_r ,
+the
 .Fn localtime_r
-functions provide the same functionality as
-.Fn gmtime
-and
-.Fn localtime
-differing in that the caller must supply a buffer area
+takes an additional buffer
 .Fa result
-in which the result is stored; also,
+as a parameter and stores the result to it.
+Note however that
 .Fn localtime_r
 does not imply initialization of the local time conversion information;
 the application may need to do so by calling
 .Xr tzset 3 .
-.Pp
+.It Fn localtime_rz "tz" "clock" "result"
+The
 .Fn localtime_rz
-is similar to
+function is similar to
 .Fn localtime_r ,
 but it also takes a
 .Ft "const timezone_t"
 argument, returned by a previous call to
 .Fn tzalloc .
-.Pp
-.Fn asctime
-converts a time value contained in a
-.Dq tm
-structure to a string,
-as shown in the above example,
-and returns a pointer to the string.
-.Pp
+.It Fn mktime "tm"
+The
 .Fn mktime
-converts the broken-down time,
-expressed as local time,
-in the structure pointed to by
-.Fa tm
-into a calendar time value with the same encoding as that of the values
-returned by the
+function converts the broken-down time,
+expressed as local time in the
+.Xr tm 3
+structure, into a calendar time value with
+the same encoding as that of the values returned by the
 .Xr time 3
 function.
+The following remarks should be taken into account.
+.Bl -bullet -offset indent
+.It
 The original values of the
 .Fa tm_wday
 and
@@ -175,6 +217,7 @@
 to presume initially that summer time (for example, Daylight Saving Time
 in the U.S.A.) respectively,
 is or is not in effect for the specified time.
+.It
 A negative value for
 .Fa tm_isdst
 causes the
@@ -182,7 +225,8 @@
 function to attempt to divine whether summer time is in effect
 for the specified time; in this case it does not use a consistent
 rule and may give a different answer when later
-presented with the same argument.)
+presented with the same argument.
+.It
 On successful completion, the values of the
 .Fa tm_wday
 and
@@ -196,33 +240,33 @@
 and
 .Fa tm_year
 are determined.
-.Fn mktime
-returns the specified calendar time; if the calendar time cannot be
-represented, it returns
+.El
+.Pp
+The function returns the specified calendar time;
+if the calendar time cannot be represented, it returns
 .Va "(time_t)-1" .
-.Pp
+.It Fn mktime_z "tz" "tm"
+The
 .Fn mktime_z
-is similar to
+function is similar to
 .Fn mktime
 but it also takes a
 .Ft "const timezone_t"
 argument, returned by a previous call to
 .Fn tzalloc .
-.Pp
-.Fn difftime
-returns the difference between two calendar times,
-.Fa ( time1 No - Fa time0 ) ,
-expressed in seconds.
-.Pp
+.It Fn tzalloc "zone"



Home | Main Index | Thread Index | Old Index