ISO8601.ml icon indicating copy to clipboard operation
ISO8601.ml copied to clipboard

Tests and bug fixes

Open dsheets opened this issue 9 years ago • 3 comments

This patchset introduces a test suite using alcotest which covers parsing, printing, and roundtripping (composed parsing/printing and printing/parsing).

Bug fixes include:

  • A correct UTC UNIX time is now always returned from parsing instead of a timezone-offset UNIX time.
  • Timezone offsets are now calculated with respect to the time in question rather than the UNIX epoch. The old behavior was applying the local timezone's offset in 1970 to all times in the local timezone. This caused problems in timezones with historical deviations in 1970. For instance, in 1970 in Great Britain, the government tried a British Standard Time experiment which kept the country on DST all year. This experiment ended in 1971 but its effects were being applied to times which do not fall in the duration of the experiment. This is because historical timezone data is available from the tzinfo database that the OS contains and uses to do timezone conversions.
  • When no timezone is specified, the local timezone settings are used as specified in ISO 8601/RFC 3339.
  • Fixed a printing bug with half-hour and other fractional timezones (e.g. in India and Venezuela) which would cause the printed timezone offset to be 1 hour off due to using low-precision floating point printing instead of float truncation.

Features include:

  • If the timezone offset is 0, Z is printed instead of +00:00 as allowed by the standard.
  • Printing functions that do not include timezone parameters or timezone output now provide the local time and *_utc variants have been added to print the UTC timezone-less dates and times.

dsheets avatar Dec 29 '15 17:12 dsheets

Sounds very nice!

I did not review all the PR deeply, but I need to stop for now.

Just a note about commits 08d88ee84a2fdfd3c5b97af7711532ac6b055ba2, 04ec7d662985a72cb8c6799af90bb8a245974f3f and 8c87fa0fc17313d2af77389c05c4ef55365c7a76: Would it be possible to move test-related commit into the https://github.com/sagotch/ISO8601.ml/tree/test branch which already contains some tests? The way tests are organized is a little bit strange, ISO8601 being separated from tests which use the lib as an external lib to test its API. Also, these test are written with OUnit. I would prefer to keep tests depending on one framework only, so unless there is a good point using alcotest instead, I think OUnit should be kept. Otherwise old tests should be converted to use alcotest as well. Never tried alcotest. so I can not tell, what do you think about it?

And I'll double check changes this evening, but for what I saw it looks like very good to me, really.

sagotch avatar Dec 30 '15 09:12 sagotch

Using Z instead of 00:00 could be optional rather than mandatory. One could want to keep some consistency in printing and do not use the Z form.

What do you think about an optional argument for shortening timezone printing? Also, a character would be needed for custom printing format allowing this, but I see no obvious character to do so...

sagotch avatar Dec 30 '15 22:12 sagotch

Do not lose hope, I will find time to review and adapt this PR...

sagotch avatar Feb 27 '17 09:02 sagotch