INtime SDK Help
ctime, ctime_s, _wctime, _wctime_s

Converts a time stored as a time_t value to a character string and adjust for local timezone settings. ctime_s, _ctim32_s and _ctim64_s provide more secure versions of the calls.

#include <time.h>

char *ctime (const time_t *timer);
char *_ctime32(const __time32_t *timer); char *_ctime64(const __time64_t *timer);
errno_t ctime_s(char *buffer, rsize_t maxsize, const time_t *timer);
errno_t _ctime32_s(char *buffer, rsize_t maxsize, const __time32_t *timer); errno_t _ctime64_s(char *buffer, rsize_t maxsize, const __time64_t *timer);

#include <wchar.h>

wchar_t *_wctime(const time_t *timer); wchar_t *_wctime32(const __time32_t *timer); wchar_t *_wctime64(const __time64_t *timer);

errno_t _wctime_s(wchar_t *buffer, rsize_t maxsize, const time_t *timer); errno_t _wctime32_s(wchar_t *buffer, rsize_t maxsize, const __time32_t *timer); errno_t _wctime64_s(wchar_t *buffer, rsize_t maxsize, const __time64_t *timer);

Parameters

timer
Pointer to stored time value to convert.
buffer
A pointer to the charater string result. Must be large enough to hold 26 characters.
maxsize
The size of the buffer, in characters.

Remarks

The converted string contains exactly 26 characters and has this form:

Wed Jan 02 02:03:55 1980\n\0

All elements have a constant width. The newline character \n and the null character \0 occupy the last two positions of the string.

A 24-hour clock is used.

Calls to ctime modify the single statically allocated buffer used by gmtime and localtime. Each call to one of these functions destroys the result of the previous call.

ctime also shares a static buffer with asctime. Thus, a call to ctime destroys the results of any previous call to asctime, localtime, or gmtime.

ctime_s does not use the static buffer but the user provides a buffer instead.

ctime is an inline function which evaluates to _ctime32 and time_t is equivalent to __time32_t. If you need to force the compiler to interpret time_t as the new 64-bit _time64_t, you can define _USE_64BIT_TIME_T. Doing this will cause ctime to evaluate to _ctime64. This is recommended to prevent your application from failing after January 18, 2038.

ctime_s is an inline function that evaluates to_ctime32_s and time_t is equivalent to __time32_t. If you need to force the compiler to interpret time_t as the 64-bit _time64_t, you can define the macro _USE_64BIT_TIME_T. Doing this will cause ctime_s to evaluate to _ctime64_s. This is recommended so that your application does not fail after January 18, 2038.

The wide-character functions _wctime, etc., are analogous to the single-characeter functions, but work with wide-character strings.

Return Values

For ctime and related functions, a pointer to the character string result. NULL will be returned if:

For ctime_s and related functions, 0 is returned on success. The value EINVAL will be returned if at least one of the folowing is true:

Generic Text Routines

tchar.h routine _UNICODE not defined _UNICODE defined
_tctime ctime _wctime
_tctime32 _ctime32 _wctime32
_tctime64 _ctime64 _wctime64

Requirements

Versions Defined in Include Link to
INtime 6.0 intime/rt/include/time.h
intime/rt/include/wchar.h
intime/rt/include/tchar.h
time.h
wchar.h
tchar.h
clib.lib
See Also