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

91% of formatted dates differ from native implementation #124

Open
vectart opened this issue Jul 14, 2015 · 18 comments
Open

91% of formatted dates differ from native implementation #124

vectart opened this issue Jul 14, 2015 · 18 comments
Assignees

Comments

@vectart
Copy link

vectart commented Jul 14, 2015

Since I had faced #117 formatting issue, I created a simple check suite of native and polyfill implementation and it revealed that 5313 from 5831 formatted dates are different from native ones (https://jsbin.com/wekebe/edit?js,output, check Chrome dev console)

intl_results

Could be the Intl.js improved to fit at least 50% of variations?

@caridy
Copy link
Collaborator

caridy commented Jul 14, 2015

@vectart this is awesome. I will look into the details when I get a chance.

@caridy caridy self-assigned this Jul 14, 2015
@caridy
Copy link
Collaborator

caridy commented Jul 14, 2015

Note to self: exact same results are exhibited in firefox.

@andyearnshaw
Copy link
Owner

Whilst fixing this, it might be worth including this code as a regression test suite with an automatic fail if we don't achieve above a certain threshold. I've been wanting to write some regression tests for a while now, it didn't occur to me to check all permutations against the native implementation that's shipped with node v0.12.

V8's Intl still fails a few of DateTimeFormat tests, but I think those are more or less superficial.

@caridy
Copy link
Collaborator

caridy commented Jul 14, 2015

I do have a test suite locally that I was planning to commit. Will try to get that in soon. @jasonmit was also going to help with that.

@andyearnshaw
Copy link
Owner

Awesome, I look forward to seeing it in action. :-)

@vectart vectart changed the title 91% of formatted dates are different from native implementation 91% of formatted dates differ from native implementation Jul 15, 2015
@vectart
Copy link
Author

vectart commented Jul 15, 2015

Yes, it would be great to see in test results something more meaningful than

9.2.1_1
9.2.1_3
9.2.1_4
9.2.1_8_c_ii
9.2.1_8_c_vi
9.2.2

@caridy
Copy link
Collaborator

caridy commented Jul 15, 2015

@vectart those are generated tests for every step of the algo based on the specifications, we will just add other tests to verify cldr data, and compare with native.

@vectart
Copy link
Author

vectart commented Jul 15, 2015

Seems like these generated tests are absolutely useless

@andyearnshaw
Copy link
Owner

@vectart: those tests are incredibly useful. Although they don't assume any specific locales are supported (or that we're even using CLDR), they ensure that the bare minimum of required date/time formats are supported, the correct options are resolved for formatters, tags are properly canonicalised and matched and much more.

That being said, Intl.js has sorely needed some tests to prevent locale data-based regressions for a long time.

@vectart
Copy link
Author

vectart commented Jul 15, 2015

@andyearnshaw How was the bare minimum of required date/time formats defined if such basic formats doesn't work?
#117 { month: 'long' }
#126 { month: 'long' }
#125 { weekday: 'long' }

I really want to use Intl.js but seems it's better to fallback to Moment.js, Globalize or other more stable date-formatting library.

@andyearnshaw
Copy link
Owner

From the spec, section 12.2.3:

The following subsets must be available for each locale:

  • weekday, year, month, day, hour, minute, second
  • weekday, year, month, day
  • year, month, day
  • year, month
  • month, day
  • hour, minute, second
  • hour, minute

Initially, we only supported one pattern for each of those subsets, the bare minimum to meet the spec's requirements, pass the tests and cover the majority of use cases. @caridy is working on improving the date formats—have a little patience (or feel free to contribute 😉).

@oliviertassinari
Copy link

+1

@chilipote
Copy link

Some news about that ?

@caridy
Copy link
Collaborator

caridy commented Feb 11, 2016

with the v1.1.0 release, we are down to 60%, big improvements. Now I'm seeing 3505 from 5831 failed in FF and Chrome.

@caridy
Copy link
Collaborator

caridy commented May 12, 2016

with the v1.2.0 release, we are down to 0%, impressive. Now I'm seeing 0 from 5831 failed in FF and Chrome.

@caridy
Copy link
Collaborator

caridy commented May 12, 2016

fixed by #171

update: this is not fixed yet.

@vectart
Copy link
Author

vectart commented May 12, 2016

Absolutely impressive! Thanks, everyone!

@caridy
Copy link
Collaborator

caridy commented May 13, 2016

@vectart something happen when attempting to test your test, I ended up copying that as part of the automation process, and I still see a bunch of differences, some of them, the polyfill is doing the right thing, while browsers take shortcut, but in general, we will have to continue this effort to close the gap. that 0% was very smelly :(, but let's keep targeting something like 20%.

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

5 participants