Hi Hugs-team, I found several divergences of the module Time of Hugs (v. Nov 2002 for Linux) from the Haskell Report which can't be found neither in the list of known Hugs bugs nor in the list of differences from Haskell 98 (the latter is also too old and claims that Time is not yet available). 1. The report specifies that the field ctSec of datatype CalendarTime must be exported outside the module. In Hugs, this field is missing from the exports list. 2. The report requires (see the end of the penultimate paragraph before the library starts) that " toClockTime l converts l [...] ignoring the contents of the ctWDay , ctYDay , ctTZName , and ctIsDST fields". Hugs, however, does not ignore ctIsDST . 3. Additionally, the behaviour of the function diffClockTime is strange in Hugs. In the returned record, at most two fields are non-zero: tdSec and tdPicosec . Thereby, tdSec is of type Int which leads to incorrect value in the case of big time differences. The report is amazingly tongue-tied at this point, so it is even difficult to argue that your implementation is diverging. It seems natural to think however that this behaviour is not what was expected. I solved this problem by changing the type of tdSec to be Integer . But this created a new divergence from the report. 4. There seem to be problems with dates before year 1970. I attach my version of Time.hs to this mail, perhaps it helps you somewhat (the places of change are documented with today's date). (Handling dates before 1970 has not been added there.) The report on Time is really funny. It specifies that "Pre-Gregorian dates are inaccurate". So if your implementation handles pre-Gregorian dates accurately then it does not implement the Haskell 98 language correctly :) Best regards, Härmel Nestra (researcher of University of Tartu, Estonia)
On Tue, Aug 26, 2003 at 05:53:32PM +0200, Härmel Nestra wrote:
I found several divergences of the module Time of Hugs (v. Nov 2002 for Linux) from the Haskell Report which can't be found neither in the list of known Hugs bugs nor in the list of differences from Haskell 98 (the latter is also too old and claims that Time is not yet available).
Thanks for the bug report.
1. The report specifies that the field ctSec of datatype CalendarTime must be exported outside the module. In Hugs, this field is missing from the exports list.
This is already fixed in the development version, which uses the same Time module as GHC.
2. The report requires (see the end of the penultimate paragraph before the library starts) that " toClockTime l converts l [...] ignoring the contents of the ctWDay , ctYDay , ctTZName , and ctIsDST fields". Hugs, however, does not ignore ctIsDST .
It is wierd: it constructs an argument using ctIsDST, and then the primitive evaluates that argument but ignores its value. I'll remove the argument from the primitive.
3. Additionally, the behaviour of the function diffClockTime is strange in Hugs. In the returned record, at most two fields are non-zero: tdSec and tdPicosec . Thereby, tdSec is of type Int which leads to incorrect value in the case of big time differences. The report is amazingly tongue-tied at this point, so it is even difficult to argue that your implementation is diverging. It seems natural to think however that this behaviour is not what was expected.
Unfortunately this (tdSec::Int) is a known bug in the Haskell 98 Report, which we must slavishly follow.
4. There seem to be problems with dates before year 1970.
That sounds like a Posix problem.
Ross Paterson wrote:
4. There seem to be problems with dates before year 1970.
That sounds like a Posix problem.
That sounds like a signed-ness problem. The underlying C functions
should handle dates prior to the epoch (those corresponding to a
negative time_t value).
For a 32-bit time_t, the range of valid times is (in UTC):
Seconds YYYY-MM-DD hh:mm:ss
-2147483648 1901-12-13 20:45:52
2147483647 2038-01-19 03:14:07
--
Glynn Clements
participants (3)
-
Glynn Clements -
Härmel Nestra -
Ross Paterson