Forum: Ruby on Rails Timzones, UTC, and to_xml()

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2006-06-09 02:17
(Received via mailing list)
Does anyone know a good way to hook into the  AR to_xml() method to
allow for adjusting datetimes to a user's timezone?

Basically I want a user to be able dump all their data before
cancelling an account.  I store all datetime info as UTC as per the
recommendations of Jamis Buck and Scott Barron in the Rails Recipe
article "Dealing with Timezones".  Come to think of it I bet 37Signals
already has figured out a way to do this as they allow users to dump

Any help would be much appreciated.

27c57aaa4bda5ac8b0593659573b522f?d=identicon&s=25 Blair Zajac (Guest)
on 2006-06-09 02:51
(Received via mailing list)
Zack Chandler wrote:
> Any help would be much appreciated.
What is the intended use of the data when they get it?

It seems safer to give it to them in UTC instead of their timezone, no
what they may do with it, so you may be saving them hassle later on.

Also, what if they move timezones after they export it and then they try
import it somewhere and the times will be wrong.


Blair Zajac, Ph.D.
Subversion training, consulting and support
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2006-06-09 16:05
(Received via mailing list)
  I understand this argument and I've thought the pros and cons.
Still, converting makes sense to me as not to confuse the user by
having all the times off by whatever their Timezone offset is...

I know I can always loop through the objects and convert if the AR
attribute is_a? Time... but I love those ruby one-liners...

This topic is locked and can not be replied to.