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 +4 -4
- data/lib/isodoc/extended_date.rb +24 -0
- data/lib/isodoc/i18n/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5323ffdd11fbc3590df89e847850d94952dd14dbedc9a3890f816452c74e5bad
|
|
4
|
+
data.tar.gz: 8de0b46ebe7acfd0e5d63835462f01c672ac6f1a915926b98395ad47b5801a81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a0c53b89c58f7d898955ed3ad725c5d38d10452787436b52e25a8dca493e6bc33aff19087ce0470098cdffaf52c71df7fdbb5c1eaea488eb96ff576987e470e
|
|
7
|
+
data.tar.gz: 27536a6ebf32c1dafca0da5db856c3215bad6a3a81b1314205a83337290c04bdbca13f75f3d27232085817913152af59072c88a4dfd1fc7a4cd503858d1078c2
|
data/lib/isodoc/extended_date.rb
CHANGED
|
@@ -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)
|
data/lib/isodoc/i18n/version.rb
CHANGED
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.
|
|
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
|
+
date: 2026-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|