Open
Conversation
To avoid float precision mistake, e.g. 42988.99999999999 (11 September 2017) should be parsed same as 42989.0 to match with date time parser and excel behaviour
Author
|
Found some strange behaviour of ruby Date object: d = Date.new(2017, 9, 11) + 15/24r
# d => #<Date: 2017-09-11 ((2458008j,54000s,0n),+0s,2299161j)>
# ^ fractional part, 54,000 seconds
# in rails it will be printed as "Mon, 11 Sep 2017"
# no time info
d.to_time # => 2017-09-11 00:00:00 +0800
d.to_datetime # => #<DateTime: 2017-09-11T00:00:00+00:00 ((2458008j,0s,0n),+0s,2299161j)>
d == Date.parse("Mon, 11 Sep 2017") # => false (difficult to understand reason)
# has time info
d.strftime("%F %T %z") # => "2017-09-11 15:00:00 +0000"
d.day_fraction # => (5/8)Imo it's difficult to understand that date may have fractional part, especially in rails What do you think? |
chopraanmol1
suggested changes
Mar 13, 2019
Contributor
chopraanmol1
left a comment
There was a problem hiding this comment.
Thank you for opening this PR. Can you add a relevant test case for this? Adding test case will ensure that this case is covered in the future as well.
chopraanmol1
suggested changes
Mar 28, 2019
Contributor
chopraanmol1
left a comment
There was a problem hiding this comment.
LGTM. Can you add a relevant test case to cover this scenario?
Author
|
Sorry, I'm not familiar with your testing setup |
Author
|
Could you give a hint on how to make tests? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To avoid float precision mistake, e.g. 42988.99999999999 (11 September 2017) should be parsed same as 42989.0 to match with date time parser and excel behaviour
Fixes #500