-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Intl: Add Intl.DateTimeFormat.timeZone #19
Conversation
Hi @kunalspathak, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
@dotnet-bot test this please. |
@dotnet-bot test this please |
@mmitche Any ideas what's going on here? |
@dotnet-bot test this please |
@dilijev Close and reopen this, it probably got caught up in the maintenance I had to do yesterday |
Hi @kunalspathak, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
Reviewed by @Yongqu . |
Thanks @mmitche |
This change matches the spec update section 12.3.5 of Intl's ECMA-402 (http://www.ecma-international.org/ecma-402/2.0/ECMA-402.pdf), to let user specify timeZone other than UTC. Earlier, the only timeZone that can be specified in DateTimeFormat was 'UTC'. New spec says that user should be able to specify any IANA valid timeZone. In order to make sure that timeZone passed by user is valid, I use ChangeTimeZone() API of windows.globalization. This API returns error if timeZone specified is invalid. If user doesn't specify timeZone, then we should use current timeZone instead of "UTC". This PR also includes some improvements of Intl objects initializing by delaying them. Here is the summary: Today, we initialize and execute Intl.js code when either of the following is true. * First time property access for below properties of `Intl` object : * Intl.DateTimeFormat * Intl.NumberFormat * Intl.Collator * When one of below methods is called : * String.prototype.localeCompare * Number.prototype.toLocaleString * Date.prototype.ToLocaleString * Date.prototype.ToLocaleDateString * Date.prototype.ToLocaleTimeString In order to execute `Intl.js` code, we initialize `WindowsGlobalizationAdapter (WGA)` objects that helps us call into Windows.globalization.dll exported methods. Some of the WGA objects map files in memory for easy lookup. For e.g. Objects having timeZone related methods map various files like `timezones.xml`, `timeZoneMapping.xml`, `tzres.dll.mui` which increases the reference set. Although these mapped files are needed for `Intl.DateTimeFormat` or `Date.prototype` methods, they are not needed for other APIs like `String.prototype.localeCompare`. This change segregates initialization of all WGA objects we use and defers it until dependent javascript methods or properties are called. The WGA objects initialization falls under one of the following category: * Common objects (needed by all the APIs) * DateTime formatting APIs (needed by methods on `Date.prototype` object) * Number formatting APIs (needed by methods on `Number.prototype` object) * All of the above (needed by properties on `Intl` object) (Note: `String.prototype` relies on common WGA objects and hence we won't initialize other objects that are initialized for Date/Number.) The change includes passing right flag to IntlLibraryCode telling what javascript APIs is needed and thus initializing right WGA objects. `Intl.js` now takes a parameter `InitType` which will determine what javascript objects it should be initializing. Also did some code refactoring.
Thanks @kunalspathak! Ping here when this ships, and I'll update the ECMAScript Compatibility Chart at (under the |
Intl: Add Intl.DateTimeFormat.timeZone
This change matches the spec update section 12.3.5 of Intl's ECMA-402,
to let user specify timeZone other than UTC. Earlier, the only timeZone that can be specified in DateTimeFormat
was 'UTC'. New spec says that user should be able to specify any IANA valid timeZone. In order to make
sure that timeZone passed by user is valid, I use ChangeTimeZone() API of windows.globalization. This API returns
error if timeZone specified is invalid.
If user doesn't specify timeZone, then we should use current timeZone instead of "UTC".
This PR also includes some improvements of Intl objects initializing by delaying them. Here is the summary:
Today, we initialize and execute Intl.js code when either of the following is true.
Intl
object :In order to execute
Intl.js
code, we initializeWindowsGlobalizationAdapter (WGA)
objects that helpsus call into Windows.globalization.dll exported methods. Some of the WGA objects map files in memory for
easy lookup. For e.g. Objects having timeZone related methods map various files like
timezones.xml
,timeZoneMapping.xml
,tzres.dll.mui
which increases the reference set. Although these mapped files are needed forIntl.DateTimeFormat
orDate.prototype
methods, they are not needed for other APIs likeString.prototype.localeCompare
.This change segregates initialization of all WGA objects we use and defers it until dependent javascript methods or properties
are called.
The WGA objects initialization falls under one of the following category:
Date.prototype
object)Number.prototype
object)Intl
object)(Note:
String.prototype
relies on common WGA objects and hence we won't initialize other objectsthat are initialized for Date/Number.)
The change includes passing right flag to IntlLibraryCode telling what javascript APIs is needed and thus initializing right WGA objects.
Intl.js
now takes a parameterInitType
which will determine what javascript objects it should be initializing.Also did some code refactoring.