[tz] Adapting localtime.c

Guy Harris guy at alum.mit.edu
Sat Oct 8 17:47:59 UTC 2016


On Oct 8, 2016, at 10:27 AM, Carsten Larsen <cs at innolan.dk> wrote:

> I am trying to adapt the tz code to a local system without any timezone database (AmigaOS). I got the code up and running and everything seems to work as intended. But one thing about the code puzzles me.
> 
> I need to implement "time_t time(time_t *p)" which is the very last part of localtime.c.

No, time() is *not* part of localtime.c.

It was originally the UNIX API to get the current time of day, and...

> Should this code return time as local time or as GMT time ?

...it returns the time as "seconds since the Epoch", which, in a POSIX-conforming system, is a count of all the non-leap seconds that have elapsed between January 1, 1970, 00:00:00 UTC and now.  (Yes, non-leap seconds.)

Some non-UNIX systems might implement it as well.  Current UNIX systems also provide it, although it's generally implemented on top of the newer gettimeofday() or clock_gettime() APIs, which provide higher-resolution time values.


More information about the tz mailing list