Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests and bug fixes #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

dsheets
Copy link

@dsheets dsheets commented Dec 29, 2015

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.

@sagotch
Copy link
Collaborator

sagotch commented Dec 30, 2015

Sounds very nice!

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

Just a note about commits 08d88ee, 04ec7d6 and 8c87fa0:
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
Copy link
Collaborator

sagotch commented Dec 30, 2015

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
Copy link
Collaborator

sagotch commented Feb 27, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants