fix: date validation reject invalid dates instead of silent normalization#315
Open
dalingmeng wants to merge 6 commits into
Open
fix: date validation reject invalid dates instead of silent normalization#315dalingmeng wants to merge 6 commits into
dalingmeng wants to merge 6 commits into
Conversation
8d7d311 to
e63e92e
Compare
lxy-9602
reviewed
May 28, 2026
e63e92e to
8b753ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
no linked issue:
std::get_timeonly validates field ranges (e.g.,tm_mdayin [1, 31]) but does not check actual date validity (e.g., Feb 29 in non-leap year, Apr 31). After parsing,timegm/mktimesilently normalizes these invalid dates instead of returning an error:StringToDate("2019-02-29")→ returns 17956 (2019-03-01) instead of errorStringToTimestampMillis("2023-02-30 00:00:00")→ returns 1677686400000 (2023-03-02) instead of errorThis change adds post-normalization validation: after calling
timegm/mktime, we comparetm_mdayandtm_monwith the original values. If they differ, the input date was invalid and an error is returned.This aligns with Java Paimon behavior, where
LocalDate.parse("2019-02-29")throwsDateTimeParseException.Tests
StringUtilsTest.TestStringToDateWithInvalidLeapYear— verifies Feb 29 in non-leap year, Feb 30, Apr 31 are rejected; valid leap year date (2020-02-29) succeedsStringUtilsTest.TestStringToTimestampMillisWithInvalidDate— verifies Feb 30, Feb 29 in non-leap year, Apr 31 are rejected; valid leap year timestamp (2024-02-29) succeedsAPI and Format
No API or format changes.
Documentation
No new features introduced.
Generative AI tooling