Problem changing datetime format

Discussion in 'Ruby' started by reed, Feb 9, 2007.

  1. reed

    reed Guest

    I am trying to format some datetimes like this...2007, February the
    9th, 6:30pm

    I have the following which gets me part way there.

    ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update:)my_date_format
    => "%Y, %d %B, %I:%M%p")

    There are 2 problems
    1. There is no "th" formatter so that I get 1st, 2nd, 3rd, 4th, 5th,
    etc.
    2. PM is in uppercase and I would prefer it in lower.

    TIA
     
    reed, Feb 9, 2007
    #1
    1. Advertising

  2. On Feb 8, 2007, at 8:40 PM, reed wrote:

    > I am trying to format some datetimes like this...2007, February the
    > 9th, 6:30pm
    >
    > I have the following which gets me part way there.
    >
    > ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(
    > :my_date_format
    > => "%Y, %d %B, %I:%M%p")
    >
    > There are 2 problems
    > 1. There is no "th" formatter so that I get 1st, 2nd, 3rd, 4th, 5th,
    > etc.
    > 2. PM is in uppercase and I would prefer it in lower.
    >
    > TIA


    Roll your own a bit:

    http://api.rubyonrails.org/classes/Inflector.html#M001091
    (part of ActiveSupport)

    Just .downcase the AM/PM

    You're asking on the Ruby list, but you clearly have ActiveSupport.
    If this is more of a Rails question, you may get more response on the
    Rails list ().

    -Rob

    Rob Biedenharn http://agileconsultingllc.com
     
    Rob Biedenharn, Feb 9, 2007
    #2
    1. Advertising

  3. reed

    reed Guest

    On Feb 9, 4:38 pm, Rob Biedenharn <> wrote:
    > On Feb 8, 2007, at 8:40 PM, reed wrote:
    >
    > > I am trying to format some datetimes like this...2007, February the
    > > 9th, 6:30pm

    >
    > > I have the following which gets me part way there.

    >
    > > ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(
    > > :my_date_format
    > > => "%Y, %d %B, %I:%M%p")

    >
    > > There are 2 problems
    > > 1. There is no "th" formatter so that I get 1st, 2nd, 3rd, 4th, 5th,
    > > etc.
    > > 2. PM is in uppercase and I would prefer it in lower.

    >
    > > TIA

    >
    > Roll your own a bit:
    >
    > http://api.rubyonrails.org/classes/Inflector.html#M001091
    > (part of ActiveSupport)
    >
    > Just .downcase the AM/PM
    >
    > You're asking on the Ruby list, but you clearly have ActiveSupport.
    > If this is more of a Rails question, you may get more response on the
    > Rails list ().
    >
    > -Rob
    >
    > Rob Biedenharn http://agileconsultingllc.com
    >


    Thanks for that, I will repost on the rails group.
     
    reed, Feb 9, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    765
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    602
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    442
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    377
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    803
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page