Sha256: e6b47a9e4bb11c620f6652621111cf4f4223a80502d7269aa7759e3412141a08

Contents?: true

Size: 576 Bytes

Versions: 5

Compression:

Stored size: 576 Bytes

Contents

# frozen_string_literal: true

require 'date'
require 'time'

module HoneyFormat
  # Convert to date
  ConvertDate = proc do |v|
    begin
      StrictConvertDate.call(v)
    rescue ArgumentError, TypeError
      nil
    end
  end

  # Convert to datetime
  ConvertDatetime = proc do |v|
    begin
      StrictConvertDatetime.call(v)
    rescue ArgumentError, TypeError
      nil
    end
  end

  # Convert to date or raise error
  StrictConvertDate = proc { |v| Date.parse(v) }

  # Convert to datetime or raise error
  StrictConvertDatetime = proc { |v| Time.parse(v) }
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
honey_format-0.21.0 lib/honey_format/converters/convert_date_and_time.rb
honey_format-0.20.0 lib/honey_format/converters/convert_date_and_time.rb
honey_format-0.19.0 lib/honey_format/converters/convert_date_and_time.rb
honey_format-0.18.0 lib/honey_format/converters/convert_date_and_time.rb
honey_format-0.17.0 lib/honey_format/converters/convert_date_and_time.rb