Sha256: 49ce9a0053d51abfd596aad7155e80572b544577a8872e5ce5ce0c3493b87d75

Contents?: true

Size: 400 Bytes

Versions: 19

Compression:

Stored size: 400 Bytes

Contents

module Decanter
  module Parser
    class DateTimeParser < ValueParser

      allow DateTime

      parser do |val, options|
        raise Decanter::ParseError.new 'Expects a single value' if val.is_a? Array
        next if (val.nil? || val === '')
        parse_format = options.fetch(:parse_format, '%m/%d/%Y %I:%M:%S %p')
        ::DateTime.strptime(val, parse_format)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decanter-4.0.4 lib/decanter/parser/datetime_parser.rb
decanter-4.0.3 lib/decanter/parser/datetime_parser.rb
decanter-4.0.2 lib/decanter/parser/datetime_parser.rb
decanter-4.0.1 lib/decanter/parser/datetime_parser.rb
decanter-4.0.0 lib/decanter/parser/datetime_parser.rb
decanter-3.6.0 lib/decanter/parser/datetime_parser.rb
decanter-3.5.1 lib/decanter/parser/datetime_parser.rb
decanter-3.5.0 lib/decanter/parser/datetime_parser.rb
decanter-3.4.2 lib/decanter/parser/datetime_parser.rb
decanter-3.4.1 lib/decanter/parser/datetime_parser.rb
decanter-3.4.0 lib/decanter/parser/datetime_parser.rb
decanter-3.3.0 lib/decanter/parser/datetime_parser.rb
decanter-3.2.1 lib/decanter/parser/datetime_parser.rb
decanter-3.2.0 lib/decanter/parser/datetime_parser.rb
decanter-3.1.2 lib/decanter/parser/datetime_parser.rb
decanter-3.1.1 lib/decanter/parser/datetime_parser.rb
decanter-3.1.0 lib/decanter/parser/datetime_parser.rb
decanter-3.0.1 lib/decanter/parser/datetime_parser.rb
decanter-3.0.0 lib/decanter/parser/datetime_parser.rb