Skip to content

Commit

Permalink
[requif/issues lutaml#3] Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
henb committed Dec 9, 2024
1 parent 9b0fa52 commit 04077c5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/reqif/high_precision_date_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

module Reqif
class HighPrecisionDateTime < Lutaml::Model::Type::DateTime
def self.serialize(value)
return nil if value.nil?

# The format looks like this `2012-04-07T01:51:37.112+02:00`
def self.from_xml(xml_string)
::DateTime.parse(xml_string)
cast(value)&.iso8601(8)
end

def to_json
value.to_time.iso8601(8)
end

# The %L adds milliseconds to the time
def to_xml
value.strftime("%Y-%m-%dT%H:%M:%S.%L99999%:z")
value.to_time.iso8601(8)
end
end
end

0 comments on commit 04077c5

Please sign in to comment.