Sha256: ce123c5edf43b1113e8f09c50718bdb626b43ceadc6dd4188f39642a775f7d0a

Contents?: true

Size: 709 Bytes

Versions: 12

Compression:

Stored size: 709 Bytes

Contents

require 'tzinfo'

module Coprl
  module Presenters
    module Helpers
      module Time
        LONG_FORMAT='%m/%d/%Y %I:%M:%S %p %Z'
        SHORT_FORMAT='%d %b %H:%M %Z'

        def format_time(time, format: LONG_FORMAT, timezone: nil)
          return '' unless time
          time = time.in_time_zone(timezone) if timezone
          time.strftime(format)
        end

        def format_time_long(time, format: nil, timezone: nil)
          format_time(time, format: format||LONG_FORMAT, timezone: timezone)
        end

        def format_time_short(time, format: nil, timezone: nil)
          format_time(time, format: format||SHORT_FORMAT, timezone: timezone)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
coprl-3.0.0.beta.12 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.11 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.10 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.9 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.8 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.7 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.6 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.5 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.4 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.3 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.2 lib/coprl/presenters/helpers/time.rb
coprl-3.0.0.beta.1 lib/coprl/presenters/helpers/time.rb