toLocaleString adds extra punctuation to generated String




3 years ago
2 years ago


(Reporter: jmassey, Unassigned)


46 Branch

Firefox Tracking Flags

(Not tracked)




3 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0
Build ID: 20160502172042

Steps to reproduce:

The following JavaScript code will always produce incorrect output.

var dateOptions = {
    weekday: "short",
    year: "numeric",
    month: "short",
    day: "numeric",
    hour: "2-digit",
    minute: "2-digit"
var date = "2016-03-14T02:49:54.000Z";
var dateString = new Date(date).toLocaleString("en-AU", dateOptions);

Actual results:

dateString generated as 'Mon., 14 Mar.,2016, 10:49 am'

Note the ., characters after the day and month.

Expected results:

dateString generated as 'Mon, 14 Mar,2016, 10:49 am'


3 years ago
Component: Untriaged → JavaScript: Internationalization API

Comment 1

3 years ago
Not to propose that one format or the other is better, but.

The Intl API does not guarantee particular formatting in response to particular options.  There is no spec-level guarantee that "short" weekdays will be abbreviations or that those abbreviations will or will not use periods.  You shouldn't rely on these particular formatting details, nor to some extent should you be requesting us to select/adopt particular formatting.

This particular formatting decision is really more a function of the particular language/locale and its conventions.  If you strongly think lack of periods is desirable, you probably should request the change from the CLDR people.  We'll adopt (in time) whatever they choose to specify.  And I strongly doubt we'll deviate from whatever they've selected for this stuff.
Can we close this then?
You need to log in before you can comment on or make changes to this bug.