Sha256: dbb42280b0371a4c57843796df1dc589f100c6a0e8b2c309ed705b47086ed6d7

Contents?: true

Size: 733 Bytes

Versions: 5

Compression:

Stored size: 733 Bytes

Contents

module Storefront
  module TimeHelper
    # (new Date()).getTimezoneOffset() in JavaScript returns (UTC - localtime) in
    # minutes, while ActiveSupport::TimeZone expects (localtime - UTC) in seconds.
    def set_time_zone
      offset       = (cookies[:timezone] || 0).to_i * -60
      # User.time_zone = ActiveSupport::TimeZone[-min.minutes]
      ::User.time_zone = ActiveSupport::TimeZone.us_zones.find { |z| z.utc_offset == offset.to_i }
      true
    end
    
    def record_post_time
      cookies[:last_post_at] = Time.zone.now.to_i
    end
    
    def html5_time(date_or_time)
      return nil if date_or_time.blank?
      date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.rfc3339
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storefront-0.3.2 lib/storefront/helpers/time_helper.rb
storefront-0.3.1 lib/storefront/helpers/time_helper.rb
storefront-0.3.0 lib/storefront/helpers/time_helper.rb
storefront-0.2.8 lib/storefront/helpers/time_helper.rb
storefront-0.2.7 lib/storefront/helpers/time_helper.rb