Questions tagged [ecmascript-intl]

ECMAScript Internationalization API

The ECMAScript Internationalization API (ECMA-402) is a series of extensions to the ECMAScript language to add support for various locale-specific formatting of numbers and dates, as well as the comparison of different Unicode strings.

It does so by providing a new Intl global object to work with, as well as providing firmer specification and new arguments to methods which were previously implementation-defined, such as Number.prototype.toLocaleString.

40 questions
1
vote
1 answer

Adding functionality to Intl.NumberFormat

I'm trying to add functionality to the format function but there is something wrong with my code: Object.defineProperty(Intl.NumberFormat.prototype, "format", { value: function(){ //your logic here let orig = Intl.NumberFormat.prototype …
Roni Gadot
  • 437
  • 2
  • 19
  • 30
1
vote
0 answers

Intl API to convert numeric to string?

I have been reading the Intl API - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat And it is awesome. I plan to start using it extensively. However there is one thing I am looking for. I want to convert…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
1
vote
1 answer

Code Splitting with Webpack for Intl polyfill

I'm trying to create a bundle for the intl polyfill to load it only for browser which requires it. Using the following code, it creates the bundle in my output folder if (!window.Intl) { require.ensure(['intl/dist/Intl'], (require) => { …
alexmngn
  • 9,107
  • 19
  • 70
  • 130
1
vote
2 answers

Does Firefox 41 have a bug when formatting `new Intl.NumberFormat("es-ES").format(3500)` as `3 500`?

When trying to become familiar with the support of number formatting in the different browsers I found that Firefox 41 formats new Intl.NumberFormat("es-ES").format(3500) as 3 500 (with a space as the group separator) while IE 11, Edge and Google…
Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
0
votes
0 answers

Messed support for Intl.DateTimeFormat with Chinese Calendar

new Intl.DateTimeFormat('zh-CN-u-ca-chinese', { dateStyle: 'full' }).format(1680537600000) The above code outputs 0040闰0214 12:00 上午 in Firefox, 2023癸卯年闰二月十四星期二 in Chrome/node/deno, 2023癸卯年闰二月14星期二 in bun. Why those outputs are so different? How…
swwind
  • 123
  • 6
0
votes
0 answers

How to ensure/load locales on the client?

I'm just getting started with the Intl package and I don't quite understand how we should use it in our web-application. E.g. the following snippet uses Intl.DateTimeFormat with different locales (en-GB, de-DE) and timezones (Europe/Vienna and…
TmTron
  • 17,012
  • 10
  • 94
  • 142
0
votes
2 answers

Convert the local time to another time zone with this JavaScript

I need to increase the current date in Moscow time by 1 day every time the clock is 15:00 and more. I did it at local time, but I can’t do it according to Moscow time (UTC + 3) function date() { const today = new Date(); const t =…
Vladislav
  • 476
  • 2
  • 13
0
votes
0 answers

Differences with formatting options in IE11 with Date.toLocaleDateString()?

I have a simple issue that I don't know how to fix. If I run this code in Chrome: var event = new Date(Date.UTC(2012, 11, 5, 3, 0, 0)); var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'…
0
votes
1 answer

Intl formatting of huge floating point numbers

I'm trying to better understand why large numbers, with potentially large precisions are inconsistently handled, specifically in JavaScript and it's localization facilities (e.g. ECMA-402/Intl). I'm assuming this has to do with the use of floating…
sparty02
  • 566
  • 1
  • 6
  • 13
0
votes
1 answer

Formatting Number and dates dilemma

My app is using : ASP.NET Http Handler for the back-end in order to read the data from MySql database and return them in JSON format React.js app for the front-end to display the data in the browsers. The app is built by using webpack. Several…
sovo2014
  • 487
  • 7
  • 17
1 2
3