Giter Site home page Giter Site logo

Comments (14)

caridy avatar caridy commented on June 16, 2024

backpointer to an old task related to this proposal: https://bugs.ecmascript.org/show_bug.cgi?id=771

from ecma402.

zbraniecki avatar zbraniecki commented on June 16, 2024

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.

caridy avatar caridy commented on June 16, 2024

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.

zbraniecki avatar zbraniecki commented on June 16, 2024

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.

caridy avatar caridy commented on June 16, 2024

@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.

caridy avatar caridy commented on June 16, 2024

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.

zbraniecki avatar zbraniecki commented on June 16, 2024

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.

zbraniecki avatar zbraniecki commented on June 16, 2024

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.

zbraniecki avatar zbraniecki commented on June 16, 2024

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.

zbraniecki avatar zbraniecki commented on June 16, 2024

@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.

eemeli avatar eemeli commented on June 16, 2024

I at least can't think of anything that could be done better with resolved.pattern rather than formatToParts.

from ecma402.

zbraniecki avatar zbraniecki commented on June 16, 2024

then I suggest we close this issue! :) @caridy, can you do this? I don't have the privs.

from ecma402.

caridy avatar caridy commented on June 16, 2024

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.

rxaviers avatar rxaviers commented on June 16, 2024

👍 (although late 😊)

from ecma402.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.