Skip to content

Conversation

@Paxa
Copy link

@Paxa Paxa commented Mar 8, 2019

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

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
@coveralls
Copy link

coveralls commented Mar 8, 2019

Coverage Status

Coverage increased (+0.04%) to 94.403% when pulling e6da217 on Paxa:master into 4ec1104 on roo-rb:master.

@Paxa
Copy link
Author

Paxa commented Mar 8, 2019

Found some strange behaviour of ruby Date object:
if we create Date with fractional part then it will be often ignored but not always:

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
Probably should not use fraction part for date values

What do you think?

Copy link
Contributor

@chopraanmol1 chopraanmol1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@chopraanmol1 chopraanmol1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you add a relevant test case to cover this scenario?

@Paxa
Copy link
Author

Paxa commented Mar 28, 2019

Sorry, I'm not familiar with your testing setup

@Paxa
Copy link
Author

Paxa commented Apr 3, 2019

Could you give a hint on how to make tests?

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.

3 participants