]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man3/ctime.3
Removed trailing white space at end of lines
[thirdparty/man-pages.git] / man3 / ctime.3
index abe5b763e10df479ad674d962260849b5c779906..73e75d3010604f6237b5baf91c50e63ffd8a79e3 100644 (file)
 .\" Modified 2001-12-13, joey, aeb
 .\" Modified 2004-11-16, mtk
 .\"
-.TH CTIME 3 2015-04-19 "" "Linux Programmer's Manual"
+.TH CTIME 3 2019-03-06 "" "Linux Programmer's Manual"
 .SH NAME
 asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r,
 localtime_r \- transform date and time to broken-down time or ASCII
 .SH SYNOPSIS
 .nf
 .B #include <time.h>
-.sp
+.PP
 .BI "char *asctime(const struct tm *" tm );
-.br
 .BI "char *asctime_r(const struct tm *" tm ", char *" buf );
-.sp
+.PP
 .BI "char *ctime(const time_t *" timep );
-.br
 .BI "char *ctime_r(const time_t *" timep ", char *" buf );
-.sp
+.PP
 .BI "struct tm *gmtime(const time_t *" timep );
-.br
 .BI "struct tm *gmtime_r(const time_t *" timep ", struct tm *" result );
-.sp
+.PP
 .BI "struct tm *localtime(const time_t *" timep );
-.br
 .BI "struct tm *localtime_r(const time_t *" timep ", struct tm *" result );
-.sp
+.PP
 .BI "time_t mktime(struct tm *" tm );
 .fi
-.sp
+.PP
 .in -4n
 Feature Test Macro Requirements for glibc (see
 .BR feature_test_macros (7)):
 .in
 .ad l
-.sp
+.PP
 .BR asctime_r (),
 .BR ctime_r (),
 .BR gmtime_r (),
 .BR localtime_r ():
 .RS
-_POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
-_SVID_SOURCE || _POSIX_SOURCE
+_POSIX_C_SOURCE
+    || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
 .RE
 .ad
 .SH DESCRIPTION
@@ -95,21 +91,21 @@ separated into year, month, day, and so on.
 .PP
 Broken-down time is stored
 in the structure \fItm\fP, which is defined in \fI<time.h>\fP as follows:
-.sp
+.PP
 .in +4n
-.nf
+.EX
 struct tm {
-    int tm_sec;    /* Seconds (0-60) */
-    int tm_min;    /* Minutes (0-59) */
-    int tm_hour;   /* Hours (0-23) */
-    int tm_mday;   /* Day of the month (1-31) */
-    int tm_mon;    /* Month (0-11) */
-    int tm_year;   /* Year - 1900 */
-    int tm_wday;   /* Day of the week (0-6, Sunday = 0) */
-    int tm_yday;   /* Day in the year (0-365, 1 Jan = 0) */
+    int tm_sec;    /* Seconds (0\-60) */
+    int tm_min;    /* Minutes (0\-59) */
+    int tm_hour;   /* Hours (0\-23) */
+    int tm_mday;   /* Day of the month (1\-31) */
+    int tm_mon;    /* Month (0\-11) */
+    int tm_year;   /* Year \- 1900 */
+    int tm_wday;   /* Day of the week (0\-6, Sunday = 0) */
+    int tm_yday;   /* Day in the year (0\-365, 1 Jan = 0) */
     int tm_isdst;  /* Daylight saving time */
 };
-.fi
+.EE
 .in
 .PP
 The members of the \fItm\fP structure are:
@@ -152,11 +148,13 @@ is equivalent to
 .BI asctime(localtime( t )) \fR.
 It converts the calendar time \fIt\fP into a
 null-terminated string of the form
-.sp
-.RS
-"Wed Jun 30 21:49:08 1993\\n"
-.RE
-.sp
+.PP
+.in +4n
+.EX
+"Wed Jun 30 21:49:08 1993\en"
+.EE
+.in
+.PP
 The abbreviations for the days of the week are "Sun", "Mon", "Tue", "Wed",
 "Thu", "Fri", and "Sat".
 The abbreviations for the months are "Jan",
@@ -246,7 +244,7 @@ and a negative value means that
 .BR mktime ()
 should (use timezone information and system databases to)
 attempt to determine whether DST is in effect at the specified time.
-
+.PP
 The
 .BR mktime ()
 function modifies the fields of the
@@ -266,7 +264,7 @@ Calling
 .BR mktime ()
 also sets the external variable \fItzname\fP with
 information about the current timezone.
-
+.PP
 If the specified broken-down
 time cannot be represented as calendar time (seconds since the Epoch),
 .BR mktime ()
@@ -275,13 +273,55 @@ returns
 and does not alter the
 members of the broken-down time structure.
 .SH RETURN VALUE
-Each of these functions returns the value described, or NULL
-(\-1 in case of
-.BR mktime ())
-in case an error was detected.
+On success,
+.BR gmtime ()
+and
+.BR localtime ()
+return a pointer to a
+.IR "struct\ tm" .
+.PP
+On success,
+.BR gmtime_r ()
+and
+.BR localtime_r ()
+return the address of the structure pointed to by
+.IR result .
+.PP
+On success,
+.BR asctime ()
+and
+.BR ctime ()
+return a pointer to a string.
+.PP
+On success,
+.BR asctime_r ()
+and
+.BR ctime_r ()
+return a pointer to the string pointed to by
+.IR buf .
+.PP
+On success,
+.BR mktime ()
+returns the calendar time (seconds since the Epoch),
+expressed as a value of type
+.IR time_t .
+.PP
+On error,
+.BR mktime ()
+returns the value
+.IR "(time_t)\ -1" .
+The remaining functions return NULL on error.
+On error,
+.I errno
+is set to indicate the cause of the error.
+.SH ERRORS
+.TP
+.B EOVERFLOW
+The result cannot be represented.
 .SH ATTRIBUTES
 For an explanation of the terms used in this section, see
 .BR attributes (7).
+.ad l
 .TS
 allbox;
 lbw14 lb lbw31
@@ -311,7 +351,7 @@ T{
 .BR localtime ()
 T}     Thread safety   MT-Unsafe race:tmbuf env locale
 .TE
-
+.ad
 .SH CONFORMING TO
 POSIX.1-2001.
 C89 and C99 specify
@@ -346,7 +386,7 @@ The thread-safe versions,
 and
 .BR localtime_r (),
 are specified by SUSv2.
-
+.PP
 POSIX.1-2001 says:
 "The
 .BR asctime (),
@@ -360,26 +400,25 @@ a broken-down time structure and an array of type
 Execution of any of the functions may overwrite the information returned
 in either of these objects by any of the other functions."
 This can occur in the glibc implementation.
-.LP
+.PP
 In many implementations, including glibc, a 0 in
 .I tm_mday
 is interpreted as meaning the last day of the preceding month.
-.LP
+.PP
 The glibc version of \fIstruct tm\fP has additional fields
-.sp
-.RS
-.nf
-long tm_gmtoff;           /* Seconds east of UTC */
+.PP
+.in +4n
+.EX
 const char *tm_zone;      /* Timezone abbreviation */
-.fi
-.RE
-.sp
+.EE
+.in
+.PP
 defined when
 .B _BSD_SOURCE
 was set before including
 .IR <time.h> .
 This is a BSD extension, present in 4.3BSD-Reno.
-
+.PP
 According to POSIX.1-2004,
 .BR localtime ()
 is required to behave as though