madeintandem / hstore_accessor

Adds typed hstore-backed field support to ActiveRecord models.
MIT License
242 stars 47 forks source link

Time serialization #28

Closed gorkunov closed 9 years ago

gorkunov commented 10 years ago

Could you explain why time is serialized as integer not as string? There is no place where timezone can be stored with time. With string serialization we can keep timezone with time/date in database.

thegrubbsian commented 9 years ago

No particular reason, I think we just didn't consider timezone. Please feel free to submit a pull request to convert to string serialization with timezone.

tonycoco commented 9 years ago

This is tough. In part because you want to serialize time as strings to keep timezone info, but then you've got to write some logic to do the scope comparators for >, < and eq. Casting the string to a time with zone in PG might be a stretch. I'm all for it, but I don't think it will be easy.

crismali commented 9 years ago

After some internal discussion, it seems likely that you'd be better off storing UTC time only, and if you absolutely need the timezone you should probably store it as a separate column. You could even override the setter and have that store the timezone separately for you rather seamlessly.