Borland C++ reference

localtime

raw OCR

Converts date and time to a structure.

Defined in header <time.h>

Syntax

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

Portability

DOSUNIXWindowsANSI CC++ only
■■■■

Remarks

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

The global long variable timezone should be set to the difference in seconds between GMT and local standard time (in PST, timezone is 8x60x60). The global variable daylight should be set to nonzero only if the standard U.S. daylight saving time conversion should be applied.

The tm structure declaration from the time.h include file follows:

struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; }; These quantities give the time on a 24-hour clock, day of month (1 to 31), month (0 to 11), weekday (Sunday equals 0), year - 1900, day of year (0 to 365), and a flag that is nonzero if daylight saving time is in effect.

Return value

localtime returns a pointer to the structure containing the broken-down time. This structure is a static that is overwritten with each call.

See also

Example

#include <time.h>
finclude <stdio.h>
#include <dos.h>
int main(void)
{
   time_t timer;
   struct tm *tblock;

   /* gets time of day */
   timer = time (NULL);
   /* converts date/time to a structure  */
   tblock = localtime (&timer);
   printf("Local time is: %s", asctime (tblock));
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.