apache/dolphinscheduler

[Bug] Regarding the system parameter $[yyyyMMdd-1], when the system timezone is set to US West (America/Los_Angeles), there is a Daylight Saving Time (DST) transition issue where a day only has 23 hours.

Open

#18,015 opened on Mar 4, 2026

View on GitHub
 (8 comments) (0 reactions) (1 assignee)Java (4,324 forks)batch import
backendbughelp wanted

Repository metrics

Stars
 (11,659 stars)
PR merge metrics
 (Avg merge 1d 17h) (22 merged PRs in 30d)

Description

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

Regarding the system parameter $[yyyyMMdd+N], when the system timezone is set to US West (America/Los_Angeles), there is a Daylight Saving Time (DST) transition issue where a day only has 23 hours.

In the code, day-based addition and subtraction is implemented using minutes, specifically through the calcMinutes method. The code hardcodes the calculation as 6024(%s). However, for the US West (Los Angeles) timezone, Daylight Saving Time (DST) transitions occur, causing the second Sunday of March to jump from 01:59:59 to 03:00:00—effectively losing one hour and making that day only 23 hours long. As a result, $[yyyyMMdd-1] subtracts one extra hour, leading to a two-day offset issue.

代码里针对天的加减是按照分钟去实现的,具体方法为calcMinutes,代码里硬编码为60×24×(%s),固定为24小时(不合理),对于美西洛杉矶时区存在冬夏转换导致三月的第二个星期日 01:59:59 会调到03:00:00 因此少了一个小时 只有23小时问题,因此$[yyyyMMdd-1] 会被多减一个小时导致少俩天问题

here is my Test Case `// 启动前设置时区 TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); // 方法1: 使用 java.time 包 (推荐,Java 8+) ZonedDateTime laDateTime = ZonedDateTime.of( 2026, 3, 9, // 年, 月, 日 0, 10, 0, // 时, 分, 秒 0, // 纳秒 ZoneId.of("America/Los_Angeles") // 洛杉矶时区 );

    // 转换为 Date 对象
    Date date = Date.from(laDateTime.toInstant());
    //System.out.println(TimePlaceholderUtils.getPlaceHolderTime("$[week_last_day(yyyy-MM-dd,0) - 1]", date));
    System.out.println(TimePlaceholderUtils.getPlaceHolderTime("yyyy-MM-dd-1", date));
    System.out.println(TimePlaceholderUtils.getPlaceHolderTime("yyyy-MM-dd", date));`

What you expected to happen

fix the bug ,期望 $[yyyyMMdd-1] 只会少一天

How to reproduce

` TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); // 方法1: 使用 java.time 包 (推荐,Java 8+) ZonedDateTime laDateTime = ZonedDateTime.of( 2026, 3, 9, // 年, 月, 日 0, 10, 0, // 时, 分, 秒 0, // 纳秒 ZoneId.of("America/Los_Angeles") // 洛杉矶时区 );

    // 转换为 Date 对象
    Date date = Date.from(laDateTime.toInstant());
    //System.out.println(TimePlaceholderUtils.getPlaceHolderTime("$[week_last_day(yyyy-MM-dd,0) - 1]", date));
    System.out.println(TimePlaceholderUtils.getPlaceHolderTime("yyyy-MM-dd-1", date));
    System.out.println(TimePlaceholderUtils.getPlaceHolderTime("yyyy-MM-dd", date));`

Anything else

No response

Version

dev

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Contributor guide