
Seth Kurtzberg
The difficulty, if it exists, comes from converting the absolute time into calendar time, but even that isn't really difficult. The firmware in a GPS receiver does it. So it is clearly not impossible.
It can do it because it gets the current TAI-UTC offset (strictly speaking, GPS-UTC offset, where GPS time is in a fixed relation to TAI) from the satellite, together with the timestamp. It cannot convert arbitrary future times. Nobody can, because leap seconds are only known 6 months in advance. As opposed to a GPS receiver, a Haskell program doesn't usually have access to a timer from which one can reconstruct TAI algorithmically.
Why is it unreasonable to ask the library to tell me the correct answer from, say, the current time to some time in the future?
How is the time in future specified? If it's absolute TAI seconds, then the library can indeed tell it; the program could as well compute it itself, because it's a trivial subtraction of two numbers. If it's yyyy-mm-dd hh:mm:ss, then a reasonable library can't answer this with sure when the future time is at least 6 months after a version of the Haskell implementation has been released, installed, and used to compile the program. POSIX time is indeed not suitable for exact calculations of timespans with a precision of seconds and the length of months. They are suitable for calculating in terms of minutes and larget units for arbitrarily large spans (because a day is always 86400 POSIX seconds) and for storing yyyy-mm-dd hh:mm:ss UTC timestamps in the past and in the future (except that *during* a leap second it's off by one second). They can also measure the length of a timespan shorter than 6 months with is exact or 1 second too long / too short - for most programs the rare error of one second is tolerable. OTOH TAI is suitable for exact measuring the length of timespans, and for nothing else. It's not suitable for converting timestamps to/from yyyy-mm-dd hh:mm:ss, until a system-wide automatically-updated leap second table is designed and implemented, unless you don't mind having to release, download and install a Haskell compiler and recompile all programs every 6 months. Under the same conditions it's not suitable for getting the *current* time, accurate to a second, because the system clock shows POSIX time; nor for getting the last-modified time of a file, because it's also POSIX time. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/