Skip to content

GH-47131: [C#] Fix day off by 1 in Date64Array #47132

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeremycostanzo
Copy link

@jeremycostanzo jeremycostanzo commented Jul 18, 2025

Rationale for this change

Date64Array.Convert(DateTimeOffset) substracts one day on date times that are at 00:00 am and < 1970.
For example, 01/01/1969 00:00:00 gets converted to 12/31/1968 whereas the expected result is 01/01/1969.

What changes are included in this PR?

Fix to the described bug.

Are these changes tested?

Yes

Are there any user-facing changes?

No

This PR contains a "Critical Fix".

Copy link

⚠️ GitHub issue #47131 has been automatically assigned in GitHub to PR creator.

@jeremycostanzo
Copy link
Author

With the added test cases and without the fix,
Date64ArrayTest.AppendGivesUtcDate(dateTimeOffset: 1969-12-31T00:00:00.0000000+00:00) fails with

Assert.Equal() Failure: Values differ
Expected: 1969-12-31T00:00:00.0000000Z
Actual:   1969-12-30T00:00:00.0000000

Date64ArrayTest.AppendGivesUtcDate(dateTimeOffset: 0001-01-01T00:00:00.0000000+00:00) fails with

System.ArgumentOutOfRangeException: Valid values are between -62135596800000 and 253402300799999, inclusive. (Parameter 'milliseconds')

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

Successfully merging this pull request may close these issues.

1 participant