Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

supporting short month format in most cases to match browser's behavior #85

Merged
merged 4 commits into from
Apr 27, 2015

Conversation

caridy
Copy link
Collaborator

@caridy caridy commented Mar 18, 2015

This matches FF and Chrome implementations. As a result, we get support these new entries:

Wednesday, December 19, 2012, 10:00:00 PM
Wednesday, Dec 19, 2012, 10:00:00 PM           // new entry

Wednesday, December 19, 2012
Wednesday, Dec 19, 2012           // new entry

December 19, 2012
Dec 19, 2012           // new entry

December 2012
Dec 2012           // new entry

December 19
Dec 19           // new entry

This does not come for free though, it increases the size of the data slightly, but not significant IMO, essentially it will increase each locale with:

            {
                "weekday": "long",
                "month": "short",
                "day": "numeric",
                "year": "numeric",
                "hour": "numeric",
                "minute": "2-digit",
                "second": "2-digit",
                "pattern": "{weekday}, {month} {day}, {year}, {hour}:{minute}:{second}",
                "pattern12": "{weekday}, {month} {day}, {year}, {hour}:{minute}:{second} {ampm}"
            },
            {
                "weekday": "long",
                "month": "short",
                "day": "numeric",
                "year": "numeric",
                "pattern": "{weekday}, {month} {day}, {year}"
            },
            {
                "month": "short",
                "day": "numeric",
                "year": "numeric",
                "pattern": "{month} {day}, {year}"
            },
            {
                "month": "short",
                "year": "numeric",
                "pattern": "{month} {year}"
            },
            {
                "month": "short",
                "day": "numeric",
                "pattern": "{month} {day}"
            },
        ],

I will probably propose to drop the two first entries, at the end of the day, if you are going for the expanded date format, you probably don't care about short month since you're using long weekday, and even time, e.g.:

Wednesday, Dec 19, 2012, 10:00:00 PM
Wednesday, Dec 19, 2012

That will be sort of a middle ground where we will increase just few entries to support the minimum number of formats.

@caridy
Copy link
Collaborator Author

caridy commented Mar 18, 2015

this PR is related to #65, and fixes #68 and #69, and partially solves #75

@caridy
Copy link
Collaborator Author

caridy commented Mar 18, 2015

another alternative is to continue the work on #77

@ericf
Copy link
Collaborator

ericf commented Mar 18, 2015

@caridy what's the gz size difference between the current and this new data for say en-US?

* supporting short month format in most cases to match browser's behavior
* cldr 26 from JSON data source
* tested in nodejs 12
* removed any java specific step in the build
@okuryu
Copy link
Contributor

okuryu commented Mar 28, 2015

Hmm.. #69 (and #88) seems not to be fixed by this change, am I missing something?

$ npm install
$ $(npm bin)/grunt update-cldr-data
$ $(npm bin)/grunt cldr
$ $(npm bin)/grunt
$ node -v
> require("./index")
{ __localeSensitiveProtos: 
   { Number: { toLocaleString: [Function] },
     Date: 
      { toLocaleString: [Function],
        toLocaleDateString: [Function],
        toLocaleTimeString: [Function] } },
  default: [Circular] }
> new Intl.DateTimeFormat("ja",{year:"numeric",month:"long",day:"numeric",weekday:"long"}).format(new Date())
'2015年3月月28日(土曜日)'

