globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Date: Fix parser lookup (use descending order) #732

Closed rxaviers closed 7 years ago

rxaviers commented 7 years ago

parseDate fails on Turkish full datetime with Monday or Saturday.

The root cause is that the parser lookup finds Cuma (Fri) before it finds Cumartesi (Sat), similarly it finds Pazar (Sun) before it finds Pazartesi (Mon), and therefore the token doesn't entirely consume the input.

The fix approach is to start the lookup with longer names, then the shorter ones.

Fixes #690