Sha256: 6321d08a3907d30fd126e2c6f4df6594bd8b163aa7a8d7ec3b1699f86cb4a35d
Contents?: true
Size: 576 Bytes
Versions: 3
Compression:
Stored size: 576 Bytes
Contents
# frozen_string_literal: true require 'date' using SmartCore::Ext::BasicObjectAsObject # @api public # @since 0.1.0 # @version 0.7.0 SmartCore::Types::Value.define_type(:DateTime) do |type| type.define_checker do |value| value.is_a?(::DateTime) || value == ::DateTime::Infinity end type.define_caster do |value| next value if value.is_a?(::DateTime) || value == ::DateTime::Infinity begin ::DateTime.parse(value) rescue ::ArgumentError, ::TypeError raise(SmartCore::Types::TypeCastingError, 'Non-castable to DateTime') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
smart_types-0.8.0 | lib/smart_core/types/value/date_time.rb |
smart_types-0.7.1 | lib/smart_core/types/value/date_time.rb |
smart_types-0.7.0 | lib/smart_core/types/value/date_time.rb |