I agree that Todo.show_from is a Date converted to the user's timezone (*).
But does the time_zone in the :condition clause refer to the database field
(in UTC (**) ) or does it refer to Todo.show_from (in the users time_zone)?

I always thought activerecord just appends the :condition clause to the SQL
query and thus refers to the database field and not the getter/setter of the
object. Or am I wrong?

 

Furthermore, you say "Basically, Times/Datetimes in the database are in UTC,
but Dates are not". I assume you mean UTC only when
config.active_record.default_timezone is UTC?

 

(*) BTW, is this controlled by Tracks' setting (prefs.time_zone) or by  the
timezone setting in application.rb?

(**) assuming config.active_record.default_timezone is UTC

 

Reinier

 

 

Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Eric Allen
Verzonden: maandag 8 september 2008 16:37
Aan: [email protected]
Onderwerp: Re: [Tracks-discuss] ticket 747 and timezone issue

 

>From what I can tell, Rails 2.1's timezone updates didn't affect the Date
class at all. Since show_from is a Date parsed directly from the user, it
will be in the user's timezone. We could change show_from to be a datetime
at midnight of the specified day in the user's timezone, but my patch
requires less modification. Basically, Times/Datetimes in the database are
in UTC, but Dates are not.

 

On Sep 8, 2008, at 10:31 AM, Reinier Balt wrote:





I find the whole timezone thing confusing right now :-) So you are probably
right in that the patch was wrong.

 

I'm also not convinced yet about your patch though. In my application.rb I
have

-       a setting for the timezone that is used to store dates in the
database (I use UTC).

-       Since the upgrade to rails 2.1 (?) there is a new setting for the
timezone where your server is at. (I use 'Amsterdam')

-       And we have the timezone setting in the preferences. (I use UTC +1)

 

Assuming dates in the database are in UTC shouldn't

 

find(:all, :conditions => ['show_from <= ?', Time.now.utc ]).collect { |t|
t.activate! }

 

be correct? Or is activerecord doing timezone conversions in the :conditions
clause too?

 

You're suggesting:

 

find(:all, :conditions => ['show_from <= ?', proxy_owner.date ]).collect {
|t| t.activate! }

 

proxy_owner.date uses Time.now.in_time_zone(prefs.time_zone).to_date

 

So it uses the timezone setting from Tracks' preferences. If activerecord is
_not_ doing timezone conversion in the :conditions, it compares UTC with the
users pref, right? Or am I missing something?

 

Everything probably changes if a user changes the default
config.active_record.default_timezone from UTC to something else. I think
that in that case using Time.now.utc goes wrong.

 

Isn't the best route to use
Time.now.in_time_zone(config.active_record.default_timezone)  or something
like that? Any timezone wizards here :-)

 

Reinier

 

 

Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Eric Allen
Verzonden: zondag 7 september 2008 4:56
Aan: [email protected]
Onderwerp: [Tracks-discuss] ticket 747 and timezone issue

 

I believe the fix
<http://github.com/bsag/tracks/commit/4ac09ed3ae391672f4077c0991b0bb8fc64247
56>  for ticket 747 <http://dev.rousette.org.uk/ticket/747>  is incorrect.
It may fix for people who are ahead of UTC, but somebody like me who lives
behind UTC (in the US) will see todos activate from the tickler before they
should. I believe the correct fix is proxy_owner.date, not Time.now.utc.
Attached is the commit I would push to master if I were sure it didn't break
other stuff. It has fixed my problem (which I'm not sure I ever filed a bug
for). Comments?

 

 

 

_______________________________________________
Tracks-discuss mailing list
[email protected]
http://lists.rousette.org.uk/mailman/listinfo/tracks-discuss

Reply via email to