Sha256: bb8b0ffdbab10f55f0054fd79779825eed9ae6804d2b818a94f338dc24a27129

Contents?: true

Size: 698 Bytes

Versions: 6

Compression:

Stored size: 698 Bytes

Contents

# frozen_string_literal: true

module Dynamoid
  # @private
  module ApplicationTimeZone
    def self.at(value)
      case Dynamoid::Config.application_timezone
      when :utc
        ActiveSupport::TimeZone['UTC'].at(value).to_datetime
      when :local
        Time.at(value).to_datetime
      when String
        ActiveSupport::TimeZone[Dynamoid::Config.application_timezone].at(value).to_datetime
      end
    end

    def self.utc_offset
      case Dynamoid::Config.application_timezone
      when :utc
        0
      when :local
        Time.now.utc_offset
      when String
        ActiveSupport::TimeZone[Dynamoid::Config.application_timezone].now.utc_offset
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dynamoid-3.10.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.9.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.8.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.7.1 lib/dynamoid/application_time_zone.rb
dynamoid-3.7.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.6.0 lib/dynamoid/application_time_zone.rb