Sha256: 78d78010fa8da3ce604774893a7e102e9cb0c07e5d2799f270da3f74b6585dbc

Contents?: true

Size: 573 Bytes

Versions: 34

Compression:

Stored size: 573 Bytes

Contents

module Kaui
  module DateHelper

    LOCAL_DATE_RE = /^\d+-\d+-\d+$/

    def format_date(date, timezone="Pacific Time (US & Canada)")

      # Double check this is not null
      return nil if date.nil?

      # If this is a local date we assume this is already in the account timezone, and so there is nothing to do
      return date.to_s if LOCAL_DATE_RE.match(date.to_s)

      # If not, convert into account timezone and return the date part only
      parsed_date = DateTime.parse(date.to_s).in_time_zone(timezone)
      parsed_date.to_s(:date_only)
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
kaui-0.15.0 app/helpers/kaui/date_helper.rb
kaui-0.14.2 app/helpers/kaui/date_helper.rb
kaui-0.14.1 app/helpers/kaui/date_helper.rb
kaui-0.14.0 app/helpers/kaui/date_helper.rb
kaui-0.12.0 app/helpers/kaui/date_helper.rb
kaui-0.11.0 app/helpers/kaui/date_helper.rb
kaui-0.10.0 app/helpers/kaui/date_helper.rb
kaui-0.9.0 app/helpers/kaui/date_helper.rb
kaui-0.8.4 app/helpers/kaui/date_helper.rb
kaui-0.8.3 app/helpers/kaui/date_helper.rb
kaui-0.8.2 app/helpers/kaui/date_helper.rb
kaui-0.8.1 app/helpers/kaui/date_helper.rb
kaui-0.8.0 app/helpers/kaui/date_helper.rb
kaui-0.7.2 app/helpers/kaui/date_helper.rb
kaui-0.7.1 app/helpers/kaui/date_helper.rb
kaui-0.7.0 app/helpers/kaui/date_helper.rb
kaui-0.6.6 app/helpers/kaui/date_helper.rb
kaui-0.6.5 app/helpers/kaui/date_helper.rb
kaui-0.6.4 app/helpers/kaui/date_helper.rb
kaui-0.6.3 app/helpers/kaui/date_helper.rb