RE: System.Time.Clock Design Issues

On 03 February 2005 02:54, Ashley Yakeley wrote:
* Should there be a TAI type separate from a POSIX time type that the system clock would return?
My preference is yes. If necessary we could create a third module for TAI time and explicit leap-second handling, which will keep them out of the way for most people. Separate types is more complication, but the alternatives have their own issues:
http://www.haskell.org//pipermail/libraries/2005-February/003049.html I don't think we should have a type for POSIX time. What does it buy you? POSIX time is a broken notion that shouldn't be visible in our library interface. Suppose we just have a TAI time type, plus various calendar types. What goes wrong? Well, you can't accurately convert some TAI times into calendar times and vice versa, in particular all times more than 6 months ahead of the leap second table. Too bad. You can still do accurate calculations on calendar times in the future, and that's what matters. The most common conversion between TAI & calendar time is going to be for the current time, and that will be correct as long as we have an up to date leap second table. Even if we don't have an up to date leap second table, we can still convert from system clock-->TAI-->calendar time, because the leap second calculations cancel out (for a POSIX system clock).
* Should we include a (days,ticks) UTC type separate from the POSIX time type?
I have two reasons for wanting this. Firstly, correctness: the POSIX time type cannot represent leap seconds, whereas this can. Secondly, this holds the result of a useful function that splits POSIX time into the simplest possible date and time parts, which can then be used for converting to various internationalised calendars.
I don't think we need this either, at lesat not in the external interface. Any calculations you can do with this type you can do on a calendar time. Cheers, Simon

In article
<3429668D0E777A499EE74A7952C382D1031906D0@EUR-MSG-01.europe.corp.microso
ft.com>,
"Simon Marlow"
I don't think we should have a type for POSIX time. What does it buy you? POSIX time is a broken notion that shouldn't be visible in our library interface.
Suppose we just have a TAI time type, plus various calendar types. What goes wrong? Well, you can't accurately convert some TAI times into calendar times and vice versa, in particular all times more than 6 months ahead of the leap second table. Too bad. You can still do accurate calculations on calendar times in the future, and that's what matters.
OK, so we have * POSIX time Can do accurate calculations on calendar times. Can store UTC times reliably. Cannot store TAI times reliably. Broken for all leap seconds. * TAI time with limited leap-second table Can do accurate calculations on calendar times. Cannot store UTC times reliably. Can store TAI times reliably. Broken for leap seconds after table runs out. Which of these is better? -- Ashley Yakeley, Seattle WA

you forgot some vital ones On Thu, Feb 03, 2005 at 02:43:50AM -0800, Ashley Yakeley wrote:
* POSIX time
Can do accurate calculations on calendar times. Can store UTC times reliably. Cannot store TAI times reliably. Broken for all leap seconds. cannot represent durations undefined before 1970, muddy definition in the future.
* TAI time with limited leap-second table
Can do accurate calculations on calendar times. Cannot store UTC times reliably. Can store TAI times reliably. Broken for leap seconds after table runs out.
can represent durations defined for all history and future
Which of these is better?
TAI is clearly superior. John -- John Meacham - ⑆repetae.net⑆john⑈

