America/Sao_Paulo datetime behavior is wrong when debug mode is OFF
See original GitHub issueOur current president has decided to cancel DST in Brazil this year. This means that since November 4th the timezone is being returned incorrectly (UTC -2 instead of -3).
I tried to use some libs to solve this problem:
"date-fns": "^2.6.0",
"date-fns-tz": "^1.0.8",
"moment": "^2.24.0",
"moment-timezone": "^0.5.27",
But I couldn’t.
I also learned that React Native has 2 types of environments to run JS: V8
from Chrome when Debug Mode is ON and device’s JavascriptCore
when Debug Mode is OFF.
I’ve noticed that’s influences directly in the timezone behavior, since when Debug Mode is ON, there’s no problem with timezone at all using any of those libraries above.
I’ve also tried to solve this by installing "jsc-android": "241213.x.x"
with all gradle config and stuff, but the timezone stills incorrect.
I can’t find a solution to make timezone works as expected.
React Native version:
React Native Environment Info:
System:
OS: macOS 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
Memory: 111.66 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.15.1 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 21, 23, 27, 28, 29
Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 27.0.3, 28.0.2, 28.0.3, 29.0.0
System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.10 => 0.59.10
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Steps To Reproduce
import React, { Component } from 'react'
import { Text } from 'react-native'
import { parseISO } from 'date-fns'
import { zonedTimeToUtc } from 'date-fns-tz'
render(){
const parsedDate = parseISO('2019-11-15 20:00:00');
const znDate = zonedTimeToUtc(parsedDate, 'America/Sao_Paulo');
return <Text>{`Date: ${znDate}`}</Text>
// returns Date: Fri Nov 15 2019 20:00:00 GTM-0200(-02)
}
Describe what you expected to happen:
Date: Fri Nov 15 2019 20:00:00 GTM-0300(-03)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
You can try using V8 engine (that’s possible now) or maybe try hermes? I know it’s not a real fix.
You can look here https://github.com/Kudo/react-native-v8#readme I would suggest that you open an issue on JSC as this will not be fixed in React Native directly probably?