localtime_r() — 변환 시간(다시 시작 가능)
형식
#include <time.h>
struct tm *localtime_r(const time_t *timeval, struct tm *result);
언어 레벨
XPG4
스레드세이프
예
로케일 감지
이 함수의 작동은 현재 로케일의 LC_TOD 범주에 영향을 받을 수 있습니다.
설명
이 함수는 localtime()의 다시 시작 가능한 버전입니다. 리턴된 구조 결과를 저장하기 위한 위치로 전달되는 점을 제외하고 localtime()와 동일합니다.
리턴값
localtime_r()은 구조 결과에 대한 포인터를 리턴합니다. 오류 리턴 값은 없습니다.
예
이 예는 시스템 클럭을 쿼리하고, 로컬 시간을 표시합니다.
#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 p.m. February 15, 2008, **********
************************* the output should be: *********************
The date and time is Fri Feb 15 15:00:00 2008
*/