Sha256: e42af7d0a8bbfe90720551ea32b84cad3d28091b48012b2a9db9b7c6dcbf7021

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

require_relative 'node_base'

require 'time'

module XML
  module MappingExtensions
    # XML mapping for XML Schema dates.
    # Known limitation: loses time zone info
    class DateNode < NodeBase

      # param xml_text [String] an XML Schema date
      # @return [Date] the value as a `Date`
      def to_value(xml_text)
        Date.xmlschema(xml_text)
      end

      # @param value [Date] the value as a `Date`
      # @return [String] the value as an XML Schema date string, without
      #   time zone information
      def to_xml_text(value)
        value.xmlschema
      end
    end
    ::XML::Mapping.add_node_class DateNode
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xml-mapping_extensions-0.1.0 lib/xml/mapping_extensions/date_node.rb