localtime64_r() — Convert Time (Restartable)
Format
#include <time.h>
struct tm *localtime64_r(const time64_t *timeval, struct tm *result);
Language Level
ILE C Extension
Threadsafe
Yes
Locale Sensitive
The behavior of this function might be affected by the LC_TOD category of the current locale.
Description
This function is the restartable
version of localtime64()
. It is the same as localtime64()
except
that it passes in the place to store the returned structure result.
Note:
- The
gmtime64()
andlocaltime64()
functions might use a common, statically allocated buffer for the conversion. Each call to one of these functions might alter the result of the previous call. Theasctime_r()
,ctime64_r()
,gmtime64_r()
, andlocaltime64_r()
functions do not use a common statically allocated buffer to hold the return string. These functions can be used in place of theasctime()
,ctime64()
,gmtime64()
, andlocaltime64()
functions if thread safety is desired. - Calendar time is the number of seconds that have elapsed since EPOCH, which is 00:00:00, January 1, 1970 Universal Coordinate Time (UTC).
- The supported date and time range for this function is 01/01/0001 00:00:00 through 12/31/9999 23:59:59.
Return Value
The localtime64_r()
function
returns a pointer to the structure result. If the given timeval is
out of range, a NULL pointer is returned and errno is set to EOVERFLOW.
Example
This example queries the system
clock and displays the local time.
#include <stdio.h>
#include <time.h>
int main(void)
{
struct tm newtime;
time64_t ltime;
char buf[50];
ltime = time64(<ime);
localtime64_r(<ime, &newtime);
printf("The date and time is %s\n", asctime_r(&newtime, buf));
}
/************** If the local time is 3 p.m. February 15, 2008, **********
************************* the output should be: *********************
The date and time is Fri Feb 15 15:00:00 2008
*/
Related Information
- asctime() — Convert Time to Character String
- asctime_r() — Convert Time to Character String (Restartable)
- ctime64() — Convert Time to Character String
- ctime64_r() — Convert Time to Character String (Restartable)
- gmtime64() — Convert Time
- gmtime64_r() — Convert Time (Restartable)
- localtime64() — Convert Time
- mktime64() — Convert Local Time
- time64() — Determine Current Time
- <time.h>