Converts a time stored as a structure to a character string.
#include <time.h> char *asctime (const struct tm *timedate);
errno_t asctime_s(char *string, rsize_t maxsize, const struct tm *timedate);
#include <wchar.h>
wchar_t *_wasctime(const struct tm *timedate);
errno_t _wasctime_s(wchar_t *string, rsize_t maxize, const struct tm *timedate);
timedate
tm
time/date structure, for example obtained using gmtime or localtime.
string
maxsize
The asctime function converts a time stored as a structure to a character string. The _tm value is usually obtained from a call to gmtime or localtime. Both functions can be used to fill in a tm structure, as defined in TIME.H.
The converted character string is also adjusted according to the local time zone settings.
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.
This function uses a 24-hour clock.
The function uses a single statically allocated buffer to hold the return string. Each call destroys the result of the previous call.
asctime and _wasctime
: a pointer to the character string.
asctime_s and _wasctime_s
: Zero if successful. If there is a failure a non-zero error code is returned. Any of the following conditions cause a failure and the function will return a value of EINVAL:
tchar.h routine |
_UNICODE not defined |
_UNICODE defined |
---|---|---|
_tasctime | asctime | _wasctime |
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 INtime 6.0 (for the wide-character and generic text versions) |
intime/rt/include/time.h intime/rt/include/wchar.h intime/rt/include/tchar.h |
time.h wchar.h tchar.h |
clib.li |