And before I reinvent the wheel, does anyone have the source code to a
portable version of gmtime() that does in fact take leap seconds into
account?
Please respond by e-mail in addition to posting, if possible.
Thanks,
Ed
Second, in fact, paying attention to leap seconds is a violation of the POSIX
standard. That is, the POSIX definitions of the various time-related
functions ignore leap seconds, and any C library which pays attention to them
is in violation of the standards.
Third, the time function that are in the Linux libc deal with leap seconds,
and I'm sure they're free :-), so you can download the source code to them and
take a look to see if they originate there or if they're actually part of some
other package that is integrated into the Linux libc (I suspect the latter).
>First of all, gmtime() is governed by POSIX specs, not by ISO or ANSI specs.
ANSI C "7.12.3.3 The gmtime function"
POSIX defers to ANSI C for the definition of gmtime(). The tm_sec member
of a struct tm is permitted a range of 0 to 61 under ANSI C so leap
seconds are supported. However ANSI C doesn't define the representation of a
time_t value whereas POSIX, to a great extent, does. I don't know the
exact details but it would be that definition that prevents leap seconds
being supported.
>Second, in fact, paying attention to leap seconds is a violation of the POSIX
>standard. That is, the POSIX definitions of the various time-related
>functions ignore leap seconds, and any C library which pays attention to them
>is in violation of the standards.
>
>Third, the time function that are in the Linux libc deal with leap seconds,
>and I'm sure they're free :-), so you can download the source code to them and
>take a look to see if they originate there or if they're actually part of some
>other package that is integrated into the Linux libc (I suspect the latter).
LINUX is supposedly POSIX compliant. Then by your argument above its standard
library cannot support leap seconds at least not when used in a POSIX
conforming mode.
--
-----------------------------------------
Lawrence Kirby | fr...@genesis.demon.co.uk
Wilts, England | 7073...@compuserve.com
-----------------------------------------
Yes, I believe that's where it occurs. I believe that it specifies the
algorithm by which a time_t value is converted to a date, and that algorithm
assumes that time_t 0 is 1/1/1970 00:00:00 GMT and that time increases in
sixty-second minutes from that point forward forever.
|> LINUX is supposedly POSIX compliant. Then by your argument above its standard
|> library cannot support leap seconds at least not when used in a POSIX
|> conforming mode.
LINUX isn't "POSIX-complaint", per se, since only one Linux distribution
(Linux-FT) has been tested for compliance, and that distribution made numerous
changes to standard Linux software in order to obtain compliance. It's
entirely possible that they ripped out the leap second support in order to
pass the POSIX tests. Or that they didn't try to obtain full POSIX
compliance, and therefore weren't tested in this particular way. Or that the
POSIX tests missed this one :-).
Also, a Linux system without a file recording leap seconds *will* handle time
in a POSIX-compliant way, since if no leap seconds are defined, time will
behave as POSIX requires. It's just that if some goes ahead and adds leap
seconds to the configuration of the system, it will no longer be
POSIX-complaint. Therefore, it wouldn't surprise me at all if Linux-FT passed
the compliance tests simply by not configuring leap seconds, but leaving the
funcionality in so that their users can configure them in (and thereby "break"
POSIX compliance) if they desire.
A version of Linux has been certified to conform to FIPS 151-2. It's
not necessary to speculate about what might have been tested, because
the source code of the NIST POSIX test suite tells the story.
A system that corrects for leap seconds in gmtime() will definitely
fail the NIST test.
>Also, a Linux system without a file recording leap seconds *will* handle time
>in a POSIX-compliant way, since if no leap seconds are defined, time will
>behave as POSIX requires. It's just that if some goes ahead and adds leap
>seconds to the configuration of the system, it will no longer be
>POSIX-complaint. Therefore, it wouldn't surprise me at all if Linux-FT passed
>the compliance tests simply by not configuring leap seconds, but leaving the
>funcionality in so that their users can configure them in (and thereby "break"
>POSIX compliance) if they desire.
The right way to handle this is to provide a separate set of
functions for use in those programs where leap seconds make a
difference.
--
Chuck Karish kar...@mindcraft.com
(415) 323-9000 x117 kar...@pangea.stanford.edu
What's your point? ISO has standards for POSIX.1 (9945-1) and for
C (9989). The ISO C standard specifies the behavior of gmtime().
The C Standard doesn't consider leap seconds at all. An implementation
can conform whether or not it handles leap seconds.
POSIX.1 says that time() returns the number of seconds since the
Epoch (4.5.1.2), and gives an algorithm relating the result to UCT that
ignores leap seconds (2.2.2.77). Use of this algorithm by the
time manipulation functions of the C Standard is mandated in 8.1.
There is no fixed schedule for leap seconds - they are inserted as needed, when
this wobbly old earth gets too far out of sync with the atomic clocks. (or vice
versa). There have been 11 since 1980, I believe (the last one was last Dec.
31.)
Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
Internet: ben...@triumf.ca | of one another only when one can be
Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
or: http:://vancouver-webpages.com/peter/index.html
--
Bill Marcum bma...@iglou.com
"Even the samurais have teddy bears, and even the teddy bears get drunk"
(don't ask me what it means, it came from the 'fortune' program).
There is no "algorithm". A leap second is inserted or removed when the body
which governs such things determines that it is necessary to do so in order to
bring our clocks into sync with the rotation of the Earth.
The Earth's rotation time isn't precisely constant. Leap seconds correct for
the variability.
The newsgroup where discussion of the mechanics of leap seconds is least
inappropriate (I'm not even sure it's appropriate there) is sci.astro, so I've
directed followups there.
I may as well point out again that these requirements are mutually
contradictory. As soon as you talk specifically about UTC rather than
some other flavor of UT, you are requiring leap seconds to be taken
into account. However, I'm informed that the intent clearly was to
require that they be ignored.
Someone else asked when leap seconds happen. There is not a pre-set
schedule; it depends on the measured rotation of the Earth. At the
moment they tend to be roughly every 2 years.
--
Mark Brader, m...@sq.com "Logic is logic. That's all I say."
SoftQuad Inc., Toronto -- Oliver Wendell Holmes
My text in this article is in the public domain.
What do you mean by "removing" leap seconds?
----------------------------------------------------------------------
Bob Goudreau Data General Corporation
goud...@dg-rtp.dg.com 62 Alexander Drive
+1 919 248 6231 Research Triangle Park, NC 27709, USA
> why should the OS make any special allowance for leap seconds?
> When they occur, aren't they handled by manually resetting the system clock
In some applications, it's convenient if the real-time difference
between two time()-return-values S and T is (S - T) seconds.
If you artificially reset the system clock at every leap second,
you lose this relationship.
Posix 1003.1-1990 does not allow for such applications,
since Posix requires that the clock ignore leap seconds,
but if you're willing to run in non-Posix mode,
many operating systems support leap seconds.
I believe BSDI, FreeBSD, Linux, NetBSD, and SunOS all support
leap seconds if you're willing to configure them correctly;
see the -l option to the zic command.
The POSIX no-leap-second restriction only applies to gmtime(), and to
localtime() and mktime() when used with TZ=UCT0. It allows time-related
functions other than gmtime() to account for leap seconds when TZ has
other values (such as TZ=GMT0BST, or I think even with TZ=GMT0).
--
Geoff Clare <g...@root.co.uk>
UniSoft Limited, London, England.
The formal mechanism allows for "negative leap seconds", i.e. for the 60th
second of a minute to be removed. This eventuality has not been necessary
since leap seconds were introduced in 1972.
-- Bill Owen, w...@wansor.jpl.nasa.gov
1) What does this question have to do with comp.unix.programmer? The fact
that you do not read sci.astro is not a reasonable justification for
continuing to post off-topic articles in comp.unix.programmer. If you have
some interest in the thread and you want to keep following it, then subscribe
to sci.astro temporarily.
2) The leap-second system doesn't only involve *adding* seconds, it also
involves *deleting* them. That is, if the rotation of the Earth is slower
than our clocks think it's supposed to be, then we have to add a second
occasionally to keep our clocks in sync with the Earth. However, if the
rotation is *faster* than our clocks think it's supposed to be, then we have
to *remove* a second to keep our clocks in sync.
I don't believe we've actually done the latter since the leap-second system
was instituted (although I could be wrong), but there are provisions for it if
it should ever become necessary.
Followups once again directed to sci.astro.
In principle, we can have a day which is 86399 seconds long.
This has never happened so far as I know, but we're ready
if the earth's rotation starts speeding up. I believe the
second to be omitted would be 23:59:59-24:00:00 of either
June 30 or December 31, but it might be the first second of the
next day.
Tom McGlynn
t...@silk.gsfc.nasa.gov
Actually, 1003.1b-1993 and, I think, 1003.1-1990 are arguably
self-contradictory in this matter. 1003.1b-1993 says
2.2.2.106 seconds since the Epoch: A value to be interpreted as
the number of seconds between a specified time and the Epoch.
and defines the Epoch as:
2.2.2.32 Epoch: The time 0 hours, 0 minutes, 0 seconds, Januray
1, 1970, Coordinated Universal Time.
which could be read as implying that "seconds since the Epoch" increases
by one every second, regardless of leap seconds, thus making the
real-time difference between two "time()" return values S and T (S-T)
seconds, but 2.2.2.106 also says:
A Coordinated Universal Time name (specified in seconds
(tm_sec), minutes (tm_min), hours (tm_hour), days since January
1 of the year (tm_yday), and calendar year minus 1900 (tm_year)
is related to a time represented as seconds since the Epoch,
according to the expression below:
If the year < 1970 or the value is negative, the relationship is
undefined. If the year >= 1970 and the value is nonnegative,
the value is related to a Coordinated Universal Time name
according to the expression:
tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400+
(tm_year-70)*31536000 + ((tm_year-69)/4)*86400
which I think might imply that "seconds since the Epoch" can't count the
number of seconds since the Epoch, if a UTC name for a leap second has
"tm_sec" equal to 60, as the UTC value
1977-12-31 23:59:60
would turn into a "time_t" of
60 + 59*60 + 23*3600 + 364*86400+ 7*31536000 + 2*86400
or 252460800, and what I think is the UTC value for the next second:
1978-01-01 00:00:00
would turn into a "time_t" of
0 + 0*60 + 0*3600 + 0*86400 + 8*31536000 + 2*86400
or 252460800, meaning you *do* have to shift the clock backwards.
The 1003.1b-1993 Rationale says:
Most systems' notion of "time" is that of a continuously
increasing value, so this value should increase even during leap
seconds. However, not only do most systems not keep track of
leap seconds, but most systems are probably not synchronized to
any standard time reference. Therefore, it is inappropriate to
require that a time represented as seconds since the Epoch
precisely represent the number of seconds between the referenced
time and the Epoch.
which doesn't seem to clearly state whether "seconds since the Epoch"
should increase during leap seconds or not - the first sentence seems to
say it should, but the second sentence mentions, for some reason, leap
seconds, but without explicitly stating that it should *not* increase
during leap seconds.
Later, though, it asserts:
It is important that the interpretation of time names and
"seconds since the Epoch" values be consistent across conforming
systems. That is, it is important that all conforming systems
intepret "536 457 599 seconds since the Epoch" as 59 seconds, 59
minutes, 23 hours 31 December 1986, regardless of the accuracy
of the system's idea of the current time. The expression is
given to assure a consistent interpretation, not to attempt to
specify the calendar. The relationship between "tm_yday" and
the day of week, day of month, and month is presumed to be
specified elsewhere and is not given in POSIX.1.
Consistent interpretation of "seconds since the Epoch" can be
critical to certain types of distributed applications that rely
on such timestamps to synchronize events. The accural of leap
seconds in a time standard is not predictable. The number of
leap seconds since the Epoch will likely increase. POSIX.1 is
more concerned about the synchronization of time between
applications of astronomically short duration. These concerans
are expected to be more critical in the future.
However, *I* sure wouldn't recommend writing such an application to use
time stamps represented as UTC names; *I*'d recommend using seconds
since some particular fixed instant in time (not necessarily the Epoch,
given that, for example, the Internet Time Protocol (RFC868) uses
seconds since 00:00:00 UTC, January 1, 1900). Given that, leap seconds
simply don't become an issue.
I.e., I'm not sure why any sanely-written distributed application
relying on timestamps to synchronize events should *care* about leap
seconds, and, as such, am not sure why POSIX needed to specify anything
about them (other than specifying that they *should* be taken into
account, and pointing to the Olson code as an implementation that *does*
take them into account, when converting between "time_t"s and "struct
tm"s).
>but if you're willing to run in non-Posix mode,
>many operating systems support leap seconds.
>I believe BSDI, FreeBSD, Linux, NetBSD, and SunOS all support
>leap seconds if you're willing to configure them correctly;
>see the -l option to the zic command.
SunOS 4.x and, as far as I know, 5.x *don't* support leap seconds. (In
retrospect, I should've left the leap-second code in there, and said "we
don't provide leap seconds files because the POSIX folks have said, for
some reason for which they don't appear to have provided any factual
support, 'POSIX systems should pretend that leap seconds don't exist'",
or something such as that, in the man page.)
Here's a table of UTC - TDT, beginning with the introduction of the redefined
UTC on 1972 Jan 1. The interval over which each value is valid begins at the
time to its left. (If I could move the values of UTC - TDT down half a line,
it might make better sense.) The current value is 62.184 s.
1972 JAN 42.184
1972 JUL 43.184
1973 JAN 44.184
1974 JAN 45.184
1975 JAN 46.184
1976 JAN 47.184
1977 JAN 48.184
1978 JAN 49.184
1979 JAN 50.184
1980 JAN 51.184
1981 JUL 52.184
1982 JUL 53.184
1983 JUL 54.184
1985 JUL 55.184
1988 JAN 56.184
1990 JAN 57.184
1991 JAN 58.184
1992 JUL 59.184
1993 JUL 60.184
1994 JUL 61.184
1996 JAN 62.184
-- Bill Owen, w...@wansor.jpl.nasa.gov
This is correct -- the second that would be omitted is the last second of
the month.
In principle leap seconds can be placed at the end of *any* month, but in
practice they have always been at the end of June or December.
And it's correct that there have been no "negative leap seconds" yet.
-- Bill Owen, w...@wansor.jpl.nasa.gov
: 1) What does this question have to do with comp.unix.programmer? The fact
: that you do not read sci.astro is not a reasonable justification for
: continuing to post off-topic articles in comp.unix.programmer. If you have
: some interest in the thread and you want to keep following it, then subscribe
: to sci.astro temporarily.
Don't get your panties in a bunch. What it has to do with c.u.p is
the same topic mentioned earlier in this thread: How are UNIX system
utilities supposed to accommodate the vagaries of leap seconds? Just
because you felt the need to redirect followups away from the original
newsgroup doesn't mean that the rest of us need follow your dictate.
: 2) The leap-second system doesn't only involve *adding* seconds, it also
: involves *deleting* them. That is, if the rotation of the Earth is slower
: than our clocks think it's supposed to be, then we have to add a second
: occasionally to keep our clocks in sync with the Earth. However, if the
: rotation is *faster* than our clocks think it's supposed to be, then we have
: to *remove* a second to keep our clocks in sync.
There's nothing surprising about that, but the practice you describe
does *not* fall under the heading of Leap Second Removal. What you
are talking about is the removal of an *ordinary* second. (A leap
second could be removed only if it existed in the first place!) When
you first broached the topic of removing leap seconds, I thought you
were referring to some sort of process wherein leap seconds that had
been previously added to the calendar were later removed retroactively.
I am gratified to discover that this is not the case.
At any rate, has any work been done on incorporating the addition
(and removal) of seconds into standard UNIX time libraries? I would
think that the Olsen approach of isolating non-algorithmic timezone
information into files that can be examined by the appropriate
library routines would also be a good way to identify which minutes
get 61 (or 59) seconds. As with the timezone data, the leap second
table would have to be updated periodically to accommodate the latest
batch of administrative decrees on the subject.
Bob Goudreau (goud...@dg-rtp.dg.com) wrote:
: Jonathan Kamens (j...@annex-1-slip-jik.cam.ov.com) wrote:
: : In article <4loe9f$d...@dg-rtp.dg.com>, goud...@dg-rtp.dg.com (Bob Goudreau) writes:
: At any rate, has any work been done on incorporating the addition
: (and removal) of seconds into standard UNIX time libraries? I would
: think that the Olsen approach of isolating non-algorithmic timezone
: information into files that can be examined by the appropriate
: library routines would also be a good way to identify which minutes
: get 61 (or 59) seconds. As with the timezone data, the leap second
: table would have to be updated periodically to accommodate the latest
: batch of administrative decrees on the subject.
I can see this causing problems. If a program calculates some time in the
future using a particular version of the leap second table, and then the
table is updated then the calculation could be invalidated. One would need
probably need to keep real-times(including leap seconds) separate from
calendar-times(excluding leap seconds) and be careful about which one is
working with.
--
Stephen Baynes bay...@ukpsshp1.serigate.philips.nl
Philips Semiconductors Ltd
Southampton My views are my own.
United Kingdom
Are you using ISO8859-1? Do you see © as copyright, ÷ as division and ½ as 1/2?
In article <4mbq15$q...@electra.saaf.se>, pau...@electra.saaf.se (Paul Schlyter) writes:
|> Also, why should one assume that the UNIX time system is in UTC? It
|> could just as well be assumed to be another time system, without leap
|> seconds, such as UT0/1/2, TT or TAI.
|>
The "unix time system" isn't in anything. There's just this thing called
an epoch which is really just an instant in time which you can specify in
any time system you choose to. In UTC it's 00:00:00 Jan 1, 1970. The
time() system call just returns the number of seconds from that instant in
time.
All the confusion arises because the timestamp conversion routines, which
convert the time() value (number of seconds from the epoch) to a UTC +-
timezone offset expression, don't take leap seconds into account,
so we and things like network time (synching) protocols adjust the unix
epoch rather than fix the timestamp conversion routines.
The so called epoch is really 00:00:20 Jan 1, 1970 UTC at this
point (if I counted those leap seconds correctly).
--
Joe Seigh se...@bose.com
--
Joe Seigh se...@bose.com
ps> In article <4m5l3t$c...@dg-rtp.dg.com>,
ps> Bob Goudreau <goud...@dg-rtp.dg.com> wrote:
>> At any rate, has any work been done on incorporating the addition
>> (and removal) of seconds into standard UNIX time libraries?
ps> Would it be worth the trouble? After all, computer clocks are
ps> usually off by at least several tens of seconds, and to worry
ps> about leap seconds in such a situation seems to not be
ps> worthwhile.
Aha! Obviously a time-newbie! :)
In fact, any shop where they care about such things (which should be,
but isn't, all of them) will be running NTP (Network Time Protocol) on
their network, and syncing all their system clocks together--and to
either a radio clock locally or some system(s) on the Internet which has
them.
You should get offsets on the order of (much?) less than a second using
this method... and every host has the same time. An absolute must for
any shop that uses timestamps as important info.
See comp.protocols.time.ntp or http://www.eecis.udel.edu/~ntp/ for more
details.
ps> Also, why should one assume that the UNIX time system is in UTC?
ps> It could just as well be assumed to be another time system,
ps> without leap seconds, such as UT0/1/2, TT or TAI.
No, it couldn't. UNIX time has been defined to be based on UTC (GMT)
since the early 1970's, AFAIK. Certainly every UNIX system I've ever
worked on (since 1984) has been. This is now formalized in POSIX, as
well. To be more specific, when you call the UNIX time system calls,
the value you get back is always given as UTC (or local time, defined
as an offset to UTC).
--
-------------------------------------------------------------------------------
Paul D. Smith <psm...@baynetworks.com> Network Management Development
Senior Software Engineer Bay Networks, Inc.
-----------------------------------------------==<http://www.baynetworks.com/>-
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions--Bay Networks takes no responsibility for them.
The time interval, the second, is determined by collecting
results from a wide variety of cesium standards and hydrogen
masers. This is called the atomic second and is the base for the
TAI, or Atomic International Time.
I just finished analyzing the latest TAI stability data from
BIPM.
As of December 28,1995, the HP 5071A Primary Frequency Standard
became the dominant part of the BIPM timebase. Of the 176
weighted clocks, exactly one-half, or 88, are HP 5071A units, 76
high performance, and 12 standard performance.
The 88 clocks are 50% of the total but contribute 71.1% of the total
weight in the BIPM timebase.
If we also add the 44 HP 5061A/B clocks, we have 75% of the
weighted clocks and 82.3% of the total weight. This is an
all-time dominance of TAI. The earlier HP atomic clocks, the
5060A, 5061A, and 5061B never achieved this milestone.
In an abstract of an invited paper to be presented to the 1996
International Frequency Control Symposium, Madame Claudine
Thomas, the director of timing services at the BIPM, states that
"Since the end of 1992, the quality of timing data received at
the BIPM has evolved rapidly thanks to the extensive replacement
of older designs of commercial caesium clocks by the new HP 5071A
units." Her talk goes on to document almost an order of
magnitude improvement in the stability of the atomic second
because of the new standards.
--
Speaking for myself from experience
PS: I thought we had a leap second on February 29th once?
> Does POSIX also formalize how to handle leap seconds?
Yes. Posix requires that you ignore leap seconds, in the sense that time_t
values count the number of seconds since the Epoch, ignoring leap seconds.
By the way, Posix erroneously says that the Epoch is 1970-01-01 00:00:00 UTC,
a time that never existed (since UTC began in 1972).
The Posix specifiers were not expert about time....
> This means that unless leap seconds are accounted for, the function
> difftime() cannot be trusted to return an accurate value.
As far as I can tell, it would be valid for a Posix implementation of
difftime to account for leap seconds. I don't know of any that do,
however: they all just subtract time_t values. Perhaps you could propose
an enhancement to the free tz implementation (see
ftp://elsie.nci.nih.gov/pub/tz*). It already has an option to support
leap seconds in a non-Posix-compliant way (see below),
but this has proved less than popular because of the dead hand of Posix,
and perhaps there's a better way that's more Posix-compliant.
(Alas, the only ways that I can see require help from the underlying
system calls, though.)
> And in your locale you should be able to
> specify that you want the time given in, say, UT2, TT, or TAI instead,
> since then you can trust the results from difftime() and friends.
That _is_ supported by the free tz implementation. For example,
in BSD/OS 1.1 I can set my TZ environment variable to
'right/US/Pacific', and then time_t values will use TAI
(plus a Unix-friendly offset). This doesn't conform to Posix, though.
>I would suggest that the requirement "the time is in UTC" is dropped
>and replaced by "the time is in UT2".
First of all, lets be totally clear from the start: leap seconds are a
*user interface* issue. They only exist to maintain some a lock
between our best time-pieces and the wobbly rotation of the Earth and the
sense of "time" the creatures that happen to inhabit it. Like us. And
(do I have to say it?), user interface crap doesn't belong in operating
system kernels.
Ok.
The "problem" with UTC not existing in 1970 is pedantic -- like, who cares?
If it is such a big deal, then I reckon that the use of the "Julian Day" be
deemed equally bogus, since the Julian calendar simply did not exist
in 4713BC.
So, no (or maybe I will yell it: NO!), the time_t should not be in UT2.
The reason is that *all* implementations of the time_t is that of a
continuously increasing counter. One click per second. So when 1996
rolled in, I am totally confident that not one single "POSIX compliant"
(assuming such a thing exists) computer system anywhere halted its counter
for a single second, in due respect to Ye Olde POSIX Standard, with maybe
a touch of reverence for the Leap Second itself.
So if any redefinitions are to be made, I'd say it would be more appropriate
to redefine time_t to be in TDT (or, better yet, lets think ahead: TDB).
Looking at my copy of the POSIX spec [ya I know: get a life :-/], and the
equation they give, this "fits" alot better. And we do not surrender the
fundamental notion that the ticks of the time_t are real, honest-to-god
hard "seconds" as experienced by the computer -- not the squishy,
variable-length seconds of UT2.
That in hand, we proceed to add, or modify, an entry point that can provide
the current value of delta-T, delta-UTC, etc. And then move on to modify
ctime(), localtime(), etc, to use this information to present the time
in whatever format the caller wishes. Where such transformations belong.
-mdf
"Althought TAI was officially introduced in January 1972, it has been available
since July 1955" according to the _Explanatory Supplement_ (page 40). My
understanding is that it really came on-line in 1958, at which time it was set
to what was then known as Universal Time ("Coordinated Universal Time" or UTC
wasn't adopted until 1972). The difference between ET and UT in January '58
was later determined to have been 32.184 seconds. Consequently TAI lags TDT
(the successor to ET) by 32.184 seconds, and UTC lags TDT by (32.184 + N)
seconds, where N is the accumulated number of leap seconds -- currently 20.
> The lack of a physical model for the long term rotation of the Earth can make
> things hairy in planetarium programs; one thing that I use to check the
> accuracy of planetaria is to check out the Sun on 5900 Jul 11 Wed 20:46 TDT;
> at that time (according to Meeus, Venus will be in the exact center of the Sun
> "the least distance of the centers, which will be approximately zero at 20h
> 46m (Ephemeris Time)" during the transit. My planetarium (the old ATARI)
> showed Venus transiting the Sun on that day, but not centrally and 4h 30m
> earlier than Meeus.
>
> Personally I think planetarium should use TDT (former Ephemeris Time) for
> computing motions of other planets and UTC for determining altaazimuth
> coordinates; a time in the distant past or future, such as the abovementioned
> Meeusian date, should be read as TDT for RA and Dec.
True enough. This is exactly why time measurements were bifurcated into UT
and ET originally -- the earth's rotation is too irregular to be used as the
independent variable in the planetary equations of motion.
> Chris Carrier
>
>
> PS: I thought we had a leap second on February 29th once?
>
Possible under the rules, but it hasn't happened.
-- Bill Owen, w...@wansor.jpl.nasa.gov
: : At any rate, has any work been done on incorporating the addition
: : (and removal) of seconds into standard UNIX time libraries? I would
: : think that the Olsen approach of isolating non-algorithmic timezone
: : information into files that can be examined by the appropriate
: : library routines would also be a good way to identify which minutes
: : get 61 (or 59) seconds. As with the timezone data, the leap second
: : table would have to be updated periodically to accommodate the latest
: : batch of administrative decrees on the subject.
:
: I can see this causing problems. If a program calculates some time
: in the future using a particular version of the leap second table,
: and then the table is updated then the calculation could be
: invalidated. One would need probably need to keep real-times
: (including leap seconds) separate from calendar-times (excluding
: leap seconds) and be careful about which one is working with.
But this is no different than the problem that already exists now
with ever-changing Daylight Savings Time rules! Any representation
of a future time (say, Mon May 5 15:51:31 BST 1997) can only be
assuming that the currently-understood DST rules will continue to
apply at the future date. As various governments continually change
their rules, the chosen time-point's representation may change.
Remember that UNIX systems measure time primarily in terms of time_t
values, which are the number of seconds since an arbitrary epoch.
Strings such as those produced and used by commands like date(1) and
cron(1) are only *representations* of underlying time_t values.
----------------------------------------------------------------------
>Sure -- but the generation of the timer count isn't an operating system
>kernel task - it belongs to the device driver of the timer device. The
>kernel just shuffles on the time to whoever requests it.
This is one way you can think of it -- but in most kernels, I suspect,
The Time is run off a timer interrupt, and the time() system call is
nothing but a simple copy. The only operating system that matters :),
Linux, does as much.
For the lucky few who have atomic clocks in their basement, or are cheating
and using GPS (ie, stealing time from the US military), a driver
of some sort may be useful. But it would be wise that any such driver
return TDT, or TAI, or something sensible. Encoding calendars into
drivers, or kernels, is very silly. Something we have come to expect from
Microsoft -- UNIX people ought to, and by-and-large do, have more sense.
(The POSIX committee re: time notwidthstanding).
>This comparison is not valid. Julian Day numbers, as well as B.C. years,
>weren't defined back then, but they're defined NOW! UTC is different:
>even today it's not defined prior to 1972!
???
Argh! I can't remember the name of the guy that "invented" this idea.
(Actually, the Mayan's came up with it centuries earlier, but whatever).
But whoever it was, back in the 1500's(?), rather than concern himself
with the problem that the Julian calendar -- or likely any useful
calendar -- didn't exist in 4713BC, he just up and propogated a known
calendar way back into the past. And why not? His intent wasn't to give
meaning to "April 13, 3984BC". Just to define a count of "days", and
make sure in most cases, the number is positive.
If the lack of UTC before 1972 is a big deal, the answer is simple: you
just define that at 1972 Jan 1 00:00:00 UTC, the value of time_t
is <whatever>. But this is just another way of propogating UTC back
before 1972.
The POSIX spec, by the way, does exactly this. Unfortunately, rather than
1972, some random date in 1986 is used.
>Here you're saying that all POSIX compliant clocks gains one second
>relative to UTC, whenever there's a leap second in UTC. But I'm positive
>some system administrator later sets it back to the real UTC -- what you
>then really have is some approximation to UT2, plus/minus one second.
It is undeniable that some system-administrator input is required. But
this is true UTC or TDT. With UTC, the poor guy has to reset the time 1
second when a leap second occurs. After the fact. With a TDT definition,
she will have to update the /etc/leapseconds file and re-run 'zic'. But
the nice thing with this option is that it can be done *before* the fact.
And, even nicer, the fundamental time-scale is left untouched, ever
ticking away.
>Not a good suggestion! TAI is much better since it's available
>immediately. TDT/TDB are only available after some delay
But TDT = TAI + 32.184s.
>You get variable length seconds anyway when the system administrators set
>back the system clock one second after a leap second has occurred.
Well, as I've pointed out, we have the technology, by simply running a sed
script over the POSIX spec:
s/UTC/TDT/
s/Universal Coordinated Time/Terrestrial Dynamical Time/
...
to "define away" this problem. Anyone who is running the Olson/Harris
TZ code, and is using a leapseconds file, has more or less done exactly
this. Technically, not a POSIX compliant system. But who wants to
comply with a flawed specification?
Yes and no. In theory you are correct, but you assume that all existing
programs that do callender time/date arithmetic do it on a struct tm
rather than a time_t (which any ISO C conforming program would do), but
I suspect there are lots of programs that do arithmetic on time_t and
expect the result to be predictable in calender time. For example adding
60 to increase the time by one minute (so 23:59:32 => 00:00:32 )
"Olson code", please. Arthur Olson was the original implementor; I was
just one of many who subsequently contributed to the code - Robert Elz,
Bradley White (who did the leap second stuff), Paul Eggert, etc. also
contributed to the code (and many many others contributed to the data
files). See the "README" file in the "tzcode" part of the package.
> Paul Eggert writes:...
> > As far as I can tell, it would be valid for a Posix implementation of
> > difftime to account for leap seconds.
> It would be impossible to do generally.
``Impossible'' is pretty strong. Posix doesn't require time_t to be an
integral type. If time_t was a float type, you could assign a time_t
value of X+0.5 to the leap second, where X is the previous second.
difftime(X+0.5, X) would yield 1, since difftime would know about leap seconds.
I'm not saying that it would be a good idea to do it this way, just
that it's possible.
>I would suggest that the requirement "the time is in UTC" is dropped
>and replaced by "the time is in UT2".
An interesting suggestion, but it's too late to make this change.
More likely the Posix committees will add new facilities to have proper timers.
I hope they do it better this time around. (It would be nice if they
would allow an implementation to supply a UT2-based clock, for example.)
> The "problem" with UTC not existing in 1970 is pedantic -- like, who cares?
Perhaps; but if you're writing a standard you should make it tight
enough to satisfy people who need accurate time.
For example, the Posix spec could be rewritten to have an origin that
is a valid UTC time, and times before UTC existed (which have less
practical importance) could be some other approximation which is
historically valid far back into the past. Some people do care about
this sort of thing -- and it's not just astronomers.
> when 1996 rolled in, I am totally confident that not one single
> "POSIX compliant" (assuming such a thing exists) computer system
> anywhere halted its counter for a single second
Your confidence is unwarranted. See comp.protocols.time.ntp, for example.
> If the lack of UTC before 1972 is a big deal, the answer is simple: you
> just define that at 1972 Jan 1 00:00:00 UTC, the value of time_t
> is <whatever>....
> The POSIX spec, by the way, does exactly this. Unfortunately, rather than
> 1972, some random date in 1986 is used.
Which Posix spec are you referring to? Posix 1003.1-1990 section
2.2.2.24 page 13 lines 153-154 defines the Epoch to be ``The time 0
hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal
Time''. As far as I know this error hasn't been corrected in later
editions.
: If the lack of UTC before 1972 is a big deal, the answer is simple: you
: just define that at 1972 Jan 1 00:00:00 UTC, the value of time_t
: is <whatever>. But this is just another way of propogating UTC back
: before 1972.
: The POSIX spec, by the way, does exactly this. Unfortunately, rather than
: 1972, some random date in 1986 is used.
References, please? I don't see anything in any revision of the
POSIX.1 spec that uses a date in 1986 for an anchor. But, section
2.2.2.24 of POSIX.1-1990 defines the Epoch as:
The time 0 hours, 0 minutes, 0 seconds, January 1, 1970,
Coordinated Universal Time.
>Which Posix spec are you referring to? Posix 1003.1-1990 section
The same one:
"That is, it is important that all conforming systems
interpret '536457899 seconds since the Epoch' as
59 seconds, 59 minutes, 23 hours 31 December 1986 [...]"
(page 200, lines 628-629). This page, btw, is rather buggy. The
correct intent is there; just that whoever wrote it was obviously
confused over what leap seconds really are ...
-mdf
That quote is from Annex B, which is not a normative part of the standard --
it is merely informative. It is commentary designed to make it easier
to understand the intent of the standard. `536457899' is merely an example.
See the Introduction, page x, lines 46-49, for a definition of ``informative''.
The relevant normative part of the standard is section 2.2.2.24;
this section refers to the (nonexistent) time 1970-01-01 00:00:00 UTC.
This is the part of the standard that is incorrect and needs fixing.
I think the intent of the standard is clear for UTC times;
what's not clear is what to do for times before UTC was established.
Yes, but this is all rather a moot point since they keep moving the epoch. It's
not 1970-01-01 00:00:00 whatever but 1970-01-01 00:00:20. In fact, if we wait
until enough leap seconds have been added the epoch really will be when UTC was
defined to be in effect.
I used to think that adjusting the epoch to compensate for the buggy timestamp
conversion routines was bogus, but now I think it's rather ingenius. Say you
want the time_t value for 5 days from now. You can use "time() + 5*24*60*60"
and it will work because if a leap second did occur between then and now the
epoch will be adjusted to make it work. That's totally fabulous. No more
worrying about leap seconds. Pretend they don't exist.
In fact, I think we should extend that technique to leap days. Just add 365
days to get 1 year from now and epoch adjustment will take care of the rest if
need be. No more dealing with leap year calculations.
Ok. Ok. So it won't work one day every four years or so. But if we turned off
all the computers on that day...
Joe Seigh se...@bose.com
egg...@twinsun.com (Paul Eggert) wrote:
>Which Posix spec are you referring to? Posix 1003.1-1990 section
Matthew Francey <m...@presence.lglobal.com> wrote:
>The same one:
>
> "That is, it is important that all conforming systems
> interpret '536457899 seconds since the Epoch' as
> 59 seconds, 59 minutes, 23 hours 31 December 1986 [...]"
>
>(page 200, lines 628-629). This page, btw, is rather buggy.
It's also not part of the POSIX spec.
It's part of the *Rationale* for the POSIX spec. It's just an
*example*.
jEFF
32 seconds. TAI is 32.184 seconds behind TDT.
-- Bill Owen, w...@wansor.jpl.nasa.gov
> In article <4mujjk$f9i$2...@mhadf.production.compuserve.com>, Chris Carrier <72157...@CompuServe.COM> writes:
> > What is the current difference between UTC and TAI, with UTC and TDT 62.184
> > seconds apart? (as they are now).
> >
>
> 32 seconds. TAI is 32.184 seconds behind TDT.
And maybe I oughta go back to second grade, or at least wake up on Monday
mornings before I post! 62.184 - 32.184 = 30.
-- Bill Owen, w...@wansor.jpl.nasa.gov
That enhancement needs to be made anyway to solve the problem
of programs that calculate durations making incorrect measurements
when the Unix time is adjusted.
A sample of a quick way to do this with backward compatibility is:
Add a new system call, uptime(2), that returns the number
of clock ticks since the system booted [or seconds and clock
ticks, whatever].
Add a kernel variable, boottime, which stores the difference
between the values that should be returned by uptime(2) verses
time(2) [or gettimeofday(2/3), whatever]. This value would
start out as the value from time(2) when the system booted and
would rarely change.
Change sdate(2) [and settimeofday(2/3)] [and therefore date(1)]
so that it just updates the boottime variable.
Over time, change programs that compute durations from computing
the difference between values returns by time(2) to computing
the difference between values returns by uptime(2).
I would think some Unixes would have separated the time of day
clock from the system real-time clock by now, but I'm not aware of
any.
I'd probably have NTP daemons mess with boottime and leave the
clock tick counter alone. I love running "traceroute" on my
server that is running NTP and watch the "time tunnelling"
response packets that arrive _before_ the query packet is sent.
Long durations would be calculated with a little less accuracy,
but the gain in consistancy is probably worth that.
--
Tye McQueen t...@metronet.com || t...@thingy.usu.edu
Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
> For the latest status concerning leap seconds in UTC, send e-mail to
> ads...@tycho.usno.navy.mil with a Subject: line of 'leap' and no
> text. You will receive in reply a list of past and provisional future
> leap seconds.
I just tried this e-mail address, and it returned an incorrect response
(it did not include the most recent leap second, at the start of this
year). How long does it typically take this service to reflect the
most recent activity?
---
Jeffrey W Percival
Space Astronomy Laboratory, University of Wisconsin - Madison
1150 University Ave, Madison, WI 53706 USA
(608)262-8686 j...@sal.wisc.edu http://www.sal.wisc.edu/~jwp
Reposting this. The original seems to have gotten lost.
In article <1996May1...@bose.com>, I wrote :
|> Of course, there are worse things in unix, like no time zone
|> indicators in the /etc/dumpdates file. You _have_ been making sure
|> those file systems have been quiesced for an hour after you dumped
|> them, haven't you?
Hmm... Maybe you're all off the hook on this one. I though I had sort
of investigated this one once before. mktime() even returns the
earlier of the two possible time_t values for the one hour of the year
that ambiguity even exists, the alternate time zone no less.
However, strptime() really is broken, which is why I have been a
little leery of timestamps without timezone indicators. It's setting
tm_isdst one higher than it should. Decrement tm_isdst by one before
you call mktime() and it seems to work better.
But it doesn't appear to be the case that dump/restore is calling
strptime(). If it is, it is correcting tm_isdst.
--
Joe Seigh se...@bose.com