Expected result as follows (Chrome's result).

> new Intl.DateTimeFormat("ja",{year:"numeric",month:"long",day:"numeric",weekday:"long"}).format(new Date())
"2015年3月28日土曜日"

@caridy
Copy link
Collaborator Author

caridy commented Mar 31, 2015

@okuryu this is really not much about the short variation (yes, I have a patch in there to add few shorts variations, but this is really about the new build process so we can start making significant changes again.

To be more specific, we want to use CLDR data to support all variations, by simply using CLDR data directly instead of a computed portion of it. Here you can see the big difference from one locale to another:

https://github.com/unicode-cldr/cldr-dates-full/blob/master/main/en-001/ca-gregorian.json#L309-L349
https://github.com/unicode-cldr/cldr-dates-full/blob/master/main/ja/ca-gregorian.json#L300-L345

As you can see, they don't have the same entries, instead, we just need to update our computations, to pick up the right variation from the list available instead of a predefined, prebuild subset.

This PR seems to be complete now, although functional tests (saucelab tests are failing, I might need help with that since I don't have too much time before going on vacation).

@mjackson
Copy link

mjackson commented Apr 1, 2015

I'm +1 for whatever we need to do to make Intl.js act like browsers do.

…d in the spec, this will help to match browsers
@caridy
Copy link
Collaborator Author

caridy commented Apr 6, 2015

fixes #77

@caridy
Copy link
Collaborator Author

caridy commented Apr 6, 2015

fixes #75

@caridy
Copy link
Collaborator Author

caridy commented Apr 6, 2015

fixes #69

@caridy
Copy link
Collaborator Author

caridy commented Apr 6, 2015

fixes #68

@caridy
Copy link
Collaborator Author

caridy commented Apr 6, 2015

@juandopazo is working on the saucelab failures which is the only missing bit at this point for rc1 to be released.

@caridy
Copy link
Collaborator Author

caridy commented Apr 9, 2015

We were able to test saucelabs manually, we just need to figure what to do with the travis integration that is failing today. I will merge this and figure that in a different PR.

@longlho
Copy link

longlho commented Apr 24, 2015

ping @caridy it'd be awesome if u can merge this 👍 thanks!

andyearnshaw added a commit that referenced this pull request Apr 27, 2015
supporting short `month` format in most cases to match browser's behavior
@andyearnshaw andyearnshaw merged commit f5ab43f into andyearnshaw:master Apr 27, 2015
@redonkulus
Copy link

Thanks @andyearnshaw. When can we expect it to be published?

@kate2753
Copy link
Collaborator

@caridy it seems that there's missing src file src\cldr.js. With latest source code grunt build fails with this error

Running "bundle_jsnext:dest" (bundle_jsnext) task
INFO: Using a global wrapper module for "src/main.js", exporting namespace "IntlPolyfill"
Fatal error: Error writing bundle in "dist/Intl.js": Error: missing module import from ./core for path: ./cldr

@marcelombc
Copy link

Can you please release a new version/tag with this fix? Thank you.

@kate2753 kate2753 mentioned this pull request May 18, 2015
@Coobaha
Copy link

Coobaha commented May 25, 2015

publish it please 👍

@pgherveou
Copy link

yep a new npm version with these fixes would be great
Thks for the hard work!

@caridy
Copy link
Collaborator Author

caridy commented Jun 10, 2015

1.0.0-rc-1 is in NPM, help us to test it...

@pgherveou
Copy link

works fine for me, thks a lot

@bcecchinato
Copy link

Issue ember-intl/ember-intl#101 is partially fixed (works fine on Chrome and IE11, not on IE9 and IE10).

Regards,

@caridy
Copy link
Collaborator Author

caridy commented Jun 15, 2015

@bcecchinato thanks for the report. Can you give us more details about the issue wiht IE9/IE10?

@bcecchinato
Copy link

@caridy : When using the following format for date :

export default {
    'date-style': {
      day:  '2-digit',
      month:  '2-digit',
      year:  'numeric'
    }
};

Day and month are on one digit when lower than 10. For instance, 15/06/2015 would be written 15/6/2015. The issue was also occurring on Chrome and IE11, since the 1.0.0-rc-1 it seems to be fixed.

Regards,

@caridy
Copy link
Collaborator Author

caridy commented Jun 15, 2015

can you open an issue for that so we can try to fix it. I have some suspicious about it, but I will have to dig in.

@bcecchinato
Copy link

@caridy Done in issue #105 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.