Sha256: 438b383b7e466b141cf697d1b826602e273204d0ae36de5dcd64edf72faa1e93
Contents?: true
Size: 687 Bytes
Versions: 1
Compression:
Stored size: 687 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) date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.rfc3339 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
storefront-0.2.0 | lib/storefront/helpers/time_helper.rb |