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

Date.parse used on timestamps, causing the time portion to be truncated #4

Open
timcharper opened this issue Apr 27, 2012 · 2 comments
Assignees

Comments

@timcharper
Copy link
Contributor

If you create an excel spreadsheet (xls) from the following csv:

date,name,
Sun Dec 31 13:59:59 CET 2006,Boogie

Then load it with jruby-poi, and access the cell with the date, you will get a Date with "2006-12-31"

The problematic code is here:

https://github.com/kameeoze/jruby-poi/blob/master/lib/poi/workbook/cell.rb#L168

Changing Date.parse to Time.parse seems like a safe bet.

@sdeming
Copy link
Member

sdeming commented Dec 14, 2012

Thank you for taking the time to do this. I've merged the pull request because the errors were not at all related. It looks like it's some incompatibility issue with jruby 1.7. The tests run fine under jruby 1.6.8.

@timcharper
Copy link
Contributor Author

Thanks for merging it in, Scott! Sorry to hear about the 1.7 incompat pain.

Sorry that I muddled the issues. Regarding POI being unable to return a time.... what do you think would be the best way to handle it? Excel doesn't have any native type to distinguish between a date and a datetime, they're all stored as datetimes. I think a few options include:

  • Do nothing. This is bad because
  • Config variable. This is good because it allows people to preserve existing behavior.
  • If the time ends with 00:00:00 (the numeric date value ends with .0), then return a date. (this can be bad, because it would leave the programmer with a bit of an inconsistent type)
  • Always return a Time, but have an optional parameter to value to tell it to return a date. I think this is my preferred approach, but could be a breaking change for some.
  • Just always return a Time. If the programmer wants a date, they should sign up for match.com, or implement Time#to_date.

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

No branches or pull requests

2 participants