Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date instance on eve of the beginning of daylight savings returns hour behind (Android) #21559

Closed
jgitt opened this issue Oct 8, 2018 · 5 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@jgitt
Copy link

jgitt commented Oct 8, 2018

Environment - react-native info

  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
      Memory: 6.80 GB / 15.86 GB
    Binaries:
      npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.1.0.0 AI-173.4907809

Other Environment Details

React: 16.5.0
React-native: 0.57.2
Timezone: AEDT - Australian Eastern Daylight Time
Device: Android 8.0 (API 26). Running in emulator (Genymotion). Have briefly tested on device, while it wasn't as thorough, it did show same issue.

Description

Creating a Date instance on the eve of daylight savings starting in Australian Eastern (Daylight) Time returns the hour as an hour behind. Only tested on Android.

The following line is expected to print 20, however it shows 19.

new Date(2018, 9, 6, 20, 0).getHours()

In browser (latest Chrome) and Nodejs (8.11.4) the above line returns 20.

I did further testing with the following timezones using the eve of the respective day light savings date and they did not show the same issue.

  • PDT (GMT-7)
  • EDT (GMT-4)

Reproducible Demo

  1. Create new react app via react-native init DateIssueTest
  2. (I had an issue with starting so did react-native start --reset-cache)
  3. react-native run-android
  4. Modified App.js to include:
        <Text style={styles.instructions}>{new Date(2018, 9, 5, 20, 0).getHours()}</Text>
        <Text style={styles.instructions}>{new Date(2018, 9, 6, 20, 0).getHours()}</Text>
        <Text style={styles.instructions}>{new Date(2018, 9, 7, 20, 0).getHours()}</Text>
  1. The device timezone must be Australian Eastern (Daylight) Time (i.e. Sydney). So Settings > System > Date & time > Select time zone > Sydney
  2. It's expected that each line of code above should show 20, however in my test, the middle line shows 19
@react-native-bot react-native-bot added the Platform: Android Android applications. label Oct 8, 2018
@nathan-k
Copy link

nathan-k commented Oct 8, 2018

Possibly related to this: https://bugs.webkit.org/show_bug.cgi?id=137003

@kelset
Copy link
Contributor

kelset commented Oct 9, 2018

Yes, it seems that it's potentially related to the WebKit - sadly at the moment React Native ships on Android with an old version of the JSC; as workarounds I think you can try using:

With version 0.58 we are planning on making it easier to move to a newer JSC but at the moment is not easily achievable.

@jgitt
Copy link
Author

jgitt commented Oct 9, 2018

No problem. Thanks @kelset. I'm using DayJS and it still shows the same problem, but I'll give Moment a shot.

@stale
Copy link

stale bot commented Jan 20, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 20, 2019
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 26, 2019
@hramos
Copy link
Contributor

hramos commented Jan 29, 2019

The new JSC landed on master a month ago.

@hramos hramos closed this as completed Jan 29, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Jan 29, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jan 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants