[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Problem changing datetime format

reed

2/9/2007 1:35:00 AM

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

2 Answers

Rob Biedenharn

2/9/2007 3:39:00 AM

0


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.ht...
(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 (rubyonrails-talk@googlegroups.com).

-Rob

Rob Biedenharn http://agileconsult...
Rob@AgileConsultingLLC.com



reed

2/9/2007 5:50:00 AM

0

On Feb 9, 4:38 pm, Rob Biedenharn <R...@AgileConsultingLLC.com> 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.ht...
> (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 (rubyonrails-talk@googlegroups.com).
>
> -Rob
>
> Rob Biedenharn http://agileconsult...
> R...@AgileConsultingLLC.com

Thanks for that, I will repost on the rails group.