Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Oct 2005 21:31:57 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, Andre Oppermann <andre@FreeBSD.org>, cvs-all@FreeBSD.org
Subject:   Re: Timekeeping [Was: Re: cvs commit: src/usr.bin/vmstat vmstat.c src/usr.bin/w w.c] 
Message-ID:  <20051022205219.O1843@epsplex.bde.org>
In-Reply-To: <34506.1129974516@critter.freebsd.dk>
References:  <34506.1129974516@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 22 Oct 2005, Poul-Henning Kamp wrote:

> In message <20051022185422.Q8268@delplex.bde.org>, Bruce Evans writes:
>
>> What's a UTC delta?  Deltas don't (shouldn't) depend on the calendar.
>
> As easy as it would be to stick our head in the sand, ignore
> international treaties,geophysics and astronomy, point to POSIX and
> ignore leapseconds, it is not an feasible way out for us as an
> operating system project.
>
> UTC deltas does depend on the calendar for now.

Um, my question was rhetorical.  We don't have times in UTC, so calandars
are irrelvant.  If we had times in UTC, then the right way to determine
the delta time seems to be to convert the times to time_t's using timegm(),
then subtract using difftime().  Times in UTC cannot be simply be subracted
by subtracting in minutes and multiplying by 60, etc.  But we can just use
difftime().  Provided difftime() actually works.

> There is proposal from USA to make them DTRT pending in ITU-R Working
> Party 7A, but it is meeting fierce opposition from astronomers and
> geophysicists who hold the position that we can just ignore computers

They already DTRT IMO.  It is what the astronomers want.

> Until the future of leapseconds are resolved, something that could
> easily take 25 years, we have to deal with them.
>
> So an UTC offect contains any leap seconds we are aware off, and
> consequently, it depends on the calendar.

Sure, but we don't have UTC.  We have broken time_t's for real times
but non-broken time_t's for monotonic times.  To subtract these times,
the opposite methods to the ones stated by Andre should work (but
don't): numerical deltas don't work for either UTC or real times --
they don't work for UTC because UTC isn't numeric, and they don't
work for real times since POSIX left out the leap seconds -- difftime()
should work for subtracting real times; OTOH, numerical deltas work
for monotonic times while difftime() doesn't -- although difftime()
takes time_t's as args you can't pass the time_t's given by
CLOCK_MONOTONIC to it, since the latter are differences relative to
an undocumented start time but difftime() only handles absolute times.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051022205219.O1843>