facebook / facebook/hermes

Daylight savings time not handled properly in America/Santigo.

Open
#1,121 7 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

## Bug Description

Dates set to midnight of the day of a DST transition in Chile get moved to the prior day at 11 vs the intended day at 1am.

This is inconsistent with the behavior of other runtimes - there may be further similar issues with other timezones.

- [x] I have run `gradle clean` and confirmed this bug does not occur with JSC

Hermes version: current
React Native version (if any): 0.71.8
OS version (if any): os x, ios, android
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): arm64-v8a

## Steps To Reproduce

1. Set your machine timezone to `America/Santiago`
2. Go to the hermes playground
3. Paste in this code
```
const first = new Date(2023,8,1);
const second = new Date(2023,8,2);
const third = new Date(2023,8,3);
const fourth = new Date(2023,8,4);

print(first);
print(second);
print(third);
print(fourth);
```
This will output:

```
Fri Sep 01 2023 00:00:00 GMT-0400
Sat Sep 02 2023 00:00:00 GMT-0400
Sat Sep 02 2023 23:00:00 GMT-0400
Mon Sep 04 2023 00:00:00 GMT-0300
```

## Expected behaviour

On v8 / jsc you see the following:

```
Fri Sep 01 2023 00:00:00 GMT-0400 (Chile Standard Time)
Sat Sep 02 2023 00:00:00 GMT-0400 (Chile Standard Time)
Sun Sep 03 2023 01:00:00 GMT-0300 (Chile Summer Time)
Mon Sep 04 2023 00:00:00 GMT-0300 (Chile Summer Time)
```

As is this causes the popular date-fns library to spin into an infinite loop in some cases.
See this function for an example: https://github.com/date-fns/date-fns/blob/main/src/eachDayOfInterval/index.ts

If you're in `America/Santiago` the following will loop forever:

```
const days = eachDayOfInterval({
start: parseISO("2023-09-01"),
end: parseISO("2023-09-04")
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.