HP C/iX Library Reference Manual (30026-90004)
234 Chapter5
HP C/iX Library Function Descriptions
localtime
localtime
Converts time to the local time zone.
Syntax
#include <time.h>
struct tm *localtime (const time_t *
timer
);
Parameters
timer
A pointer to a variable of type time_t.
Return Values
x A pointer to a structured time variable of type tm.
Description
The localtime function is passed a pointer to a time_t variable whose value is typically
set by the time function. The localtime function converts this value into the structured
tm format expressed in local time, corrected for daylight saving time if applicable, and
returns a pointer to the structure.
By default, localtime() adjusts the return value to Eastern Standard Time (EST). You
may control this by using the MPE/iX command SETVAR TZ
name
. Time zone names, and
the format of TZTAB.LIB.SYS file containing offsets from UTC (Coordinated Universal
Time) are listed in appendix A, "Time Zones."
Example
The following code fragment assigns values to the tm structure members for the local time
zone:
#include <time.h>
…
struct tm *ptr, *localtime();
int time(), nseconds;
…
nseconds = time(NULL);
Once this code is executed, you can use ptr to access the different components of the local
time. For example, ptr -> tm_mon references the month of the year, and ptr -> tm_wday
references the day of the week.
See Also
time(), ctime(), ANSI C 4.12.3.4, POSIX.1 8.1