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

Switch to using the raw CLDR data #77

Closed
andyearnshaw opened this issue Oct 13, 2014 · 6 comments
Closed

Switch to using the raw CLDR data #77

andyearnshaw opened this issue Oct 13, 2014 · 6 comments

Comments

@andyearnshaw
Copy link
Owner

In a rather short-sighted attempt at boosting the performance of the library, I wrote a small script to compile CLDR data into the format used by the ECMA-402 spec. I see the mistake now, as it's become difficult to include all the date patterns for each locale without bulking up the data tremendously.

We should use the raw CLDR formats for the best chance at matching the output from native versions of the Intl APIs.

@caridy
Copy link
Collaborator

caridy commented Oct 13, 2014

/cc @ericf

@caridy
Copy link
Collaborator

caridy commented Mar 18, 2015

I have done a lot of experimentation on this regards, the problem is that the amount of data will also increase drastically if we add all CLDR data, I'm looking at:

            "timeFormats": {
              "full": "h:mm:ss a zzzz",
              "long": "h:mm:ss a z",
              "medium": "h:mm:ss a",
              "short": "h:mm a"
            },
            "dateTimeFormats": {
              "full": "{1} 'at' {0}",
              "long": "{1} 'at' {0}",
              "medium": "{1}, {0}",
              "short": "{1}, {0}",
              "availableFormats": {
                "E": "ccc",
                "EHm": "E HH:mm",
                "EHms": "E HH:mm:ss",
                "Ed": "d E",
                "Ehm": "E h:mm a",
                "Ehms": "E h:mm:ss a",
                "Gy": "y G",
                "GyMMM": "MMM y G",
                "GyMMMEd": "E, MMM d, y G",
                "GyMMMd": "MMM d, y G",
                "H": "HH",
                "Hm": "HH:mm",
                "Hms": "HH:mm:ss",
                "M": "L",
                "MEd": "E, M/d",
                "MMM": "LLL",
                "MMMEd": "E, MMM d",
                "MMMd": "MMM d",
                "Md": "M/d",
                "d": "d",
                "h": "h a",
                "hm": "h:mm a",
                "hms": "h:mm:ss a",
                "ms": "mm:ss",
                "y": "y",
                "yM": "M/y",
                "yMEd": "E, M/d/y",
                "yMMM": "MMM y",
                "yMMMEd": "E, MMM d, y",
                "yMMMd": "MMM d, y",
                "yMd": "M/d/y",
                "yQQQ": "QQQ y",
                "yQQQQ": "QQQQ y"
              }
            }

although, I will say that this is not more than:

"formats": [
            {
                "weekday": "long",
                "month": "long",
                "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",
                "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": "long",
                "day": "numeric",
                "year": "numeric",
                "pattern": "{weekday}, {month} {day}, {year}"
            },
            {
                "weekday": "long",
                "month": "short",
                "day": "numeric",
                "year": "numeric",
                "pattern": "{weekday}, {month} {day}, {year}"
            },
            {
                "month": "long",
                "day": "numeric",
                "year": "numeric",
                "pattern": "{month} {day}, {year}"
            },
            {
                "month": "numeric",
                "day": "numeric",
                "year": "numeric",
                "pattern": "{month}/{day}/{year}"
            },
            {
                "month": "short",
                "day": "numeric",
                "year": "numeric",
                "pattern": "{month} {day}, {year}"
            },
            {
                "month": "numeric",
                "year": "numeric",
                "pattern": "{month}/{year}"
            },
            {
                "month": "long",
                "year": "numeric",
                "pattern": "{month} {year}"
            },
            {
                "month": "short",
                "year": "numeric",
                "pattern": "{month} {year}"
            },
            {
                "month": "long",
                "day": "numeric",
                "pattern": "{month} {day}"
            },
            {
                "month": "short",
                "day": "numeric",
                "pattern": "{month} {day}"
            },
            {
                "month": "numeric",
                "day": "numeric",
                "pattern": "{month}/{day}"
            },
            {
                "hour": "numeric",
                "minute": "2-digit",
                "second": "2-digit",
                "pattern": "{hour}:{minute}:{second}",
                "pattern12": "{hour}:{minute}:{second} {ampm}"
            },
            {
                "hour": "numeric",
                "minute": "2-digit",
                "pattern": "{hour}:{minute}",
                "pattern12": "{hour}:{minute} {ampm}"
            }
        ],

but it will require more computations during runtime, not that I'm worry about it, since this is a polyfill for older browsers :), what do you think about this @andyearnshaw and @ericf ?

@ericf
Copy link
Collaborator

ericf commented Mar 18, 2015

not that I'm worry about it, since this is a polyfill for older browsers :)

And Node.js, where the problem is exacerbated with many connections to a server.

@andyearnshaw
Copy link
Owner Author

Indeed, that was the reason for the custom data format in the first place
(to avoid the runtime costs) and gzipping would be highly beneficial to the
format because of the many duplicated string patterns.

I think the payoff would probably be worth it though, it seems to be every
few weeks we get another report about Intl.js not matching browser formats.
On 18 Mar 2015 19:32, "Eric Ferraiuolo" notifications@github.com wrote:

not that I'm worry about it, since this is a polyfill for older browsers :)

And Node.js, where the problem is exacerbated with many connections to a
server.


Reply to this email directly or view it on GitHub
#77 (comment).

@caridy
Copy link
Collaborator

caridy commented Apr 6, 2015

Ok, I finally get a chance to implement this here: 869782c

@caridy
Copy link
Collaborator

caridy commented Jun 18, 2015

this is now part of 1.0.0-rc-1

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

No branches or pull requests

3 participants