[refactor](function) ignore DST for function from_unixtime (#19151)

This commit is contained in:
Gabriel
2023-05-05 11:51:49 +08:00
committed by GitHub
parent 1a1aee3886
commit 9dd6c8f87b
9 changed files with 96 additions and 60 deletions

View File

@ -225,13 +225,17 @@ public class DateLiteral extends LiteralExpr {
Timestamp timestamp = new Timestamp(unixTimestamp);
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.of(timeZone.getID()));
year = zonedDateTime.getYear();
month = zonedDateTime.getMonthValue();
day = zonedDateTime.getDayOfMonth();
hour = zonedDateTime.getHour();
minute = zonedDateTime.getMinute();
second = zonedDateTime.getSecond();
microsecond = zonedDateTime.get(ChronoField.MICRO_OF_SECOND);
// Ignore DST transition
LocalDateTime time = zonedDateTime.minusSeconds(
zonedDateTime.getOffset().getTotalSeconds() - timeZone.getRawOffset() / 1000).toLocalDateTime();
year = time.getYear();
month = time.getMonthValue();
day = time.getDayOfMonth();
hour = time.getHour();
minute = time.getMinute();
second = time.getSecond();
microsecond = time.get(ChronoField.MICRO_OF_SECOND);
if (type.equals(Type.DATE)) {
hour = 0;
minute = 0;