localtime_s

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_s(const time_t * _RESTRICT clock, struct tm * _RESTRICT result);

Description

Converts date and time to a structure.

localtime_s 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_s returns result if successfull, or null otherwise.

Example

#include <time.h>
#include <stdio.h>
int main(void)
{
   time_t timer;
   struct tm tblock;
   /* gets time of day */
   timer = time(NULL);
   /* converts date/time to a structure */
   localtime_s(&timer, &tblock);
   printf("Local time is: %s", asctime(&tblock));
   return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

+

+

+

+

See Also