1ASCTIME(3P)                POSIX Programmer's Manual               ASCTIME(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       asctime, asctime_r - convert date and time to a string
13

SYNOPSIS

15       #include <time.h>
16
17       char *asctime(const struct tm *timeptr);
18
19
20       char *asctime_r(const struct tm *restrict tm, char *restrict buf);
21
22

DESCRIPTION

24       For asctime():   The functionality described on this reference page  is
25       aligned  with the ISO C standard. Any conflict between the requirements
26       described here and the ISO C standard is unintentional. This volume  of
27       IEEE Std 1003.1-2001 defers to the ISO C standard.
28
29       The asctime() function shall convert the broken-down time in the struc‐
30       ture pointed to by timeptr into a string in the form:
31
32
33              Sun Sep 16 01:03:52 1973\n\0
34
35       using the equivalent of the following algorithm:
36
37
38              char *asctime(const struct tm *timeptr)
39              {
40                  static char wday_name[7][3] = {
41                      "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
42                  };
43                  static char mon_name[12][3] = {
44                      "Jan", "Feb", "Mar", "Apr", "May", "Jun",
45                      "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
46                  };
47                  static char result[26];
48
49
50                  sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
51                      wday_name[timeptr->tm_wday],
52                      mon_name[timeptr->tm_mon],
53                      timeptr->tm_mday, timeptr->tm_hour,
54                      timeptr->tm_min, timeptr->tm_sec,
55                      1900 + timeptr->tm_year);
56                  return result;
57              }
58
59       The tm structure is defined in the <time.h> header.
60
61       The asctime(),  ctime(),  gmtime(),  and  localtime()  functions  shall
62       return  values  in one of two static objects: a broken-down time struc‐
63       ture and an array of type char. Execution of any of the  functions  may
64       overwrite the information returned in either of these objects by any of
65       the other functions.
66
67       The asctime() function need not be reentrant. A function  that  is  not
68       required to be reentrant is not required to be thread-safe.
69
70       The  asctime_r()  function  shall  convert  the broken-down time in the
71       structure pointed to by tm into a string (of  the  same  form  as  that
72       returned  by  asctime())  that  is  placed  in the user-supplied buffer
73       pointed to by buf (which shall contain at  least  26  bytes)  and  then
74       return buf.
75

RETURN VALUE

77       Upon  successful  completion,  asctime()  shall return a pointer to the
78       string.
79
80       Upon successful completion, asctime_r() shall return  a  pointer  to  a
81       character  string  containing the date and time. This string is pointed
82       to by the argument buf. If  the  function  is  unsuccessful,  it  shall
83       return NULL.
84

ERRORS

86       No errors are defined.
87
88       The following sections are informative.
89

EXAMPLES

91       None.
92

APPLICATION USAGE

94       Values  for  the  broken-down time structure can be obtained by calling
95       gmtime() or localtime(). This function is  included  for  compatibility
96       with  older  implementations,  and  does not support localized date and
97       time formats.  Applications should use strftime()  to  achieve  maximum
98       portability.
99
100       The  asctime_r()  function  is thread-safe and shall return values in a
101       user-supplied buffer instead of possibly using a static data area  that
102       may be overwritten by each call.
103

RATIONALE

105       None.
106

FUTURE DIRECTIONS

108       None.
109

SEE ALSO

111       clock(),  ctime(),  difftime(),  gmtime(), localtime(), mktime(), strf‐
112       time(), strptime(), time(), utime(), the  Base  Definitions  volume  of
113       IEEE Std 1003.1-2001, <time.h>
114
116       Portions  of  this text are reprinted and reproduced in electronic form
117       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
118       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
119       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
120       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
121       event of any discrepancy between this version and the original IEEE and
122       The  Open Group Standard, the original IEEE and The Open Group Standard
123       is the referee document. The original Standard can be  obtained  online
124       at http://www.opengroup.org/unix/online.html .
125
126
127
128IEEE/The Open Group                  2003                          ASCTIME(3P)
Impressum