app/controllers/application_controller.rb
# Create a time in a timezone
Create a time in a timezone
Create a time in a timezone
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
Create a time in a timezone
Create a time in a timezone
# 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>