-
Notifications
You must be signed in to change notification settings - Fork 344
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
XLDateTime calculations for doubles. #299
Comments
What exactly is your question? Your code example correctly converts an Excel Date to a |
|
1.0 = 1899-12-31 (0 = 1899-12-30) - please note that MS documentation is contradicting itself every second sentence.
Because this module hasn't been reviewed in a while, and MS documentation being as it is, I may have implemented the struct tm epoch 1900-01-01 wrongly - especially since MS Excel date is a clsterfck working around a bug that they made 1900 be considered a leap year when it is not.
Yes, in the current version, no dates before 1900-01-01 are allowed - in doubles that means the value must be >= 1.0.
I am sure the implementation is not correct for all dates. As I said, I haven't gotten around to it yet.
Yes, but since the buggy epoch implementation was in only one constructor (from double), I didn't notice at the time. Have some patience please - I have other things to work on as well (the ones that I get paid for ;) - but I'll get around to it. I'll mark this here as a confirmed bug and will not close it until I fix it (multiple, actually). |
Thanks for detailed reply! ;-) Have your time. This info could be probably helpful.
|
Hi @wiluite - I just patched XLDateTime, hopefully fixing the issues now - refer 107ad2b for the change. The bug I had introduced in the past was because I didn't realize LibreOffice (which I use for testing) chose a different solution for Excel Date format bug where it assumes that 1900 is a leap year: In Excel, if you enter "60", and format as date, you would get "29 February 1900", a day that did not exist in history - and for "61" you would get "1 March 1900". So between the very real days that follow upon each other: 1900-02-28 and 1900-03-01, in Excel, a date diff would yield "2 days", when actually it is only 1 day difference. LibreOffice "fixed" this by moving the epoch back by 1 day, to start on 1899-12-30T00:00:00. Being unaware of this, I assumed the Excel epoch was also the same, and documentation was wrong. When fixing what I thought was "correct" date displays for the first two months of the epoch - using LibreOffice as control - I broke the correct code (IIRC) from before. Please have a look and test & let me know if I can close this issue. Thank you for reporting it! |
Patch has been merged into main branch. Closing as resolved. |
Is this code too problematic? It calculates 0 as 'day of month'.
std::asctime(&tmo)
also fails to proceed further, because it probably returns nullptr;imho:
note, there is a good Howard Hinnant's date library for such things.
The text was updated successfully, but these errors were encountered: