Sha256: 641edc3118ccdc16b26dce60bdb05b7828da9a20265cd1163b689f3d06383a92

Contents?: true

Size: 685 Bytes

Versions: 7

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

module Dynamoid
  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

7 entries across 7 versions & 1 rubygems

Version Path
dynamoid-3.5.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.4.1 lib/dynamoid/application_time_zone.rb
dynamoid-3.4.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.3.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.2.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.1.0 lib/dynamoid/application_time_zone.rb
dynamoid-3.0.0 lib/dynamoid/application_time_zone.rb