Note that there are some explanatory texts on larger screens.

plurals
  1. POAM/PM not uppercase when using I18n.l with %p in Rails
    primarykey
    data
    text
    <p>I'm having an issue which I can't seem to figure out. I'm trying to format a date using a custom format I've defined in my en.yml file:</p> <pre><code>en: hello: "Hello world" time: formats: history_table: "%m/%d/%Y %I:%M:%S %p %Z" </code></pre> <p>This is being called using the 'l' helper:</p> <pre><code>l version.created_at, :format =&gt; :history_table </code></pre> <p>For some reason this is displaying the AM/PM in lowercase, instead of in uppercase as should be the case with %p.</p> <p>I've played around in the console a bit, and it seems like it's a difference in behavior between the localization function and strftime:</p> <pre><code>ruby-1.9.2-p180 :043 &gt; I18n.l user.updated_at, :format =&gt; "%m/%d/%Y %I:%M:%S %p %Z" =&gt; "03/23/2011 01:52:16 am UTC" ruby-1.9.2-p180 :044 &gt; user.updated_at.strftime("%m/%d/%Y %I:%M:%S %p %Z") =&gt; "03/23/2011 01:52:16 AM UTC" </code></pre> <p>Am I doing something wrong? Is this a bug? Any guidance is greatly appreciated as my forehead is sore from banging it against the wall.</p> <p>Edit: This has been solved(ish). Looking at the default activesupport localization, there isn't any differentiation between %p and %P. <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml" rel="nofollow">https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml</a></p> <p>I over-rode the localization in my local en.yml file to use uppercase. I would really have liked to see Rails support both options however.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload