Class: MrCommon::Timezone

Inherits:
Object
  • Object
show all
Defined in:
app/models/mr_common/timezone.rb

Overview

Helper class for building time zone select options. Pares down the list by grouping locations that share ones or offsets.

Class Method Summary collapse

Class Method Details

.time_zone_optionsArray<String>

Returns list of time zone names ordered by offset.

Returns:

  • (Array<String>)

    list of time zone names ordered by offset



9
10
11
# File 'app/models/mr_common/timezone.rb', line 9

def time_zone_options
  filtered_time_zones.collect(&:name)
end

.time_zone_select_optionsArray<Array<String, String>>

Returns list of label value pairs for building time zone select options ordered by offset.

Returns:

  • (Array<Array<String, String>>)

    list of label value pairs for building time zone select options ordered by offset.



15
16
17
18
19
# File 'app/models/mr_common/timezone.rb', line 15

def time_zone_select_options
  filtered_time_zones.collect do |tz|
    ["(UTC#{tz_utc_offset(tz)}) #{tz_friendly_name(tz)}", tz.name]
  end
end