question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

America/Sao_Paulo datetime behavior is wrong when debug mode is OFF

See original GitHub issue

Our 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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
radko93commented, Nov 1, 2019

You can try using V8 engine (that’s possible now) or maybe try hermes? I know it’s not a real fix.

0reactions
radko93commented, Nov 1, 2019

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

America/Sao_Paulo datetime behavior is wrong when debug ...
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...
Read more >
React native different behaviour between debug mode and ...
When the remote debugging is disabled, code runs on your phone, ... you'll see that it contains "outDate": "Invalid DateTime" . There it...
Read more >
DateTime - Something not right! - Salesforce Stack Exchange
The Date and Time objects are timezone agnostic; they neither carry nor honor timezone information. You can prove this with a simple script:...
Read more >
Change in behavior when datetime parameter is out of range
In this case, Adaptive Server ADO.NET Data Provider sends the date to Adaptive Server, and Adaptive Server returns an error. The error code...
Read more >
UART behaves different out of DEBUG mode - TI E2E
If I start the MCU execution by the Debug button and loading the code, then even if I turn the Debugger off, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found