isodoc-i18n 1.5.1 → 1.5.2

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: 95f917d7a4996d6dc8305abccafe651027a54240675c991901b9bd918d7d812c
4
- data.tar.gz: 15b31e27d8b80f12dcbbbab05f191f8f7f04abd4d894f34dc05f3ca91fa47c18
3
+ metadata.gz: 5323ffdd11fbc3590df89e847850d94952dd14dbedc9a3890f816452c74e5bad
4
+ data.tar.gz: 8de0b46ebe7acfd0e5d63835462f01c672ac6f1a915926b98395ad47b5801a81
5
5
  SHA512:
6
- metadata.gz: cdd88aa05e6d1fe3021312fe38b0b47dec6343ceb12ff8c56cc920e43aeceb6d9bd58ada246f61fd1f9efa7da0be9df87f51ee25086090ff9eae7cd7ded3ec92
7
- data.tar.gz: 8a73521429748c13f56c570ddef968974606c69b8ba40be61b456c7ae57dfdd50ea046939784590544ae6a70e6c60757b51d90188bcf5c9b657f48556e01692a
6
+ metadata.gz: 9a0c53b89c58f7d898955ed3ad725c5d38d10452787436b52e25a8dca493e6bc33aff19087ce0470098cdffaf52c71df7fdbb5c1eaea488eb96ff576987e470e
7
+ data.tar.gz: 27536a6ebf32c1dafca0da5db856c3215bad6a3a81b1314205a83337290c04bdbca13f75f3d27232085817913152af59072c88a4dfd1fc7a4cd503858d1078c2
@@ -44,6 +44,30 @@ module IsoDoc
44
44
  new(**opts).format(value, fmt)
45
45
  end
46
46
 
47
+ # Convenience wrapper for ISO 8601 date strings of variable arity
48
+ # (year-only, year-month, or full date). Picks one of three format
49
+ # strings keyed by the arity of the input. Each format string may be
50
+ # nil, in which case the input is returned unchanged for that arity.
51
+ # Used by metanorma-flavour metadata helpers to delegate their
52
+ # arity-branching logic instead of duplicating it per gem.
53
+ def self.format_iso_date(isodate, year: nil, year_month: nil, full: nil,
54
+ **opts)
55
+ normalized, fmt = iso_normalize(isodate, [year, year_month, full])
56
+ return isodate if fmt.nil?
57
+
58
+ format(normalized, fmt, **opts)
59
+ rescue StandardError
60
+ isodate
61
+ end
62
+
63
+ def self.iso_normalize(isodate, fmts)
64
+ return [isodate, nil] if isodate.nil? || isodate.to_s.empty?
65
+
66
+ parts = isodate.to_s.split("-")
67
+ fmt = fmts[parts.size - 1] or return [isodate, nil]
68
+ [[parts[0], parts[1] || "01", parts[2] || "01"].join("-"), fmt]
69
+ end
70
+
47
71
  attr_reader :lang, :script
48
72
 
49
73
  def initialize(lang:, script: nil, calendar: nil, calendar_en: nil)
@@ -1,5 +1,5 @@
1
1
  module IsoDoc
2
2
  class I18n
3
- VERSION = "1.5.1".freeze
3
+ VERSION = "1.5.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
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-05-11 00:00:00.000000000 Z
11
+ date: 2026-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64