localtime_r

From RAD Studio
Jump to: navigation, search

Go Up to time.h Index


Header File

time.h

Category

Time and Date Routines

Prototype

struct tm *localtime_r( const time_t *timer, struct tm *buf );

Description

Converts date and time to a structure.

localtime_r accepts the address of a value returned by time and returns a pointer to the structure of type tm containing the time elements. It corrects for the time zone and possible daylight saving time.

For the tm structure please see localtime.

Return Value

localtime_r returns result if successfull, or null otherwise.

Example

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
  time_t t = time(NULL);
  struct tm tmbuf;
  char buf[30];
  printf("UTC:       %s", asctime_r(gmtime_r(&t, &tmbuf), buf));
  printf("local:     %s", asctime_r(localtime_r(&t, &tmbuf), buf));
}

Portability

POSIX Win32 ANSI C ANSI C++

+

+

+

+

See Also