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

Issues when importing datetimes #144

Open
ecorreig opened this issue Jan 14, 2020 · 2 comments
Open

Issues when importing datetimes #144

ecorreig opened this issue Jan 14, 2020 · 2 comments
Labels

Comments

@ecorreig
Copy link

ecorreig commented Jan 14, 2020

When parsing a simple xlsx file with european formatted datetimes I get that the function subtracts one second to all dates at 13 hours or at 1 hour. It only happens at these times, so I'm guessing it has to do with AM-PM to 24H conversion or something like that. The file would be something like:

time things
26/2/2019 9:00 a
26/2/2019 13:00 b
26/2/2016 21:00 c
27/2/2019 1:00 d

And the code is simply:

df <- read.xlsx("file.xlsx", sheetIndex = 1)

Thanks,
Eudald

@colearendt
Copy link
Owner

Thanks for sharing this! I haven't had a chance to look at this, and it seems like the seconds / hours may be a different root cause, but any chance you have tried customizing the following? Our datetime formatting is defined by an option, and these are the defaults:

    options(xlsx.date.format = "m/d/yyyy")
    options(xlsx.datetime.format = "m/d/yyyy h:mm:ss")

Please note that we set these options universally on package load (which is wrong...), so you should set them after loading the xlsx package until we address this issue.

@colearendt
Copy link
Owner

Also, any chance you could use the reprex package to both write and read a sample xlsx in your example, perhaps also showing some of your locale settings / etc.? That would be helpful for our investigation!

https://www.jessemaegan.com/post/so-you-ve-been-asked-to-make-a-reprex/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants