localtime

Converts a time value to broken-down local time.

Format

#include  <time.h>

struct tm *localtime  (const time_t *bintim);
Function Variants Compiling with the _DECC_V4_SOURCE and _VMS_V6_SOURCE feature- test macros defined enables a local-time-based entry point to this function that is equivalent to the behavior before OpenVMS Version 7.0.

Argument

bintim
A pointer to a time in seconds since the Epoch. You can generate this time by using the time function or you can supply a time.

Description

This function converts the time (in seconds since the Epoch) pointed to by timer into a broken-down time, expressed as a local time.

The function corrects for the time zone and any seasonal time adjustments. Local time-zone information is used as if localtime called tzset.

The converted time value is placed in a time structure defined in the <time.h> header file with the tag tm. Table 6 describes the member names that are offsets into the structure.

Table 6 Member Names

int tm_sec;  Seconds after the minute (0-60) 
int tm_min;  Minutes after the hour (0-59) 
int tm_hour;  Hours since midnight (0-23) 
int tm_mday;  Day of the month (1-31) 
int tm_mon;  Months since January (1-11) 
int tm_ year;  Years since 1900 
int tm_wday;  Days since Sunday (0-6) 
int tm_yday;  Days since January 1 (0- 365) 
int tm_isdst;  Daylight Savings Time flag

  • tm_isdst = 0 for Standard Time

  • tm_isdst = 1 for Daylight Time
 
long tm_gmtoff;[1]   Seconds east of Greenwich (Negative values indicate seconds west of Greenwich) 
char *tm_zone;[1]   Time zone string, for example "GMT" 

[1] This field is an extention to the ANSI C tm structure. It is present unless you compile your program with /STANDARD=ANSI89 or with _DECC_V4_SOURCE defined.


Note
Return values point to per- thread static storage, which is overwritten by subsequent calls to the localtime function. You must make a copy if you wish to save it.

The type time_t is defined in the <time.h> header file as follows:

typedef long int time_t

Return Value
pointer  A pointer to the time structure. 


Previous Page | Next Page | Table of Contents | Index