class Lutaml::Model::Type::DateTime

Date and time representation

def self.cast(value)

def self.cast(value)
  return value if value.nil? || Utils.uninitialized?(value)
  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)

def self.serialize(value)
  return value if value.nil? || Utils.uninitialized?(value)
  cast(value)&.iso8601
end

def to_json(*_args)

RFC3339 (ISO8601 with timezone)
def to_json(*_args)
  value&.iso8601
end

def to_toml

TOML datetime format (RFC3339)
def to_toml
  value&.iso8601
end

def to_xml

xs:dateTime format (ISO8601 with timezone)
def to_xml
  value&.iso8601
end

def to_yaml

YAML timestamp format (native)
def to_yaml
  value&.iso8601
end