diff options
| author | Zog | 2018-05-03 11:13:51 +0200 | 
|---|---|---|
| committer | cedricnjanga | 2018-05-03 16:06:35 -0700 | 
| commit | 69b680aa5e50ae5761c4b87f9e2cf6d408d5e7ca (patch) | |
| tree | 26367d6eee0d39a51352507e5797179656405b17 /app/inputs | |
| parent | d768698125f45ac35278c015e5cca99e0861b0d7 (diff) | |
| download | chouette-core-69b680aa5e50ae5761c4b87f9e2cf6d408d5e7ca.tar.bz2 | |
Refs #6867; Add A LOT of TZs
Diffstat (limited to 'app/inputs')
| -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 | 
