The resulting datetime is 12 hours off, since without the Meridian indicator (i.e., am/pm), it can only be reasonably interpreted as a 24-hour clock datetime.
Versions of i18n, rails, and anything else you think is necessary
I18::Backend::Base#translate_localization_formatstrips %p/%P unless object.respond_to?(:hour). Date#hour is a private method, so object.respond_to?(:hour) is false, despite Date#strftime supporting the %p/%P fields:
What I tried to do
What I expected to happen
What actually happened
The resulting datetime is 12 hours off, since without the Meridian indicator (i.e.,
am/pm
), it can only be reasonably interpreted as a 24-hour clock datetime.Versions of i18n, rails, and anything else you think is necessary
i18n
:v1.12.0
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
Explanation
I18::Backend::Base#translate_localization_format
strips%p/%P
unlessobject.respond_to?(:hour)
.Date#hour
is a private method, soobject.respond_to?(:hour)
isfalse
, despiteDate#strftime
supporting the%p/%P
fields:This conditional was added in this commit (2008-06-17).