[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] where to fetch local time
Hi,
On Sat, Nov 25, 2000 at 08:33:12PM +0100, Andreas Schwab wrote:
> Martin-Éric Racine <q-funk@pp.fishpool.fi> writes:
>
> |> Hello!
> |>
> |> I'm just wondering, what's the correct call to fetch local time
> |> when the kernel itself is running in UTC?
>
> Use localtime(3).
The kernel calls Tgettime (Gemdos) resp. Gettime (XBIOS) always return
local time (in the broken-down Gemdos format) and Tgettimeofday
(MiNT) always returns the time in UTC (as seconds since the epoch).
More exactly, Tgettimeofday returns 0 on success and a negative error code
on failure (can't happen). The current time as seconds since the epoch
is written into the struct timeval buffer that the caller has to provide.
Using localtime(3) has the one advantage of being portable, within and
outside the realm of MiNT.
The library functions ftime(3) and gettimeofday(3) are slightly less
portable but they have a higher resolution (milli resp. microseconds as
opposed to seconds for localtime(3)).
Ciao
Guido