>> t1 = Time.now=> Sat Mar 10 19:27:33 -0500 2007>> t2 = t1.change(:hour => 12, :min => 0, :sec => 0)=> Sat Mar 10 12:00:00 -0500 2007>> t2.strftime("%H:%M %p")=> "12:00 PM" Since I am setting hour to 12, I was expecting it to be 12:00 AM. Also t2 is Sat Mar 10 12:00:00. I think 12:00:00 should translate to 12:AM and not to 12:00 PM. I am using ruby 1.8.5 and rails 1.2.2 Any thoughts. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Neeraj Kumar wrote:>>> t1 = Time.now > => Sat Mar 10 19:27:33 -0500 2007 >>> t2 = t1.change(:hour => 12, :min => 0, :sec => 0) > => Sat Mar 10 12:00:00 -0500 2007 >>> t2.strftime("%H:%M %p") > => "12:00 PM" > > > Since I am setting hour to 12, I was expecting it to be 12:00 AM. Also > t2 is Sat Mar 10 12:00:00. > > I think 12:00:00 should translate to 12:AM and not to 12:00 PM. > > I am using ruby 1.8.5 and rails 1.2.2 > > Any thoughts.Even though technically it''s incorrect (noon is "12 M" -- it''s neither anti or post meridian, it is the meridian), by convention midnight is 12 AM and noon is 12 PM, and that rule is codified in the ANSI C strftime function. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The :hour param means the hour out of 24, not 12. 12 == noon, and 0 == midnight. Also %H will give you time on this same scale. You should use %I:>> Time.now.change(:hour => 0, :min => 0, :sec => 0).strftime("%I:%M %p")=> "12:00 AM" On Mar 11, 8:30 am, "Neeraj Kumar" <neeraj....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> >> t1 = Time.now > > => Sat Mar 10 19:27:33 -0500 2007>> t2 = t1.change(:hour => 12, :min => 0, :sec => 0) > > => Sat Mar 10 12:00:00 -0500 2007>> t2.strftime("%H:%M %p") > > => "12:00 PM" > > Since I am setting hour to 12, I was expecting it to be 12:00 AM. Also > t2 is Sat Mar 10 12:00:00. > > I think 12:00:00 should translate to 12:AM and not to 12:00 PM. > > I am using ruby 1.8.5 and rails 1.2.2 > > Any thoughts.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 11, 2007, at 01:30 , Neeraj Kumar wrote:> Since I am setting hour to 12, I was expecting it to be 12:00 AM. Also > t2 is Sat Mar 10 12:00:00. > > I think 12:00:00 should translate to 12:AM and not to 12:00 PM.You''re fighting an uphill battle then, trying to change how the 12 hour clock is designed: Noon == "12 pm". Midnight == "12 am". http:// en.wikipedia.org/wiki/12-hour_clock has more information. -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---