relaton 3.1.16 → 3.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b7286c99d15f19823983e5965873648750e480124f4d72e97a58ca511bd2068
4
- data.tar.gz: dc9148ea2bc0c47f14828183bb6c11b7fc8c4a44fc664e005d4ae6683a364a6d
3
+ metadata.gz: 113616dfa3ea3bd048a0da27ab3400b267d4ba8f999761197a0f2c5032da109d
4
+ data.tar.gz: 428640dc9817a710305298130a02584ba779ec60fe3bce940e1ab78f648244d2
5
5
  SHA512:
6
- metadata.gz: e84b0544a255c1dd857aaaf1a10632b9fbaa1d2e15e5d7c44dbaf0d696f96320c0b00356d9cc823f2579dbb2d82a8331eaba4262e0346d52b06ad2333b18a264
7
- data.tar.gz: f240a5bf6b24a6679cd9407634e2590b6717fc5e42a2675214fb1631785f464b7b3e18976f4f20f65bf2436eeb64e836037866c5759cc8866a19305006413f1c
6
+ metadata.gz: 4217909b731782960e1f893172578e94c3ff483589d9800c0f4bc7fc9bb0420cf295c8d8c8a14464162d9bf09b36425e6ef4b570e39430b91b6f9244273a388a
7
+ data.tar.gz: 809b0d30b4d929a1dd336c7e43e00592b8b986648aca898f03a3dca53afdc514a068ec58f3076f24fb3de4c23f17576e8f9e1ea626e045c59a8231742c56ed5c
@@ -616,13 +616,21 @@ module Relaton
616
616
  p = period == :ends ? -1 : 1
617
617
  case t
618
618
  when /^\d{4}$/
619
- ::Date.new(t.to_i, p, p).to_datetime.to_time.utc
619
+ # Year and year-month inputs are date-only: keep ::Date
620
+ # precision (PlainDate serializes them as xs:date).
621
+ ::Date.new(t.to_i, p, p)
620
622
  when /^(?<year>\d{4})-(?<month>\d{1,2})$/
621
- ::Date.new($~[:year].to_i, $~[:month].to_i, p).to_datetime.to_time.utc
623
+ ::Date.new($~[:year].to_i, $~[:month].to_i, p)
622
624
  else
623
- # Default to UTC when no timezone is specified
624
- t += " UTC" unless t.match?(/[+-]\d{2}:?\d{2}\s*$|Z\s*$/i)
625
- ::Time.parse t
625
+ # Date-only strings stay ::Date (PlainDate keeps xs:date
626
+ # precision); strings with a time promote to ::Time/DateTime.
627
+ if t.match?(/\A\d{4}-\d{2}-\d{2}\s*(UTC|UTC\+00:00)?\s*$/i)
628
+ ::Date.parse t
629
+ else
630
+ # Default to UTC when no timezone is specified
631
+ t += " UTC" unless t.match?(/[+-]\d{2}:?\d{2}\s*$|Z\s*$/i)
632
+ ::Time.parse t
633
+ end
626
634
  end
627
635
  end
628
636
 
@@ -14,6 +14,9 @@ module Relaton
14
14
  # String with a time component: parse as ::DateTime, keeping
15
15
  # offset and precision (lutaml's Date cast truncates these).
16
16
  return ::DateTime.parse(value) if value.is_a?(String) && value =~ /T\d{2}:\d{2}/
17
+ # ::Time objects (the hash parser's validity output) carry full
18
+ # precision: promote to ::DateTime instead of truncating.
19
+ return value.to_datetime if value.is_a?(::Time)
17
20
  # ::DateTime objects already carry the caller's precision.
18
21
  return value if value.is_a?(::DateTime)
19
22
  # A string without a time component ("2018-04-15+05:30") is
@@ -35,3 +38,16 @@ module Relaton
35
38
  end
36
39
  end
37
40
  end
41
+
42
+ # lutaml's format-serializer table resolves Date-typed attributes by
43
+ # walking the class hierarchy to the BASE Type::Date entry, whose static
44
+ # serialize truncates ::DateTime to "YYYY-MM-DDZ" — a subclass's serialize
45
+ # override is never consulted. Register this subclass explicitly so
46
+ # Validity#to_xml honors the precision-preserving serialization above
47
+ # (relaton#636).
48
+ if defined?(Lutaml::Xml::Type::Serializers)
49
+ Lutaml::Model::Type::Value.register_format_type_serializer(
50
+ :xml, Relaton::Bib::PlainDate,
51
+ to: ->(inst) { Relaton::Bib::PlainDate.serialize(inst.value) }
52
+ )
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "3.1.16".freeze
2
+ VERSION = "3.1.18".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.16
4
+ version: 3.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-28 00:00:00.000000000 Z
11
+ date: 2026-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable