[V8 embedder] Default timezone is wrong with Intl on Android

52 views
Skip to first unread message

ckc...@gmail.com

unread,
Mar 4, 2020, 7:29:32 AM3/4/20
to v8-dev
Timezone detection on Android is slightly from POSIX and ICU did not well support this for Android.
There was an opening issue for ICU: https://unicode-org.atlassian.net/browse/ICU-13208

Chromium on Android, on the other hand, will call icu::TimeZone::adoptDefault() to setup correct timezone.

Unfortunately, for V8 embedders, there are no public API to setup timezone.
It will fallback to use ICU internal host timezone detection and will get wrong result on Android.

Hopefully to add a public API in v8.h for embedders to setup default timezone.
The API could probably to add in existing `DateTimeConfigurationChangeNotification`.
With new TimeZoneDetection::kCustom and maybe a second string parameter to
`DateTimeConfigurationChangeNotification` for the custom timezone.

What steps will reproduce the problem?
1. Setup a V8 embedder application on Android.
2. Setup Android device's timezone to Australia/Sydney.
3. `console.log(new Date().toString())` or `console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)`

What is the expected output?
console.log(new Date().toString()) expects get GMT+11:00 right now for daylight saving.
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone) expects to get 'Australia/Sydney'.

What do you see instead?
console.log(new Date().toString()) got GMT+10:00
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone) got undefined

ckc...@gmail.com

unread,
Mar 7, 2020, 1:19:39 AM3/7/20
to v8-dev
Well, the patch should be pretty much like this.
https://github.com/Kudo/v8-android-buildscripts/blob/master/patches/custom_timezone.patch
Please let me know if the API change making sense or not.
I could create a CL if that is okay.
Thanks.

ckc...@gmail.com於 2020年3月4日星期三 UTC+8下午8時29分32秒寫道:

Sathya Gunasekaran

unread,
Mar 11, 2020, 10:44:42 AM3/11/20
to v8-...@googlegroups.com, Frank Yung-Fong Tang
+Frank Yung-Fong Tang 

Adding an API for this makes sense to me. Can you submit the patch using gerrit? More information here: https://v8.dev/docs/contribute

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/1c841e92-4341-4945-b771-d003776b77b3%40googlegroups.com.

Frank Tang (譚永鋒)

unread,
Mar 11, 2020, 11:31:18 AM3/11/20
to Sathya Gunasekaran, ckc...@gmail.com, v8-...@googlegroups.com, Jungshik Shin (신정식, 申政湜)

Dear CK

Looks reasonable. 
Could you please file a bug in v8 by using https://bugs.chromium.org/p/v8/issues/entry w/ details
and assign it to me (and cc js...@chromium.org and gsa...@chromium.org)  about this.

Thanks

Regards,
Frank
--
Frank Yung-Fong Tang
譚永鋒 / 🌭🍊 
Sr. Software Engineer 

Jungshik Shin (신정식, 申政湜)

unread,
Mar 11, 2020, 12:40:09 PM3/11/20
to Frank Tang (譚永鋒), Sathya Gunasekaran, ckc...@gmail.com, v8-...@googlegroups.com
Looks reasonable, too. 

As for the ICU bug about the tz detection on Android (https://unicode-org.atlassian.net/browse/ICU-13208), I think it has been fixed in another bug in a recent version of ICU.  Because ICU on Android is only updated by a new Android release and v8 embedders need to support old versions of Android, this proposed change makes sense. 

Jungshik 

2020년 3월 11일 (수) 오전 8:31, Frank Tang (譚永鋒) <ft...@google.com>님이 작성:

Kudo Chien

unread,
Mar 12, 2020, 9:09:12 PM3/12/20
to v8-dev
Hi, Jungshik,

Do you know which ICU change fixed the problem?
If the problem could be fixed by ICU, that seems to be the formal solution and we don't need to open a new V8 API to workaround it.

Fo ICU on Android, supposedly V8 embeds its own ICU and not rely on Android system's ICU.
In this situation, we don't need to think about old versions of Android.

Let's see if ICU fixed the problem or not.
Thank you folks for the help.

Kudo

Jungshik Shin (신정식, 申政湜)於 2020年3月12日星期四 UTC+8上午12時40分09秒寫道:
Frank

To unsubscribe from this group and stop receiving emails from it, send an email to v8-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages