Changeset 776
- Timestamp:
- 02/23/05 23:55:59 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_view/helpers/form_options_helper.rb
r759 r776 186 186 # obtaining a list of the US time zones.) 187 187 # 188 # The +selected+ parameter must be either +nil+, or a string that names 189 # a TimeZone. 190 # 188 191 # By default, +model+ is the TimeZone constant (which can be obtained 189 192 # in ActiveRecord as a value object). The only requirement is that the … … 196 199 zone_options = "" 197 200 201 zones = model.all 202 convert_zones = lambda { |list| list.map { |z| [ z.to_s, z.name ] } } 203 198 204 if priority_zones 199 zone_options += options_for_select( priority_zones, selected)205 zone_options += options_for_select(convert_zones[priority_zones], selected) 200 206 zone_options += "<option>-------------</option>\n" 201 207 202 zones = model.all.reject { |z| priority_zones.include?( z ) } 203 zone_options += options_for_select(zones, selected) 204 else 205 zone_options += options_for_select(model.all, selected) 206 end 207 208 zones = zones.reject { |z| priority_zones.include?( z ) } 209 end 210 211 zone_options += options_for_select(convert_zones[zones], selected) 208 212 zone_options 209 213 end trunk/activesupport/lib/active_support/values/time_zone.rb
r768 r776 38 38 end 39 39 40 # Return the current date in this time zone. 41 def today 42 now.to_date 43 end 44 40 45 # Adjust the given time to the time zone represented by +self+. 41 46 def adjust(time) 47 time = time.to_time 42 48 offset = time.utc_offset 43 49 time + utc_offset - offset