Format
#include <time.h> struct tm *localtime_r(const time_t *timeval, struct tm *result);
Language Level: XPG4
Threadsafe: Yes,
Description
This function is the restartable version of localtime(). It is the same as localtime() except that it passes in the place to store the returned structure result.
Return Value
The localtime_r() returns a pointer to the structure result. There is no error return value.
Example that uses localtime_r()
This example queries the system clock and displays the local time.
#include <time.h> #include <stdio.h> int main(void) { struct tm newtime; time_t ltime; char buf[50]; ltime=time(<ime); localtime_r(<ime, &newtime); printf("The date and time is %s", asctime_r(&newtime, buf)); } /************** If the local time is 3:00 p.m. May 31, 1993, ********** ************************* output should be: ********************* The date and time is Mon May 31 15:00:00 1993 */
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.