Comments (14)
backpointer to an old task related to this proposal: https://bugs.ecmascript.org/show_bug.cgi?id=771
from ecma402.
Example of what this API would save us from doing: https://github.com/mozilla-b2g/gaia/blob/1360b05876d2def34a37c28e44d49e7e60dc2484/apps/system/js/value_selector/spin_date_picker.js#L120-L156
from ecma402.
I need to talk to @bterlson about this to see how realistic this will be for Chakra/Edge since they don't use CLDR data.
from ecma402.
Is DateTimeFormat using raw CLDR? I'm a bit confused about how CLDR handles order of "hma" (where h is hour, m i minute and a is dayperiod) because there doesn't seem to be an entry with that name. So it seems that CLDR for locales that don't use dayperiod by default, doesn't provide a way to order with dayperiod. DateTimeFormat
handles that, so it may be coming from somewhere else.
Also, Mozilla would be very interested in such data for our date/time pickers.
from ecma402.
@zbraniecki for that particular case, they use hm
instead of hma
, which can be matched with the fact that for en
the value of hour12
config is true by default. In other words, yes, it is the raw CLDR data:
"hm": "h:mm a"
while for en-GB
we have:
"Hm": "HH:mm",
matching the default value for hour12
, which if false.
from ecma402.
I don't think I have answered your question, let me try again. the algo we have today does NOT use the key, it uses the value from CLDR to find the best match based on the provided configuration, which means we will either pickup entry hm
or Hm
depending of the value of hour12
(whether that's provided in the instance, or the default value per locale), in other words:
(new Intl.DateTimeFormat("en-US", { hour: "numeric", minute: "numeric" }));
will use h:mm a
for en
, and HH:mm
for en-GB
, if you add hour12
to that config, you can choose which one to use by forcing the value of it.
from ecma402.
I'm going to expose it internally for Gecko because we need this for date/time pickers.
I may be interested in championing it, but I'm a bit afraid of the scope of spec work to define all combinations that pattern
can take depending on locale and options.
@caridy - am I correct to expect it to be a substantial amount of work or would you be ok to leave it as implementation specific?
from ecma402.
Alternatively, one can use formatToParts
to build a placeholder:
var x = new Intl.DateTimeFormat('en-US', {
hour: '2-digit',
minute: '2-digit',
});
var parts = x.formatToParts(now);
parts.map(part => {
switch (part.type) {
case 'hour':
case 'minute':
return '--'
default:
return part.value;
}
}).join('');
from ecma402.
I guess my question is - except of building placeholder patterns (which can be done using formatToParts
), is there any other use case for the pattern?
from ecma402.
@eemeli, @rxaviers, @ericf, @littledan - any opinion on that?
If the only use case for the pattern is to create placeholders or pickers and we can already do that with formatToParts
, I suggest we close this issue.
from ecma402.
I at least can't think of anything that could be done better with resolved.pattern
rather than formatToParts
.
from ecma402.
then I suggest we close this issue! :) @caridy, can you do this? I don't have the privs.
from ecma402.
Yes, in fact chrome does not longer expose the internals of the DateTimeFormat, there is no reason to do so now that we have formatToParts
.
from ecma402.
👍 (although late 😊)
from ecma402.
Related Issues (20)
- Meta: promote editors' draft on Ecma listing for 402 HOT 1
- locale data: expose delimiters HOT 3
- Use unicode_script_subtag and unicode_region_subtag in Locale.prototype.{script,region} HOT 1
- Draft plan to align canonical time zone IDs across implementations HOT 20
- Get the formats for a given locale HOT 2
- Allow compact notation to depend on `style` HOT 3
- AvailableCurrencies and default fallback for unsupported currencies in NumberFormat HOT 1
- Ensure data returned from Intl Enumeration is consistent with data supported by Intl objects HOT 8
- Is there a polyfill for the "extend-timezonename" proposal? HOT 6
- Cyclic year doesn't show up in resolvedOptions HOT 1
- Ok HOT 1
- Numbering system option value not correctly passed to internal Intl.NumberFormat instances
- Feedback on ICU's new HOT 1
- Feedback on ICU's new "get IANA ID" API HOT 3
- Should ECMA-402 spec text for time zone canonicalization refer to CLDR or to IANA as authoritative? HOT 8
- Canonicalization for Calendar identifiers? HOT 2
- Consider making ResolveLocale return the normalized requested locale instead of the available locale HOT 6
- Default of ignorePunctuation need to be locale dependent HOT 3
- Support cash rounding HOT 3
- Displaying wrong date format for sr-Latn-me locale HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecma402.