Skip to content

Conversation

WenHsuanYu
Copy link
Contributor

@WenHsuanYu WenHsuanYu commented Sep 10, 2025

This test case ensures that the parser can convert ISO8601 correctly.
However, when the local time falls on a different day than the UTC time,
there will be an off-by-one issue.

I changed the test to convert the local time and then compare it with
the expected local time. This should fix the off-by-one issue.

Reference
link

Reviewers: Andrew Schofield [email protected]

@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 17:48
@github-actions github-actions bot added triage PRs from the community connect tests Test fixes (including flaky tests) small Small PRs labels Sep 10, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes an off-by-one error in the ValuesTest that occurred when local time falls on a different day than UTC time. The test was using LocalDate.ofEpochDay(days) which could result in incorrect date conversion when timezone differences cause day boundaries to differ between local and UTC time.

  • Replaces LocalDate.ofEpochDay(days) with localTime.format(DateTimeFormatter.ISO_LOCAL_DATE) to ensure consistent local time handling
  • Removes unused LocalDate import

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -903,7 +901,7 @@ public void shouldConvertDateValues() {

// ISO8601 strings - accept a string matching pattern "yyyy-MM-dd"
LocalDateTime localTimeTruncated = localTime.truncatedTo(ChronoUnit.DAYS);
java.util.Date d3 = Values.convertToDate(Date.SCHEMA, LocalDate.ofEpochDay(days).format(DateTimeFormatter.ISO_LOCAL_DATE));
java.util.Date d3 = Values.convertToDate(Date.SCHEMA, localTime.format(DateTimeFormatter.ISO_LOCAL_DATE));
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable days is referenced in the original code but not visible in this diff. If days was calculated from localTime, this change may not fix the off-by-one issue as intended, since localTime.format(DateTimeFormatter.ISO_LOCAL_DATE) will still use the same local date that could differ from UTC. Consider using a fixed date string or ensuring the test uses UTC time consistently.

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change may not fix the off-by-one issue as intended, since localTime.format(DateTimeFormatter.ISO_LOCAL_DATE) will still use the same local date that could differ from UTC.

@WenHsuanYu What do you think for this comment?

@github-actions github-actions bot removed the triage PRs from the community label Sep 11, 2025
Signed-off-by: Alex <[email protected]>
Copy link
Member

@AndrewJSchofield AndrewJSchofield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Testing in timezone one day ahead of UTC was successful.

@AndrewJSchofield AndrewJSchofield merged commit 3fcc0c2 into apache:trunk Sep 15, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved connect small Small PRs tests Test fixes (including flaky tests)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants