Sha256: 30be6008efc6b83e40fbe64625b0c8125f4f1b0a6c0140adaec12bdab3c6e894
Contents?: true
Size: 966 Bytes
Versions: 4
Compression:
Stored size: 966 Bytes
Contents
require "date" module Lutaml module Model module Type # Date and time representation class DateTime < Value def self.cast(value) return nil if value.nil? case value when ::DateTime then value when ::Time then value.to_datetime else ::DateTime.parse(value.to_s) end rescue ArgumentError nil end def self.serialize(value) return nil if value.nil? cast(value)&.iso8601 end # xs:dateTime format (ISO8601 with timezone) def to_xml value&.iso8601 end # RFC3339 (ISO8601 with timezone) def to_json(*_args) value&.iso8601 end # YAML timestamp format (native) def to_yaml value&.iso8601 end # TOML datetime format (RFC3339) def to_toml value&.iso8601 end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems