-
Notifications
You must be signed in to change notification settings - Fork 650
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 getTime unexpected result #1491
Comments
Hi, can you reproduce this with the CLI?
It may be caused by polyfills that are active in your code. Also, what timezone are you using? |
I also tried with Hermes CLI it's not reproducible. |
I can't reproduce it either. Could you provide the timezone? Or TZ environment variable if you ever set that. |
Timezone is I reproduced with an expo project ([email protected]): const testDate = new Date(0)
console.log('=====>', testDate.getTime())
testDate.setSeconds(0)
console.log('=====>', testDate.getTime()) output
output of
hermes engine used (from pod install):
dependencies from
|
I reproduced using latest hermes release https://github.com/facebook/hermes/releases/download/v0.13.0/hermes-cli-darwin.tar.gz script file: const d = new Date(0)
d.setSeconds(0)
print(d.getTime()) ➜ hermes-cli-darwin ./hermes script.js
-3600000 this is running on a Apple M1 Pro OS version 14.6.1 |
Thanks! I can reproduce with that timezone. We'll look into it. |
I looked into it. The issue is that when we are computing UTC time from local time, we are offseting -1 hour to get the DST (this trick works really well in most cases). This results in a negative epoch value and an equivalent time is used, which has different DST (Auckland does not have DST transition in 1960-1973). One solution is that we don't compute equivalent time on Linux/MacOS (AFAIK only Windows CRT can't handle negative time value), and finding alternative on Windows (it seems even Win32 API has issue handling this case). |
Bug Description
There is a discrepency between how Hermes compute dates and how chrome V8 does it.
The following code does not provide the same result:
Code:
Output with hermes:
Output in chrome console:
gradle clean
and confirmed this bug does not occur with JSCHermes git revision (if applicable):
React Native version: 0.74.0
OS: ios and android
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):
Steps To Reproduce
NA
code example:
The Expected Behavior
getTime
should return0
The text was updated successfully, but these errors were encountered: