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

Account for leap year bug; fixes #264 #292

Merged
merged 2 commits into from Mar 13, 2017

Conversation

Projects
None yet
3 participants
@jennybc
Member

jennybc commented Mar 13, 2017

Excel reproduces a bug from Lotus 1-2-3: the non-existent leap day February 29, 1900 is included in the date system. This only affects sheets that use the 1900 date system and dates prior to March 1, 1900.

The proposed fix effectively removes that date. I adjust (increment) date-times on or before February 28, 1900. I convert date-times on February 29 1900 -- a day which does not actually exist -- to NA and throw a warning.

Since knowledge of the date system is now required for both the leap year adjustment and the offset, I store and pass the 1900 vs 1904 indicator around instead of the offset.

Fixes #264 and #148 (already closed as duplicate), if you want to read more about it.

@jennybc jennybc requested a review from hadley Mar 13, 2017

@hadley

hadley approved these changes Mar 13, 2017

src/utils.h Outdated
// If date is *prior* to the non-existent leap day: add a day
// If date is on the non-existent leap day: make negative and, in due course, NA
// Otherwise: do nothing
inline double removeLeapDay(double xlDate) {

This comment has been minimized.

@hadley

hadley Mar 13, 2017

Member

I think this would be slightly easier to follow if you combined these two functions.

This comment has been minimized.

@jennybc

jennybc Mar 13, 2017

Member

Yes good point. Done 2d57d7a

@jennybc jennybc merged commit c9a54ae into tidyverse:master Mar 13, 2017

0 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@jennybc jennybc deleted the jennybc:bugfix-leap-year branch Mar 14, 2017

@wjcgh

This comment has been minimized.

wjcgh commented Apr 20, 2017

Thank you jennybc for making the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment