27 September 2016

javascript dates in firefox and locales

Today I learnt:

You actually have to reinstall firefox using a different download to get `new Date(dateString)` to use a different date format (i.e. non-US).

https://jqueryvalidation.org/date-method/

This method should not be used, since it relies on the new Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js).

So if you're using chocolatey or boxstarter like I am (my boxstarter script) you need to add the locale flag: https://chocolatey.org/packages/firefox

choco install Firefox -packageParameters "l=en-GB".

Reinstalling the package with --force is sufficient to change it.

It would seem chrome has no way change the format from en-US.

To be clear the correct solution is to do as the documentation says and not use that method, however it's a bit mean having a pitfall like that in the API. And sometimes you just have to work with the code you have...

No comments: