edtf-humanize 2.2.0 → 2.3.1

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: d0bdc76c57a55ce4f9ec22d75d2247609840b769d52662c252d7dc43dc0926ac
4
- data.tar.gz: a4c90eeb17b1e05335498c6aa7bb58b8696fb1238feb5700ba4f6098ab498f97
3
+ metadata.gz: 283504bd85672cde682e30d988fc76de86154a3085d889a9ca99be64a5542ae4
4
+ data.tar.gz: fc780936f1a191c97f4820223f4b20b0d4eff5ef4a0843a70eb0c682037cd674
5
5
  SHA512:
6
- metadata.gz: fee2ccf6b710d1f52e1e842b837052fe9efe8c274ddf2fe33a494462c801b6220dd878269a9befc8b719cad2baa3f46f7ea239923d8ca091b542368bd5c5176b
7
- data.tar.gz: 92f100dd9dd8865c7ee2e42dd711787b05a00adc959287afb394f3ac67a182a9142a4d5f1af43bf0e402eb7047935c7a64425e92501b8d1df3ac88c795842424
6
+ metadata.gz: 05d9fc1bef76ddfb9f4623e8e7358592e57f05e97e2d2bed49c68200e2d75f130acad5c64c66e43062c12b8b8f18fb56e738595b1e5866cae3c8b76cda98ea32
7
+ data.tar.gz: 879caebeedb39a2b2b42aee78784a426d392152bf2de9ea3c732c10ef9cd2582b918130add3b01bd0efd635e673e745f46c5df1402d88e07b7a37298ec1ddbce
@@ -25,7 +25,6 @@ de:
25
25
  interval_prefix_month: ""
26
26
  interval_prefix_year: ""
27
27
  interval_connector_approximate: " - "
28
- interval_connector_open: " - "
29
28
  interval_connector_day: " - "
30
29
  interval_connector_month: " - "
31
30
  interval_connector_year: " - "
@@ -46,8 +45,15 @@ de:
46
45
  set_later_prefix_inclusive: "nach "
47
46
  set_two_dates_connector_exclusive: " oder "
48
47
  set_two_dates_connector_inclusive: " eund "
48
+ uncertain_date_prefix: ""
49
49
  uncertain_date_suffix: " ?"
50
50
  unknown: "Datum unbekannt"
51
+ unknown_start_interval_with_day: "unbekanntes Datum bis %{date}"
52
+ unknown_start_interval_with_month: "unbekanntes Datum bis %{date}"
53
+ unknown_start_interval_with_year: "unbekanntes Datum bis %{date}"
54
+ unknown_end_interval_with_day: "%{date} bis unbekanntes Datum"
55
+ unknown_end_interval_with_month: "%{date} bis unbekanntes Datum"
56
+ unknown_end_interval_with_year: "%{date} bis unbekanntes Datum"
51
57
  unspecified_digit_substitute: "x"
52
58
  formats:
53
59
  day_precision_strftime_format: "%-d. %B %Y"
@@ -15,7 +15,6 @@ en:
15
15
  interval_prefix_year: ""
16
16
  interval_connector_approximate: " to "
17
17
  interval_connector_day: " to "
18
- interval_connector_open: " to "
19
18
  interval_connector_month: " to "
20
19
  interval_connector_year: " to "
21
20
  interval_unspecified_suffix: "s"
@@ -35,8 +34,15 @@ en:
35
34
  set_later_prefix_inclusive: 'on and after '
36
35
  set_two_dates_connector_exclusive: " or "
37
36
  set_two_dates_connector_inclusive: " and "
37
+ uncertain_date_prefix: ""
38
38
  uncertain_date_suffix: "?"
39
39
  unknown: 'unknown'
40
+ unknown_start_interval_with_day: "unknown date to %{date}"
41
+ unknown_start_interval_with_month: "unknown date to %{date}"
42
+ unknown_start_interval_with_year: "unknown date to %{date}"
43
+ unknown_end_interval_with_day: "%{date} to unknown date"
44
+ unknown_end_interval_with_month: "%{date} to unknown date"
45
+ unknown_end_interval_with_year: "%{date} to unknown date"
40
46
  unspecified_digit_substitute: "x"
41
47
  formats:
42
48
  day_precision_strftime_format: "%B %-d, %Y"
@@ -25,7 +25,6 @@ fr:
25
25
  interval_prefix_month: "De "
26
26
  interval_prefix_year: "De "
27
27
  interval_connector_approximate: " à "
28
- interval_connector_open: " à "
29
28
  interval_connector_day: " au "
30
29
  interval_connector_month: " à "
31
30
  interval_connector_year: " à "
@@ -46,8 +45,15 @@ fr:
46
45
  set_later_prefix_inclusive: 'Le et après '
47
46
  set_two_dates_connector_exclusive: " ou "
48
47
  set_two_dates_connector_inclusive: " et "
48
+ uncertain_date_prefix: ""
49
49
  uncertain_date_suffix: "?"
50
50
  unknown: 'Inconnue'
51
+ unknown_start_interval_with_day: "date inconnue au %{date}"
52
+ unknown_start_interval_with_month: "date inconnue jusqu'en %{date}"
53
+ unknown_start_interval_with_year: "date inconnue jusqu'en %{date}"
54
+ unknown_end_interval_with_day: "%{date} à date inconnue"
55
+ unknown_end_interval_with_month: "%{date} à date inconnue"
56
+ unknown_end_interval_with_year: "%{date} à date inconnue"
51
57
  unspecified_digit_substitute: "x"
52
58
  formats:
53
59
  day_precision_strftime_format: "%-d %B %Y"
@@ -25,7 +25,6 @@ it:
25
25
  interval_prefix_month: ""
26
26
  interval_prefix_year: ""
27
27
  interval_connector_approximate: " - "
28
- interval_connector_open: " - "
29
28
  interval_connector_day: " - "
30
29
  interval_connector_month: " - "
31
30
  interval_connector_year: " - "
@@ -46,8 +45,15 @@ it:
46
45
  set_later_prefix_inclusive: "dopo "
47
46
  set_two_dates_connector_exclusive: " o "
48
47
  set_two_dates_connector_inclusive: " e "
48
+ uncertain_date_prefix: ""
49
49
  uncertain_date_suffix: " ?"
50
50
  unknown: "data sconosciuta"
51
+ unknown_start_interval_with_day: "data sconosciuta a %{date}"
52
+ unknown_start_interval_with_month: "data sconosciuta a %{date}"
53
+ unknown_start_interval_with_year: "data sconosciuta a %{date}"
54
+ unknown_end_interval_with_day: "%{date} a data sconosciuta"
55
+ unknown_end_interval_with_month: "%{date} a data sconosciuta"
56
+ unknown_end_interval_with_year: "%{date} a data sconosciuta"
51
57
  unspecified_digit_substitute: "x"
52
58
  formats:
53
59
  day_precision_strftime_format: "%-d %B %Y"
@@ -10,7 +10,7 @@ module Edtf
10
10
  private
11
11
 
12
12
  def date_format(date)
13
- "#{apply_if_unspecified_year(date)}#{apply_if_uncertain(date)}"
13
+ "#{apply_prefix_if_uncertain(date)}#{apply_if_unspecified_year(date)}#{apply_suffix_if_uncertain(date)}"
14
14
  end
15
15
 
16
16
  def date_precision(date)
@@ -85,12 +85,19 @@ module Edtf
85
85
  end
86
86
 
87
87
  # '1990?' => 1990?
88
- def apply_if_uncertain(date)
88
+ def apply_suffix_if_uncertain(date)
89
89
  return '' unless date.respond_to?(:uncertain?) && date.uncertain?
90
90
 
91
91
  I18n.t('edtf.terms.uncertain_date_suffix', default: '?')
92
92
  end
93
93
 
94
+ # '1990?' => ?1990
95
+ def apply_prefix_if_uncertain(date)
96
+ return '' unless date.respond_to?(:uncertain?) && date.uncertain?
97
+
98
+ I18n.t('edtf.terms.uncertain_date_prefix', default: '')
99
+ end
100
+
94
101
  # '198u' => 198x
95
102
  def apply_if_unspecified_year(date)
96
103
  display = date_precision(date)
@@ -12,6 +12,8 @@ module Edtf
12
12
  def humanizer(date)
13
13
  if date.from == :open || date.to == :open
14
14
  open_interval(date)
15
+ elsif date.from == :unknown || date.to == :unknown
16
+ unknown_interval(date)
15
17
  else
16
18
  "#{interval_prefix(date)}" \
