branch-2.1: [fix](nereids) fix to_monday('1970-01-04 23:59:59') #49153 (#49176)

Cherry-picked from #49153

Co-authored-by: yujun <yujun@selectdb.com>
This commit is contained in:
github-actions[bot]
2025-03-18 18:07:26 +08:00
committed by GitHub
parent 6430ff365d
commit 44b868de6b
2 changed files with 29 additions and 2 deletions

View File

@ -463,7 +463,7 @@ public class DateTimeExtractAndTransform {
}
private static LocalDateTime toMonday(LocalDateTime dateTime) {
LocalDateTime specialUpperBound = LocalDateTime.of(1970, 1, 4, 0, 0, 0);
LocalDateTime specialUpperBound = LocalDateTime.of(1970, 1, 4, 23, 59, 59, 999_999_999);
LocalDateTime specialLowerBound = LocalDateTime.of(1970, 1, 1, 0, 0, 0);
if (dateTime.isAfter(specialUpperBound) || dateTime.isBefore(specialLowerBound)) {
return dateTime.plusDays(-dateTime.getDayOfWeek().getValue() + 1);