Skip to content

[Fix-18015] [DST ISSUE] Handle DST issue when calculating yyyyMMdd±N time placeholders#18026

Open
iampratap7997-dot wants to merge 2 commits intoapache:devfrom
iampratap7997-dot:fix-dst-time-placeholder
Open

[Fix-18015] [DST ISSUE] Handle DST issue when calculating yyyyMMdd±N time placeholders#18026
iampratap7997-dot wants to merge 2 commits intoapache:devfrom
iampratap7997-dot:fix-dst-time-placeholder

Conversation

@iampratap7997-dot
Copy link
Contributor

@iampratap7997-dot iampratap7997-dot commented Mar 6, 2026

Was this PR generated or assisted by AI?

NO (Only the manual test case for America(Los_Angeles) timezone was created by AI to verify the fix.)

Purpose of the pull request

Fixes #18015 DST issue when calculating $[yyyyMMdd±N] time placeholders.
Day-based calculations were previously implemented in minutes, which caused incorrect dates during Daylight Saving Time transitions.

Brief change log

1- Replaced minute-based day calculations with addDays for expressions like yyyyMMdd+N & yyyyMMdd-N.
2- Ensures correct date calculation in timezones with DST (e.g., America/Los_Angeles).

Verify this pull request

  • The fix was manually verified using America/Los_Angeles timezone around DST transition.
  • Unit tests cover existing placeholders (no new tests added, logic change only).

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

Date targetDate = addMinutes(date, calcMinutes(addMinuteExpr));
if (index + 1 < expression.length() && Character.isDigit(expression.charAt(index + 1))) {
String addDayExpr = expression.substring(index + 1);
int days = Integer.parseInt(addDayExpr);

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
Date targetDate = addMinutes(date, 0 - calcMinutes(addMinuteExpr));
if (index + 1 < expression.length() && Character.isDigit(expression.charAt(index + 1))) {
String addDayExpr = expression.substring(index + 1);
int days = Integer.parseInt(addDayExpr);

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
@iampratap7997-dot
Copy link
Contributor Author

iampratap7997-dot commented Mar 7, 2026

HI maintainers,
Please add the milestone label for this PR .

Thanks,
Divyansh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant