Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localisation is not handled correctly for date functions (moment.js) #631

Closed
lukereative opened this issue Sep 7, 2018 · 2 comments · Fixed by #630
Closed

Localisation is not handled correctly for date functions (moment.js) #631

lukereative opened this issue Sep 7, 2018 · 2 comments · Fixed by #630

Comments

@lukereative
Copy link
Contributor

An issue has been discovered through a couple of the scenarios in the 'Search for a page' tests now failing with the new search component.

The tests are failing because a NZ formatted date (DD-MM-YYYY) is being provided to a non HTML5 date field which is not being localised and functioning in the default US format (MM-DD-YYYY) – thus when a NZ date is provided to the field the date is parsed incorrectly and the test fails.

@unclecheese and I have done some investigation into this and the problem is three-fold:

  1. The date format provided by the Basic Context (for behat provided by silverstripe-behat-extension) is hard coded to the NZ date format 'd-m-Y' but the default member and date format is 'd-m-Y', @unclecheese has investigated this and has a solution to make context aware of locale.

  2. Date fields have a number of problems:

  1. moment.js locales are not loaded into the vendor.js bundle – this means that during yarn test or yarn watch moment has access to all it's locals but when you run yarn build momentjs doesn't have access to any of it's locale files and therefore falls back to the default 'en' (US) locale, this is what's blocking us from fixing the behat tests at the moment.

@unclecheese and I have investigated including all the locales into the build but this would add ~200k to the build size which is not desirable. We have identified that the solution will either be adding a SS JS requirement on page load based on member locale or possibly look at replacing momentjs with another library which handles localisation differently (possiblydate-fns)

@robbieaverill
Copy link
Contributor

There's one PR left

@chillu
Copy link
Member

chillu commented Jan 28, 2019

@bergice Could you please check if this is still an issue?

@bergice bergice self-assigned this Jan 31, 2019
@bergice bergice closed this as completed Feb 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants