Sha256: 9554923665207c6e375d5261c46dc237f9561d275f6d98fefa98c455539202cc
Contents?: true
Size: 454 Bytes
Versions: 31
Compression:
Stored size: 454 Bytes
Contents
module Superstore module Types class DateType < BaseType FORMAT = '%Y-%m-%d' REGEX = /\A\d{4}-\d{2}-\d{2}\Z/ def encode(value) raise ArgumentError.new("#{value.inspect} is not a Date") unless value.kind_of?(Date) value.strftime(FORMAT) end def decode(str) return nil if str.empty? Date.parse(str) end def typecast(value) value.to_date end end end end
Version data entries
31 entries across 31 versions & 1 rubygems