Sha256: ef2ff163a34d2e75e809b650e87614f7760cc1e3aeaac61723f7441046398e6f
Contents?: true
Size: 1023 Bytes
Versions: 4
Compression:
Stored size: 1023 Bytes
Contents
require "time" module Lutaml module Model module Type class Time < Value def self.cast(value) return nil if value.nil? case value when ::Time then value when ::DateTime then value.to_time else ::Time.parse(value.to_s) end rescue ArgumentError nil end def self.serialize(value) return nil if value.nil? value = cast(value) # value&.strftime("%Y-%m-%dT%H:%M:%S%:z") value&.iso8601 end # # xs:time format (HH:MM:SS.mmm±HH:MM) # def to_xml # value&.strftime("%H:%M:%S%:z") # end # # ISO8601 time format # def to_json # value&.iso8601 # end # # YAML timestamp format (native) # def to_yaml # value # end # # TOML time format (HH:MM:SS.mmm) # def to_toml # value&.strftime("%H:%M:%S.%L") # end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems