Sha256: 9751bdcd5c0c4971bacc5e4b7781eb583e07e4741ee6f55a58d7a54cef7db085

Contents?: true

Size: 868 Bytes

Versions: 3

Compression:

Stored size: 868 Bytes

Contents

unless defined?(Date)
  begin
    require 'date'
  rescue LoadError
  end
end

require 'third_base'

TimeCrisis = ThirdBase.dup

# add needed bits of active support to time crisis
# necessary now that it uses ThirdBase
require 'time_crisis/support'

require 'time_crisis/meteorological_seasons'
require 'time_crisis/date_range'
require 'time_crisis/named_months'
require 'time_crisis/weekend'
require 'time_crisis/nth_weekday'
require 'time_crisis/holiday'

# TODO: make this less of an ugly hack
module TimeCrisis
  class DateTime
    ENVMUTEX = Mutex.new
    def for_zone(time_zone)
      ENVMUTEX.synchronize do
        original_zone = ENV['TZ']
        begin
          utc_time = self.to_time.utc
          ENV['TZ'] = time_zone
          utc_time.localtime.to_tc_datetime
        ensure
          ENV['TZ'] = original_zone
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
time_crisis-0.1.8 lib/time_crisis.rb
time_crisis-0.1.7 lib/time_crisis.rb
time_crisis-0.1.6 lib/time_crisis.rb