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

Difference of one day. #264

Closed
stla opened this issue Feb 13, 2017 · 4 comments · Fixed by #292
Closed

Difference of one day. #264

stla opened this issue Feb 13, 2017 · 4 comments · Fixed by #292
Labels
bug an unexpected problem or unintended behavior datetime 📆

Comments

@stla
Copy link

stla commented Feb 13, 2017

Hello,

I create a xlsx file with a "Time" formatting:

library(openxlsx)
dat <- data.frame(A=c(1, 1.5, 1.8))
wb <- createWorkbook()
addWorksheet(wb=wb, sheetName = "Sheet1")
sty <- createStyle(numFmt = "h:mm AM/PM")
addStyle(wb, sheet=1, style=sty, rows=2:4, cols=1)
writeData(wb, sheet=1, dat)
saveWorkbook(wb, "test02.xlsx", overwrite = TRUE) 

In Excel:

capture

But:

> readxl::read_excel("test02.xlsx", sheet=1)
                    A
1 1899-12-31 00:00:00
2 1899-12-31 12:00:00
3 1899-12-31 19:12:00
@nacnudus
Copy link
Contributor

This is because of Excel's leap-year bug. Excel addresses it by printing 1/01/1900, which it can do because it also uses 29/02/1900. In R, 29/02/1900 is impossible.

I'd be interested to see how you handle this in readxl. In tidyxl I give the user a warning.

@hadley
Copy link
Member

hadley commented Feb 13, 2017

Duplicate of #148

@jennybc jennybc added bug an unexpected problem or unintended behavior datetime 📆 labels Feb 17, 2017
@jennybc
Copy link
Member

jennybc commented Mar 11, 2017

Yes duplicate of #148, which I am closing ... but note that it contains an example xlsx.

@jennybc
Copy link
Member

jennybc commented Mar 11, 2017

Good description of how ssf (format code handler for SheetJS) deals with the Lotus 1-2-3 fake leap day:

https://github.com/SheetJS/ssf/blob/master/ssf.md#parsing-date-and-time-codes

jennybc added a commit that referenced this issue Mar 13, 2017
* Account for leap year bug; fixes #264

* Put leap day adjustment inside POSIXctFromSerial
@lock lock bot locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior datetime 📆
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants