Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected difference when parsing with ActiveSupport time_class #25

Closed
jwarchol opened this issue Dec 3, 2010 · 2 comments
Closed

Comments

@jwarchol
Copy link

jwarchol commented Dec 3, 2010

I noticed odd results when parsing the same string after switching Chronic.time_class to an ActiveSupport time with zone. I've got some ideas of what might be the problem and will update this issue as I explore. Here is some code to show the issue.

require 'rubygems'
require 'chronic'
require 'active_support/time'

s = "8/1/10"

no_as_tc = Chronic.parse(s)
puts no_as_tc.class.name + "\t" + no_as_tc.inspect

Time.zone = "UTC"
Chronic.time_class = Time.zone

yes_as_tc = Chronic.parse(s)
puts yes_as_tc.class.name + "\t" + yes_as_tc.inspect
@jwarchol
Copy link
Author

jwarchol commented Dec 3, 2010

Showing the output might be nice too ;-) :

Time    Sun Aug 01 12:00:00 -0400 2010
Time    Fri, 01 Aug 0010 12:00:00 UTC +00:00

@leejarvis
Copy link
Collaborator

Notice these outputs:

1.8.7
-----
Time        Sun Aug 01 12:00:00 +0100 2010
Time(AR)    Fri, 01 Aug 0010 12:00:00 UTC +00:00

1.9.2
-----
Time        0010-08-01 12:00:00 +0100
Time(AR)    Sun, 01 Aug 0010 12:00:00 UTC +00:00

As you can see, on Ruby 1.9.2, all went as expected. This is because 1.8 handles years differently to 1.9. ActiveRecord is obviously doing something to ensure 1.8 works like 1.9 does.

I'm going to close this as a duplicate to #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants