I have been parsing some dates in Spanish and found out that the a token for am/pm does not get applied with the locale es.
See for example this date in English. It gets parsed properly by doing 8 pm -> 20 h.
>>> arrow.get('June 30, 2019 - 08:00 pm', "MMMM DD, YYYY - hh:mm a")
<Arrow [2019-06-30T20:00:00+00:00]>
However, in Spanish it does not work:
>>> arrow.get('Junio 30, 2019 - 08:00 pm', "MMMM DD, YYYY - hh:mm a", locale="es")
<Arrow [2019-06-30T08:00:00+00:00]>
In fact, anything can be put in the a token!
>>> arrow.get('Junio 30, 2019 - 08:00 pasdfasdfm', "MMMM DD, YYYY - hh:mm a", locale="es")
<Arrow [2019-06-30T08:00:00+00:00]>
Hi @NestorTejero thanks for reporting this, I can reproduce it on the master branch.
From a quick glance at https://github.com/crsmithdev/arrow/blob/master/arrow/locales.py#L359 it looks like the Spanish locale is inheriting the meridians class variable from the base locale, meaning they are blank.
@systemcatch would this be fixed by simply getting translations for meridians = {"am": "", "pm": "", "AM": "", "PM": ""}?
@jadchaar yup that would fix it, I'll do a PR.
This has been fixed in: https://github.com/crsmithdev/arrow/pull/610. This change should ship with arrow 0.14.3.
Most helpful comment
@systemcatch would this be fixed by simply getting translations for
meridians = {"am": "", "pm": "", "AM": "", "PM": ""}?