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

Cannot distinguish a date from a date with explicitly written time in an excel file. #543

Open
kikaragyozov opened this issue Jun 22, 2021 · 4 comments

Comments

@kikaragyozov
Copy link

kikaragyozov commented Jun 22, 2021

The library does an excellent job parsing dates to DateTime objects, but in doing so makes it impossible to distinguish if the cell originally contained the value dd/mm/YYYY instead of dd/mm/YYYY hh:mm:ss tt.

I feel like this is important for cases where you need to verify a date against a specific format, as the above would ruin the validation if you expect a format without time, as the date you receive will always be with a time. (DateTime objects without time set, default to the time of 12:00:00 AM)

Are there any possible solution to this, other than wrapping the DateTime object the library produces in a custom type that could help alleviate these differences, as changing the returned object would undoubtedly be a breaking change for many current users of the API?

@appel1
Copy link
Collaborator

appel1 commented Jun 22, 2021

The only consistently available information in Excel in addition to the datetime is the format. You can probably figure out the information you want by inspecting the format specification for the cell. See GetNumberFormatString.

@kikaragyozov
Copy link
Author

The only consistently available information in Excel in addition to the datetime is the format. You can probably figure out the information you want by inspecting the format specification for the cell. See GetNumberFormatString.

Works like a charm, thank you!

@kikaragyozov
Copy link
Author

I'm sorry for re-opening this, but am I doing something wrong on my part, because it seems number format is returning the incorrect date format for a supplied date?

In the excel, I have the date 10/14/2015, but calling GetNumberFormatString returns d/m/yyyy.

Shouldn't it return instead m/d/yyyy?

@kikaragyozov kikaragyozov reopened this Jul 1, 2021
@kikaragyozov
Copy link
Author

Linked to #461

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