This closes #2192, made special date format result consistent with Excel #2193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
timeFromExcelTime
function had an off-by-one error when converting Excel dates 1-59 (January 1900 through February 1900) to Go time values. This caused dates to be returned one day earlier than expected.Problem
When reading Excel date
2.0
(which should represent January 2, 1900), the function incorrectly returned January 1, 1900:Root Cause
The issue was in the Julian date conversion logic used for Excel dates ≤ 61. The function uses different conversion methods:
The Julian conversion was working correctly for:
But days 1-59 had an incorrect offset, causing them to be off by one day.
Solution
Applied a targeted fix that adds +1.0 to the Julian date offset specifically for Excel days 1-59:
This preserves the correct behavior for days 0, 60, and 61 (which handle Excel's leap year bug correctly) while fixing the offset error for the affected range.
Verification
timeFromExcelTime(2.0, false)
now correctly returns1900-01-02
✅TestTimeFromExcelTime_Issue2192
) for edge casesFixes #2192.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.