datetime values incorrectly get marked as changed #12459

Closed
bpardee opened this Issue Oct 7, 2013 · 4 comments

Comments

Projects
None yet
4 participants
@bpardee

bpardee commented Oct 7, 2013

Datetime values incorrectly get marked as changed when their parsed from a string with a different timezone.

> a
=> #<Appointment id: 263982, start_at: "2013-08-26 18:00:00", end_at: "2013-08-26 18:30:00">
> a.start_at = a.start_at.to_s
=> "2013-08-26 18:00:00 UTC"
> a.changes
=> {}
> a.start_at = a.start_at.in_time_zone("Eastern Time (US & Canada)")
=> Mon, 26 Aug 2013 14:00:00 EDT -04:00
> a.changes
=> {}
> a.start_at = a.start_at.in_time_zone("Eastern Time (US & Canada)").to_s
=> "2013-08-26 14:00:00 -0400"
> a.changes
=> {"start_at"=>[Mon, 26 Aug 2013 18:00:00 UTC +00:00, Mon, 26 Aug 2013 18:00:00 UTC +00:00]}
@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Oct 9, 2013

Member

Can you write an executable test-case to reproduce the problem? You can use this gist as a starting point.

Member

senny commented Oct 9, 2013

Can you write an executable test-case to reproduce the problem? You can use this gist as a starting point.

@bpardee

This comment has been minimized.

Show comment
Hide comment
@bpardee

bpardee Oct 9, 2013

My apologies for not doing due diligence. This looks to be fixed in 4.1.0beta

bpardee commented Oct 9, 2013

My apologies for not doing due diligence. This looks to be fixed in 4.1.0beta

@bpardee bpardee closed this Oct 9, 2013

@robin850

This comment has been minimized.

Show comment
Hide comment
@robin850

robin850 Oct 13, 2013

Member

@bpardee : Thanks for reporting but is it fixed on the 4-0-stable branch please ? If it's not the case, we need to backport the commit which fixed it.

Member

robin850 commented Oct 13, 2013

@bpardee : Thanks for reporting but is it fixed on the 4-0-stable branch please ? If it's not the case, we need to backport the commit which fixed it.

@bpardee

This comment has been minimized.

Show comment
Hide comment
@bpardee

bpardee Oct 13, 2013

It looks like it's a problem parsing times of the form "2009-02-13 18:31:30 -0500" although I'm not sure why my project using postgres and UTC timezones seems to parse it correctly but still mark it as changed. The test program below works on the latest but not in 4-0-stable.

https://gist.github.com/bpardee/6961999

bpardee commented Oct 13, 2013

It looks like it's a problem parsing times of the form "2009-02-13 18:31:30 -0500" although I'm not sure why my project using postgres and UTC timezones seems to parse it correctly but still mark it as changed. The test program below works on the latest but not in 4-0-stable.

https://gist.github.com/bpardee/6961999

@bpardee bpardee reopened this Oct 13, 2013

georgeguimaraes added a commit to georgeguimaraes/rails that referenced this issue Dec 5, 2013

ActiveRecord::ConnectionAdapters::Column.string_to_time method respec…
…ts string with timezone.


Closes #12278
Closes #12459

Conflicts:
	activerecord/CHANGELOG.md

georgeguimaraes added a commit to georgeguimaraes/rails that referenced this issue Dec 5, 2013

rafaelfranca added a commit that referenced this issue Dec 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment