AM/PM select


#1

I have a customer that has a request that the select_datetime fields
have AM/PM selectors instead of 24 hour time.
The rails time and datetime selects seem to only support 24 hour time.
I can’t seem to find any information on this. i was wondering if
there is already a solution out there, or will i have to roll my own?

Sean W.
master nerd of
i heart squares, inc.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613
http://www.iheartsquares.com


#2

Sean W. wrote:

I have a customer that has a request that the select_datetime fields
have AM/PM selectors instead of 24 hour time.
The rails time and datetime selects seem to only support 24 hour time.
I can’t seem to find any information on this. i was wondering if
there is already a solution out there, or will i have to roll my own?

Sean W.
master nerd of
i heart squares, inc.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613
http://www.iheartsquares.com

there is already solution out there… and dont need much coding also…
cos this is only a formatting question…

using the strftime method would solve the trick!
options to use are just like the usual sql commands…

eg.
my_date.strftime("%Y-%m-%d–%H:%M") will generate 2006-06-09–17:30
my_date.strftime("%Y-%m-%d–%I:%M%p") will generate 2006-06-09–5:30PM

hope this helps!


#3

that’s all fine if it’s just the var my_date you’re trying to format,
but how would you go about modifying the datetime_select tag?

<%= datetime_select ‘bug’, ‘added_at’ %>

I can’t get it to work with .strftime in there…


#4

On 6/8/06, Sean W. removed_email_address@domain.invalid wrote:

I have a customer that has a request that the select_datetime fields have
AM/PM selectors instead of 24 hour time.

Here’s a solution I whipped up for a project a while back. Might not
be the best solution, but it did the trick.

http://www.atlrug.org/atlrug/show/12HourHelper

-eric


#5

Eric W. wrote:

On 6/8/06, Sean W. removed_email_address@domain.invalid wrote:

I have a customer that has a request that the select_datetime fields have
AM/PM selectors instead of 24 hour time.

Here’s a solution I whipped up for a project a while back. Might not
be the best solution, but it did the trick.

http://www.atlrug.org/atlrug/show/12HourHelper

Ahhh! Fantastic. And this is a lot better than i was expecting. Nice
solution to put it all into a single Drop. I thought about it being a
mess to have AM/PM selector on the side.

I’ve posted this link into my del.icio.us


#6

I also made something similar, with an am/pm dropdown and model support:

http://www.happyfreelancer.com/?p=10

This is also supposed to be very good:

http://wiki.rubyonrails.org/rails/pages/FlexTimes+Plugin

Hope this helps!