Ruby on Rails Wednesday, August 21, 2013

On Aug 20, 2013, at 9:57 AM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:

> On Thu, Aug 15, 2013 at 5:15 PM, Phil <phil@edgedesign.us> wrote:
>
> I'm porting an old rails app to Rails 4 and got stumped tonight on time conversions.
>
> This worked:
>
> Loading development environment (Rails 2.3.18)
> > > Time.now.to_s
> => "08/14/2013 07:09PM"
>
> Now it doesn't on Rails 4.0:
>
> Loading development environment (Rails 4.0.0)
>
> irb(main):002:0> Time.now.to_s
> => "08/15/2013 12:19AM"
>
> 1.9.3 (main):0 > Date.parse("08/20/2013").to_s
> ArgumentError: invalid date
> from (pry):22:in `parse'
> 1.9.3 (main):0 > Date.parse("20/08/2013").to_s
> => "2013-08-20"
> 1.9.3 (main):0 >
>
> In the source for e.g. ruby-1.9.3-p448 see ./doc/NEWS-1.9.1:
>
> o Time.parse and Date.parse interprets slashed numerical dates·
> as "dd/mm/yyyy".
>
> HTH!
> --
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> http://about.me/hassanschroeder
> twitter: @hassan
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAQEDNjSQ6KtaYyn-SrxzAWecv2GZj3y%2BGC3T8ZO1_vrw%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

The documentation, however, points to the libc functions, strftime(3) and strptime(3), which state quite plainly that these formats are reflexive. Hardly seems sporting, does it? Without including a format field, it's probably quite reasonable to assume the parse methods will interpret in that dd/mm/yyyy order, BUT, *with* a format field?? They should not ignore the format field in that case. *That* is the bug.



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9607CE16-D087-41D5-A318-93ACE17F2476%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment