diff options
| author | Zog | 2018-05-03 11:13:51 +0200 | 
|---|---|---|
| committer | Zog | 2018-05-03 11:13:51 +0200 | 
| commit | 5a9bf4e1d2bf46f7e3b39e87c85cf2848b1db79d (patch) | |
| tree | 26367d6eee0d39a51352507e5797179656405b17 | |
| parent | bc2c7564f0afb7324c59dae67e359807ff78658f (diff) | |
| download | chouette-core-5a9bf4e1d2bf46f7e3b39e87c85cf2848b1db79d.tar.bz2 | |
Refs #6867; Add A LOT of TZs6867-fix-tilmezones-selector
| -rw-r--r-- | app/inputs/full_time_zone_input.rb | 23 | 
1 files changed, 13 insertions, 10 deletions
| diff --git a/app/inputs/full_time_zone_input.rb b/app/inputs/full_time_zone_input.rb index b3f43fa19..6138d17f5 100644 --- a/app/inputs/full_time_zone_input.rb +++ b/app/inputs/full_time_zone_input.rb @@ -2,11 +2,18 @@ class FullTimeZoneInput < SimpleForm::Inputs::CollectionSelectInput    def collection      @collection ||= begin        collection = options.delete(:collection) || begin -        coll = ActiveSupport::TimeZone::MAPPING.invert -        coll.sort_by do |k, v| -          tz = ActiveSupport::TimeZone[k] -          "(#{tz.formatted_offset}) #{tz.name}" +        coll = {} + +        TZInfo::Timezone.all_data_zones.map do |tzinfo| +          # v = ActiveSupport::TimeZone.zones_map[k] +        # coll.sort_by do |v| +        #   "(#{v.formatted_offset}) #{v.name}" +        # end +          next if tzinfo.friendly_identifier =~ /^etc/i +          tz = ActiveSupport::TimeZone.new tzinfo.name#, nil, tzinfo +          coll[[tz.utc_offset, tzinfo.friendly_identifier(true)]] = ["(#{tz.formatted_offset}) #{tzinfo.friendly_identifier(true)}", tz.name]          end +        coll.sort.map(&:last)        end        collection.respond_to?(:call) ? collection.call : collection.to_a      end @@ -15,12 +22,8 @@ class FullTimeZoneInput < SimpleForm::Inputs::CollectionSelectInput    def detect_collection_methods      label, value = options.delete(:label_method), options.delete(:value_method) -    label ||= ->(tz) do -      tz = ActiveSupport::TimeZone[tz.first] -      "(#{tz.formatted_offset}) #{tz.name}" -    end -    value ||= :first - +    label ||= :first +    value ||= :last      [label, value]    end | 
