Brian McManus
2013-May-01 17:35 UTC
time_zone_options_for_select values use full zone name?
I''m curious about something I noticed with
time_zone_options_for_select.
The existing implementation sets up a lambda to convert the zones into
something usable by options_for_select. That lambda looks like:
convert_zones = lambda { |list| list.map { |z| [ z.to_s, z.name ] } }
z.to_s returns the Rails TimeZone name. Are these standard names for other
systems? They do not seem to be. Is there a logical reason we don''t do
something like this instead?
convert_zones = lambda { |list| list.map { |z| [ z.tzinfo.identifier, z.name ] }
}
This uses the TZ identifier as the value in the select list instead of the
Rails TimeZone name. As far as I can see from ActiveSupport::TimeZone, the
TZ identifier would work as well as the Rails TZ name.
My problem is this. I''m storing the TZ returned from a TZ select into a
field in a Postgres database. I would "like" to be able to use that TZ
in
Postgres queries but the Rails TimeZone seem to be non-standard and
unsupported by Postgres directly. Postgres either expects a full zone name
(tzinfo.identifier) or a zone abbreviation:
http://www.postgresql.org/docs/9.2/static/datatype-datetime.html#DATATYPE-TIMEZONES
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.