Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[requif/issues #3] Fix specs #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[requif/issues #3] Fix specs #5

wants to merge 1 commit into from

Conversation

henb
Copy link

@henb henb commented Dec 9, 2024

MOTIVATION

I don't want to see the bad spec.

Reason

I want the date and time to match with milliseconds when parsing.

Description

Issue #3

Result

for tests you can use the code:

require 'lutaml/model'

Lutaml::Model::Config.configure do |config|
  require 'lutaml/model/xml_adapter/nokogiri_adapter'
  config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
end

class Kiln < Lutaml::Model::Serializable
  attribute :time1, :date_time
  attribute :time2, :time
  attribute :time3, Reqif::HighPrecisionDateTime
end

a = Kiln.new(time1: Time.now, time2: Time.now, time3: Time.now)
b = Kiln.from_json(a.to_json)
c = Kiln.from_xml(a.to_xml)

puts "FOR JSON"
puts "date_time #{a.time1 == b.time1}"
puts "time #{a.time2 == b.time2}"
puts "HighPrecisionDateTime #{a.time3 == b.time3}"
 
puts "FOR XML"
puts "date_time #{a.time1 == c.time1}"
puts "time #{a.time2 == c.time2}"
puts "HighPrecisionDateTime #{a.time3 == c.time3}"

Output

FOR JSON
date_time false
time false
HighPrecisionDateTime true

FOR XML
date_time false
time false
HighPrecisionDateTime true

Before

2014-07-09T10:19:00.12345678-04:00
2014-07-09T10:19:00-04:00

After

2014-07-09T10:19:00.12345678-04:00
2014-07-09T10:19:00.12345678-04:00

Changes

  • Fixed Reqif::HighPrecisionDateTime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant