angular-moment icon indicating copy to clipboard operation
angular-moment copied to clipboard

Update amMoment.changeLocale()

Open geroyche opened this issue 9 years ago • 3 comments
trafficstars

as per the current moment.js docs, moment.locale() is deprecated (and produces warnings in the console). it should be replaced with updateLocale()

https://github.com/moment/moment/issues/3043#issuecomment-197017584

geroyche avatar Nov 03 '16 09:11 geroyche

It seems like only the second parameter to locale was deprecated (i.e. customizing strings). Can you please send a PR that will call updateLocale if the second parameter is provided?

Thanks!

urish avatar Nov 03 '16 09:11 urish

not only so. it's also about whether the locale already exists or not.

.locale(locale) to simply load an existing locale .locale(locale, opt) to load a newly created one .updateLocale(locale, opt) to load an existing locale and customize

maybe it would be best to additionally provide .locale() and updateLocale() to your directive? that way existing code will continue to work, and in new code users can decide what to call, based on their knowledge about whether a locale exists already or not.

geroyche avatar Nov 03 '16 10:11 geroyche

Yes, that makes sense. I think that the best solution would be to deprecate the second parameter to changeLocale. If you want to define a new locale, or update an existing one - just go directly to moment API.

urish avatar Nov 04 '16 18:11 urish