edtf-humanize 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/de.edtf.yml +7 -1
- data/config/locales/en.edtf.yml +7 -1
- data/config/locales/fr.edtf.yml +7 -1
- data/config/locales/it.edtf.yml +7 -1
- data/lib/edtf/humanize/language/default/formats.rb +9 -2
- data/lib/edtf/humanize/language/default/interval.rb +48 -6
- data/lib/edtf/humanize/language/default/season.rb +3 -2
- data/lib/edtf/humanize/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d37dd3663889a9bcaa2a00392525eca76c61691705591c6c50f0ee8eacf9d8f
|
4
|
+
data.tar.gz: de92c0782ba2cfa57b62d55a214ede47c8a6fa152cc14b7d38f6bde0c4bfc66b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f4afa9029965ed3a620067218a4594559717f6eeae2ae42c5fe4ba985c6eae9d6be81fd06a150deabf8997c9d5fb10564d4915c0f725c3e0743c636df407cd
|
7
|
+
data.tar.gz: 3180b6b54cc2b9011cfdef70259a4196721cc6894d0eab0258962020b0918e8bcfa2dc8b6744b6ba6f2f90f3f6a065039f214e39075490700597a70a6f3d372d
|
data/config/locales/de.edtf.yml
CHANGED
@@ -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"
|
data/config/locales/en.edtf.yml
CHANGED
@@ -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"
|
data/config/locales/fr.edtf.yml
CHANGED
@@ -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"
|
data/config/locales/it.edtf.yml
CHANGED
@@ -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)}#{
|
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
|
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
|
-
"#{
|
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
|
-
"#{
|
17
|
+
"#{apply_suffix_if_uncertain(date)}"
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
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.
|
4
|
+
version: 2.3.0
|
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-
|
11
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.4.19
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: This gem adds a humanize method to EDTF dates.
|