app/controllers/mixins/time_helper.rb
# tz = nil means use user's session timzone
tz = nil means use user's session timzone
tz = nil means use user ' s session timzone
def create_time_in_tz(datetime, tz = nil)
      if tz && (Time.zone.nil? || tz != Time.zone.name)     
        saved_tz = Time.zone
        Time.zone = tz                                      
        t = Time.zone.parse(datetime)                       
        Time.zone = saved_tz                                
      else                                                  
        t = Time.zone.parse(datetime)                       
      end
      t
    end
def create_time_in_tz ( datetime , tz = nil ) if tz && ( Time . zone . nil? || tz != Time . zone . name ) saved_tz = Time . zone Time . zone = tz t = Time . zone . parse ( datetime ) Time . zone = saved_tz else t = Time . zone . parse ( datetime ) end t end
tz = nil means use user's session timzone
tz = nil means use user ' s session timzone
# If tz passed in and not default tz # Temporarily convert to new tz and create the time object # Create the time object # Restore original default # tz not passed in or matches current tz # Create the time object
datetime
<not_specific>
tz
<not_specific>