localtime, localtime_r

Converts a time value to local time.

Library:LibC
Classification:ANSI
Service:Time

Syntax

  #include <time.h> 
   
  struct tm *localtime (
     const time_t  *calendar);
  
  
  struct tm *localtime_r (
     const time_t   *calendar, 
     struct tm      *localtime);
  

Parameters

calendar

(IN) Points to the time, in seconds since the epoch began, to convert into local time.

localtime

(OUT) Points to a tm structure for the converted time.

Return Values

Returns a pointer to the tm structure containing the time information.

Remarks

The localtime and localtime_r functions convert the time in seconds since the epoch began into a structure of time information expressed as local time. Local timezone information and any seasonal time adjustments are used in the conversion.

The structure returned is reused every time that localtime is called.

The localtime_r function provides the same functionality as localtime, but localtime_r is designed for use with reentrant NLM applications. The localtime_r function allows the caller to pass storage for the results rather than relying on per-thead data

See Also