APIdock / Ruby on Rails
/
Browse About
method

use_zone

v4.2.1 - Show latest stable - Class: Time
use_zone(time_zone)
public

Allows override of Time.zone locally inside supplied block; resets Time.zone to existing value when done.

# File activesupport/lib/active_support/core_ext/time/zones.rb, line 44
    def use_zone(time_zone)
      new_zone = find_zone!(time_zone)
      begin
        old_zone, ::Time.zone = ::Time.zone, new_zone
        yield
      ensure
        ::Time.zone = old_zone
      end
    end

Related methods

  • Instance methods
  • +
  • -
  • <=>
  • _dump
  • _dump_without_zone
  • acts_like_time?
  • advance
  • ago
  • all_day
  • as_json
  • at_beginning_of_day
  • at_beginning_of_hour
  • at_beginning_of_minute
  • at_end_of_day
  • at_end_of_hour
  • at_end_of_minute
  • at_midday
  • at_middle_of_day
  • at_midnight
  • at_noon
  • beginning_of_day
  • beginning_of_hour
  • beginning_of_minute
  • change
  • compare_with_coercion
  • compare_without_coercion
  • end_of_day
  • end_of_hour
  • end_of_minute
  • eql?
  • eql_with_coercion
  • eql_without_coercion
  • formatted_offset
  • in
  • midday
  • middle_of_day
  • midnight
  • minus_with_coercion
  • minus_with_duration
  • minus_without_coercion
  • minus_without_duration
  • noon
  • plus_with_duration
  • plus_without_duration
  • seconds_since_midnight
  • seconds_until_end_of_day
  • since
  • to_default_s
  • to_formatted_s
  • to_s
  • Class methods
  • ===
  • _load
  • _load_without_zone
  • at
  • at_with_coercion
  • at_without_coercion
  • current
  • days_in_month
  • find_zone
  • find_zone!
  • use_zone
  • zone
  • zone=
APIdock API Documentation Browser

© 2026 APIdock