-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hello,
I'm trying to use the options to set the timeZoneName so the string comes formatted using that time zone
I have something like this
const config = { year: 'numeric', month: 'short', day: 'numeric', timeZoneName: 'UTC', }
const formatter = new DateTimeFormat("en", config)
const result = formatter.format(new Date("2020-01-01"))
the result should be Jan 1, 2020, but the timeZoneName is being ignored, I'm receiving Dec 31, 2019, instead
Looking at the code, I think I found a solution for that, it could be done in the formatNative function
something like this
// -- ios
...
const timeZone: NSTimeZone = getNativeTimeZone(timeZoneName);
if (timeZone) {
dateFormatter.timeZone = timeZone;
}
...
// -- android
...
const timeZone: java.util.TimeZone = getNativeTimeZone(timeZoneName);
if (timeZone) {
sdf.setTimeZone(timeZone);
}
...
Creating the corresponding getNativeTimeZone methods
If you'd like I can make the pull request
Metadata
Metadata
Assignees
Labels
No labels