Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 776

Show
Ignore:
Timestamp:
02/23/05 23:55:59 (4 years ago)
Author:
david
Message:

Fixed TimeZone issues in action-pack and active-support #704

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_view/helpers/form_options_helper.rb

    r759 r776  
    186186      # obtaining a list of the US time zones.) 
    187187      # 
     188      # The +selected+ parameter must be either +nil+, or a string that names 
     189      # a TimeZone. 
     190      # 
    188191      # By default, +model+ is the TimeZone constant (which can be obtained 
    189192      # in ActiveRecord as a value object). The only requirement is that the 
     
    196199        zone_options = "" 
    197200 
     201        zones = model.all 
     202        convert_zones = lambda { |list| list.map { |z| [ z.to_s, z.name ] } } 
     203 
    198204        if priority_zones 
    199           zone_options += options_for_select(priority_zones, selected) 
     205          zone_options += options_for_select(convert_zones[priority_zones], selected) 
    200206          zone_options += "<option>-------------</option>\n" 
    201207 
    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) 
    208212        zone_options 
    209213      end 
  • trunk/activesupport/lib/active_support/values/time_zone.rb

    r768 r776  
    3838  end 
    3939 
     40  # Return the current date in this time zone. 
     41  def today 
     42    now.to_date 
     43  end 
     44 
    4045  # Adjust the given time to the time zone represented by +self+. 
    4146  def adjust(time) 
     47    time = time.to_time 
    4248    offset = time.utc_offset 
    4349    time + utc_offset - offset