When you say "defined for all history and the future", does that mean literally what it says? It accounts for the adjustments to the Calendar through various centuries, some of which are gaps of over a month (that is, corrections to get the calendar back in the right place, by adding more than a month or skipping more than a month)? I only have one user who bitches about this (he's an archeologist, so he has a reason, although his expectation may not be as reasonable as his reason). I'm not saying this is a requirement, I'm simply asking whether TAI can really handle these situations. Seth P.S.: If anyone receives this message as HTML or as combined plain text/html, please let me know. I think I've got the problem solved as long as haskell.org is in the address, but it may not be solved for addresses in other domains (such as John's above). Thanks, the response will help me troubleshoot. My logs are indicating that something went out as plain text, but I still get complaints that they arrived as html+plain text. TIA John Meacham wrote:
you forgot some vital ones
On Thu, Feb 03, 2005 at 02:43:50AM -0800, Ashley Yakeley wrote:
* POSIX time
Can do accurate calculations on calendar times. Can store UTC times reliably. Cannot store TAI times reliably. Broken for all leap seconds.
cannot represent durations undefined before 1970, muddy definition in the future.
* TAI time with limited leap-second table
Can do accurate calculations on calendar times. Cannot store UTC times reliably. Can store TAI times reliably. Broken for leap seconds after table runs out.
can represent durations defined for all history and future
Which of these is better?
TAI is clearly superior. John

Seth Kurtzberg
When you say [TAI is] "defined for all history and the future", does that mean literally what it says?
Well, as it is only a clock (counting SI seconds), it is unambigously defined. It is not a calendar, so you need a separate calendar to name days and years for you, and to perform the mapping between TAI's seconds and calendar entities. -kzm -- If I haven't seen further, it is by standing in the footprints of giants

Ketil Malde writes:
Seth Kurtzberg
writes: When you say [TAI is] "defined for all history and the future", does that mean literally what it says?
Well, as it is only a clock (counting SI seconds), it is unambigously defined. It is not a calendar, so you need a separate calendar to name days and years for you, and to perform the mapping between TAI's seconds and calendar entities.
As I understand it, TAI and UTC can both be described in terms of a
clock counting SI seconds. The difference is that a TAI day is always
86400 seconds long, whereas a UTC day can be 86399 - 86401 seconds,
depending on which second it is.
Using TAI, we can always convert a date and clock time to a count of
seconds and vice-versa without any additional information. To do the
same with UTC, we need a table of leap-seconds.
--
David Menendez

In article
As I understand it, TAI and UTC can both be described in terms of a clock counting SI seconds. The difference is that a TAI day is always 86400 seconds long, whereas a UTC day can be 86399 - 86401 seconds, depending on which second it is.
Yes.
Using TAI, we can always convert a date and clock time to a count of seconds and vice-versa without any additional information. To do the same with UTC, we need a table of leap-seconds.
No. Date and clock times are usually UTC or some offset (time-zone) thereof. Converting to TAI requires a table of leap-seconds. -- Ashley Yakeley, Seattle WA

Ashley Yakeley wrote:
In article
, David Menendez wrote: As I understand it, TAI and UTC can both be described in terms of a clock counting SI seconds. The difference is that a TAI day is always 86400 seconds long, whereas a UTC day can be 86399 - 86401 seconds, depending on which second it is.
Yes.
Using TAI, we can always convert a date and clock time to a count of seconds and vice-versa without any additional information. To do the same with UTC, we need a table of leap-seconds.
No. Date and clock times are usually UTC or some offset (time-zone) thereof. Converting to TAI requires a table of leap-seconds.
I mentioned this before, but it may have been lost in the shuffle. GPS has a clever way of handling leap seconds even though they are not known in advance. GPS receivers properly handle leap seconds, without firmware updates, even though the specifics (when each leap second occurs) are now known in advance. The general idea is that TAI time is accompanied by a value which is the current difference between TAI and UTC. That in itself is interesting, but more interesting is the fact that it can go both forwards and backwards without a leap second table. This URL has technical information: http://tycho.usno.navy.mil/gps_faq.html The site is a bit old, but the information is still current. It indicates that leap seconds are not the only corrections that are used. The latest unit for the time library (latest I've seen in this thread) is nanoseconds. The URL explains additional corrections required to keep nanosecond time. This may well be overkill for our purposes, but it doesn't hurt to look.

In article <42088CBB.9040801@cql.com>, Seth Kurtzberg
The general idea is that TAI time is accompanied by a value which is the current difference between TAI and UTC. That in itself is interesting, but more interesting is the fact that it can go both forwards and backwards without a leap second table.
We have no way of finding out what this value is. The system clock only gives us UTC. -- Ashley Yakeley, Seattle WA

Ashley Yakeley writes:
In article
, David Menendez wrote: Using TAI, we can always convert a date and clock time to a count of seconds and vice-versa without any additional information. To do the same with UTC, we need a table of leap-seconds.
No. Date and clock times are usually UTC or some offset (time-zone) thereof. Converting to TAI requires a table of leap-seconds.
I should have been more specific. I meant, "we can always convert a date
and clock time specified in TAI to a count of seconds, and vice versa".
--
David Menendez

On 2005-02-08, David Menendez
As I understand it, TAI and UTC can both be described in terms of a clock counting SI seconds. The difference is that a TAI day is always 86400 seconds long, whereas a UTC day can be 86399 - 86401 seconds, depending on which second it is.
No, I believe a UTC day is also always exactly 86400 seconds long. Some seconds may be longer than others (though this happens only at Leap Second events). At least this is how it works in POSIX. -- John

On 2005-02-08, John Goerzen
On 2005-02-08, David Menendez
wrote: As I understand it, TAI and UTC can both be described in terms of a clock counting SI seconds. The difference is that a TAI day is always 86400 seconds long, whereas a UTC day can be 86399 - 86401 seconds, depending on which second it is.
No, I believe a UTC day is also always exactly 86400 seconds long.
Incorrect.
Some seconds may be longer than others (though this happens only at Leap Second events). At least this is how it works in POSIX.
POSIX (stupidly) mandates that 86400 time_t seconds / day, yes. -- Aaron Denney -><-

On Thu, 3 Feb 2005, Simon Marlow wrote:
I don't think we need this either, at lesat not in the external interface. Any calculations you can do with this type you can do on a calendar time.
The problem is that a sane calendar time depends a lot on the application. Forcing physicists and engineers to deal with human constructs like Year and Month seems annoying at the very least! Personally, I would prefer a representation that is very storage efficient and I don't know that "calendar time" would guarantee that. I think we actually have a few different use cases here that it would be helpful to elucidate. Note I am not a user in most of these cases so feel free to refine. This is a strawman. Mathematical Time ----------------- This is an infinitely large, infinitely precise quantity useful only to people doing theoretical stuff. data MathTime = MathTime Integer Rational Note: Calendar overhead seeems really pointless for this userbase. I am not even certain that these people need anything from System.* but am keeping an open mind here. Engineering Time ---------------- Keann's example is building rockets, but the general concept is that we need to compare a system clock at two different times. So the system clock needs to return a duration since some official time in units corresponding to the resolution of the system clock. getClockTime::IO Integer getClockPrecision::IO Units Note: I don't know how to specify units here. Perhaps units are specified in an Integer which identifies the denominator of the smallest measurable fraction of a second. Server Time ----------- For the vast majority of applications we probably want the much more simple: type Seconds=Integer getClockSeconds::IO Integer getClockMillis::IO Integer Here I am a user. I like having a definition like this because I am space constrained and would much prefer to store Ints than whole wasteful CalendarTime constructs. Calendars are important only at the front end. User/Calendar Time ------------------ Different users require different representations of time and duration in different applications. Various calendars would handle leap seconds, timezones, DST, and units for various application contexts. These different sorts of representations should be localized to different libraries like: Calendar.RFC822 Calendar.Julian Calendar.Muslim Calendar.Hebrew Calendar.UTC Calendar.TAI Calendar.Dog The main thing we then need is a standard interface to communicate between them. class CalTime calTime where fromClockTime::->Units->Integer->calTime fromSeconds::Seconds->calTime toSeconds::calTime->Seconds diffCalTime::calTime->calTime->Seconds addCalTime::calTime->Seconds->calTime I hope this makes sense. In any case, it is just a strawman. Burn at will. -Alex- ______________________________________________________________ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
participants (9)
-
Aaron Denney
-
Ashley Yakeley
-
David Menendez
-
John Goerzen
-
John Meacham
-
Ketil Malde
-
S. Alexander Jacobson
-
Seth Kurtzberg
-
Simon Marlow