apache / 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.
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 5.1k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 29
Description
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) 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 60*24*(%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
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Contributor guide
Assessment
This issue has not been assessed yet.