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

NAME

6       ctime, ctime_r - convert a time value to a date and time string
7

SYNOPSIS

9       #include <time.h>
10
11       char *ctime(const time_t *clock);
12
13
14       char *ctime_r(const time_t *clock, char *buf);
15
16

DESCRIPTION

18       For  ctime():    The  functionality described on this reference page is
19       aligned with the ISO C standard. Any conflict between the  requirements
20       described  here and the ISO C standard is unintentional. This volume of
21       IEEE Std 1003.1-2001 defers to the ISO C standard.
22
23       The ctime() function shall convert the time pointed to by clock, repre‐
24       senting time in seconds since the Epoch, to local time in the form of a
25       string. It shall be equivalent to:
26
27
28              asctime(localtime(clock))
29
30       The asctime(),  ctime(),  gmtime(),  and  localtime()  functions  shall
31       return  values  in one of two static objects: a broken-down time struc‐
32       ture and an array of char. Execution of any of the functions may  over‐
33       write the information returned in either of these objects by any of the
34       other functions.
35
36       The ctime() function need not be reentrant.  A  function  that  is  not
37       required to be reentrant is not required to be thread-safe.
38
39       The  ctime_r()  function  shall convert the calendar time pointed to by
40       clock to local time in exactly the same form as  ctime()  and  put  the
41       string  into  the  array  pointed to by buf (which shall be at least 26
42       bytes in size) and return buf.
43
44       Unlike ctime(), the thread-safe version ctime_r() is  not  required  to
45       set tzname.
46

RETURN VALUE

48       The  ctime()  function  shall  return the pointer returned by asctime()
49       with that broken-down time as an argument.
50
51       Upon successful completion, ctime_r() shall return  a  pointer  to  the
52       string  pointed to by buf. When an error is encountered, a null pointer
53       shall be returned.
54

ERRORS

56       No errors are defined.
57
58       The following sections are informative.
59

EXAMPLES

61       None.
62

APPLICATION USAGE

64       Values for the broken-down time structure can be  obtained  by  calling
65       gmtime()  or localtime(). The ctime() function is included for compati‐
66       bility with older implementations, and does not support localized  date
67       and  time  formats.  Applications should use the strftime() function to
68       achieve maximum portability.
69
70       The ctime_r() function is thread-safe and  shall  return  values  in  a
71       user-supplied  buffer instead of possibly using a static data area that
72       may be overwritten by each call.
73

RATIONALE

75       None.
76

FUTURE DIRECTIONS

78       None.
79

SEE ALSO

81       asctime() , clock() , difftime() , gmtime() , localtime() , mktime()  ,
82       strftime()  , strptime() , time() , utime() , the Base Definitions vol‐
83       ume of IEEE Std 1003.1-2001, <time.h>
84
86       Portions of this text are reprinted and reproduced in  electronic  form
87       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
88       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
89       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
90       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
91       event of any discrepancy between this version and the original IEEE and
92       The Open Group Standard, the original IEEE and The Open Group  Standard
93       is  the  referee document. The original Standard can be obtained online
94       at http://www.opengroup.org/unix/online.html .
95
96
97
98IEEE/The Open Group                  2003                             CTIME(P)
Impressum