This project is archived and is in readonly mode.
Accessing datetime via read_attribute loses timezone
-
Mark Turner
What version of Rails are you using?
-
Frederick Cheung
Well currently the conversion happens at the level of the automatically generated attribute reader so it's not surprising that this happens.
All you need to do is change your code to say
read_attribute(:start_time).in_time_zoneFurthermore I'm of the opinion that time zone conversions etc... are none of read_attribute's business. It's a low level method, so if you use it there will be slighly more faffing around
-
Artem Ignatiev
What version of Rails are you using? Using 2.2, patch is against 07298fd0929ae1c6dd6d1b41bf320112d6bfc6a0 (Fri Dec 26 01:49:14 2008 +0000)
2Frederick:
Well, after reading the source I came to conclusion that it's intended behaviour when reading datetime attributes.
Perhaps, a note should be added to rdoc about timezone conversion when reading/writing datetime attributes?
-
Geoff Buesing
- State changed from new to wontfix
In agreement with Frederick -- time zone conversions shouldn't be done inside of read_attribute.
@Artem, agreed, an rdoc note could help by explaining that time zone conversions are done via generated methods, and not inside of read_attribute.