17
19
  "#{formatted_date(date.from)}" \
@@ -68,6 +70,52 @@ module Edtf
68
70
  end
69
71
  end
70
72
 
73
+ def unknown_interval(date)
74
+ if date.from == :unknown
75
+ unknown_start_interval(formatted_date: formatted_date(date.to),
76
+ precision: date.to.precision)
77
+ elsif date.to == :unknown
78
+ unknown_end_interval(formatted_date: formatted_date(date.from),
79
+ precision: date.from.precision)
80
+ end
81
+ end
82
+
83
+ # unknown/1980 => unknown year to 1980
84
+ def unknown_start_interval(formatted_date:, precision:)
85
+ case precision
86
+ when :year
87
+ I18n.t('edtf.terms.unknown_start_interval_with_year',
88
+ date: formatted_date,
89
+ default: "unknown date to #{formatted_date}")
90
+ when :month
91
+ I18n.t('edtf.terms.unknown_start_interval_with_month',
92
+ date: formatted_date,
93
+ default: "unknown date to #{formatted_date}")
94
+ when :day
95
+ I18n.t('edtf.terms.unknown_start_interval_with_day',
96
+ date: formatted_date,
97
+ default: "unknown date to #{formatted_date}")
98
+ end
99
+ end
100
+
101
+ # 1980/unknown => 1980 to unknown year
102
+ def unknown_end_interval(formatted_date:, precision:)
103
+ case precision
104
+ when :year
105
+ I18n.t('edtf.terms.unknown_end_interval_with_year',
106
+ date: formatted_date,
107
+ default: "#{formatted_date} to unknown date")
108
+ when :month
109
+ I18n.t('edtf.terms.unknown_end_interval_with_month',
110
+ date: formatted_date,
111
+ default: "#{formatted_date} to unknown date")
112
+ when :day
113
+ I18n.t('edtf.terms.unknown_end_interval_with_day',
114
+ date: formatted_date,
115
+ default: "#{formatted_date} to unknown date")
116
+ end
117
+ end
118
+
71
119
  def formatted_date(date)
72
120
  "#{apply_prefix_if_approximate(date)}" \
73
121
  "#{date_format(date)}" \
@@ -86,8 +134,6 @@ module Edtf
86
134
  end
87
135
 
88
136
  def interval_connector(date)
89
- return interval_connector_open if date.to == :open
90
-
91
137
  return interval_connector_approx if date.to.approximate.day ||
92
138
  date.to.approximate.month ||
93
139
  date.to.approximate.year
@@ -95,10 +141,6 @@ module Edtf
95
141
  interval_connector_other(date)
96
142
  end
97
143
 
98
- def interval_connector_open
99
- I18n.t('edtf.terms.interval_connector_open')
100
- end
101
-
102
144
  def interval_connector_approx
103
145
  I18n.t('edtf.terms.interval_connector_approximate',
104
146
  default: ' to ')
@@ -10,10 +10,11 @@ module Edtf
10
10
  extend self
11
11
 
12
12
  def humanizer(date)
13
- "#{apply_prefix_if_approximate(date)}" \
13
+ "#{apply_prefix_if_uncertain(date)}" \
14
+ "#{apply_prefix_if_approximate(date)}" \
14
15
  "#{translate_season(date.season)} #{date.year}" \
15
16
  "#{apply_suffix_if_approximate(date)}" \
16
- "#{apply_if_uncertain(date)}"
17
+ "#{apply_suffix_if_uncertain(date)}"
17
18
  end
18
19
 
19
20
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Edtf
4
4
  module Humanize
5
- VERSION = '2.2.0'
5
+ VERSION = '2.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edtf-humanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Lown
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-05 00:00:00.000000000 Z
11
+ date: 2026-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -109,16 +109,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '2.4'
112
- - - "<"
113
- - !ruby/object:Gem::Version
114
- version: '4'
115
112
  required_rubygems_version: !ruby/object:Gem::Requirement
116
113
  requirements:
117
114
  - - ">="
118
115
  - !ruby/object:Gem::Version
119
116
  version: '0'
120
117
  requirements: []
121
- rubygems_version: 3.5.6
118
+ rubygems_version: 3.5.9
122
119
  signing_key:
123
120
  specification_version: 4
124
121
  summary: This gem adds a humanize method to EDTF dates.