Hi, I''ve search this term on google and didn''t get the result that im looking for. given a date and a locale, some times the date in ''%d/%m''%Y'' but sometimes it ''%m/%d/%Y'' according to the locale. how to parse this date ? Ahmy Yulrizka -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 April 2012 03:51, Ahmy Yulrizka <ahmy135-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, I''ve search this term on google and didn''t get the result that im > looking for. > > given a date and a locale, some times the date in ''%d/%m''%Y'' but sometimes > it ''%m/%d/%Y'' according to the locale.I think the best solution is not to allow free format of date but to provide separate fields for each part. datetime_select can do this for you automatically. If you really need to do it however, then provided you know what the format is then use strptime to parse it. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for your reply colin but the thing is, i dont control the format. Im trying to parse brithday given by facebook. it give both of information the locale like ''en_US'' and then the birthday like ''10/21/1980'' and it''s differ according the facebook user''s setting. if this is not built in in ruby/rails, is there any gem for this ? Ahmy Yulrizka On Fri, Apr 20, 2012 at 1:56 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 20 April 2012 03:51, Ahmy Yulrizka <ahmy135-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, I''ve search this term on google and didn''t get the result that im > > looking for. > > > > given a date and a locale, some times the date in ''%d/%m''%Y'' but > sometimes > > it ''%m/%d/%Y'' according to the locale. > > I think the best solution is not to allow free format of date but to > provide separate fields for each part. datetime_select can do this > for you automatically. > > If you really need to do it however, then provided you know what the > format is then use strptime to parse it. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.