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

Microseconds: fix and testcase for a bug #77

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

Conversation

qrilka
Copy link
Contributor

@qrilka qrilka commented Jan 26, 2015

Added proper zero padding for microseconds in date formatting and a testcase for the bug in parsing those microseconds

@ericbmerritt
Copy link
Member

@qrilka note the CI build failed

@qrilka
Copy link
Contributor Author

qrilka commented Mar 4, 2015

Formatting was fixed and parsing is buggy - I've added a testcase and proper fix needs parsing to be almost rewritten

@ericbmerritt
Copy link
Member

@qrilka any updates on the build failure?

@qrilka
Copy link
Contributor Author

qrilka commented Sep 9, 2015

this build failure was intended - it shows that the parsing code is broken.
I don't use erlware_commons in my projects and I don't have time to rewrite date parsing, sorry...

@ericbmerritt
Copy link
Member

@qrilka ok. I understand now. Thanks. I will see if I can find some time to fix it.

@tsloughter
Copy link
Member

Damn, @ericbmerritt you know what is going on here and what needs fixing?

@ericbmerritt
Copy link
Member

No clue. I need to dig into this. Fortunately, with a good test case its doable. Thanks @qrilka

@qrilka
Copy link
Contributor Author

qrilka commented Nov 2, 2015

@tsloughter the reported problem is that parsing works only for strings with 6(or zero) digits after the comma, the test case supplied shows it failing parsing "2012-12-12T12:12:12.123" incorrectly - not giving 123ms but 123us
and formatting of microseconds was fixed (it has a similar bug)

@erszcz
Copy link
Contributor

erszcz commented Aug 18, 2016

Up!

Example:

> ec_date:tokenise("2016-08-18T09:37:29.000456Z", []).
[2016,45,8,45,18,9,58,37,58,29,46,456,90]

.000456 of a second is not 456 milliseconds, but that's how the fraction is tokenised and interpreted later. Actually, it is interpreted as microseconds. However:

> ec_date:parse("2016-08-18T09:37:29.456+0000").
{{2016,8,18},{9,37,29,456}}

.456 of a second isn't 456 microseconds, but that's how it's interpreted.
More examples - the first result is incorrect, the second causes an error:

> ec_date:parse("2016-08-18T09:37:29.1+0000").
{{2016,8,18},{9,37,29,1}}
> ec_date:parse("2016-08-18T09:37:29.000456Z").
** exception throw: {ec_date,{bad_date,"2016-08-18T09:37:29.000456Z"}}
     in function  ec_date:do_parse/3 (/private/tmp/erlware_commons/_build/default/lib/erlware_commons/src/ec_date.erl, line 106)

@tsloughter
Copy link
Member

Still needs the tests to pass.

@maximvl
Copy link
Collaborator

maximvl commented Jun 26, 2019

It looks like @erszcz's commit covers this exact case

@erszcz
Copy link
Contributor

erszcz commented Jun 26, 2019

#109 which is now merged was based on this commit PR - it does all that's done here and more. I think this PR can be closed now.

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.

5 participants