edtf-humanize 0.0.5 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/config/locales/en.edtf.yml +44 -0
  3. data/config/locales/fr.edtf.yml +55 -0
  4. data/config/locales/it.edtf.yml +55 -0
  5. data/lib/edtf-humanize.rb +5 -0
  6. data/lib/edtf/humanize.rb +24 -41
  7. data/lib/edtf/humanize/century.rb +4 -4
  8. data/lib/edtf/humanize/decade.rb +4 -4
  9. data/lib/edtf/humanize/interval.rb +4 -17
  10. data/lib/edtf/humanize/iso_date.rb +4 -4
  11. data/lib/edtf/humanize/language.rb +13 -0
  12. data/lib/edtf/humanize/language/default.rb +17 -0
  13. data/lib/edtf/humanize/language/default/century.rb +20 -0
  14. data/lib/edtf/humanize/language/default/decade.rb +21 -0
  15. data/lib/edtf/humanize/language/default/formats.rb +114 -0
  16. data/lib/edtf/humanize/language/default/interval.rb +132 -0
  17. data/lib/edtf/humanize/language/default/iso_date.rb +21 -0
  18. data/lib/edtf/humanize/language/default/season.rb +30 -0
  19. data/lib/edtf/humanize/language/default/set.rb +78 -0
  20. data/lib/edtf/humanize/language/default/unknown.rb +17 -0
  21. data/lib/edtf/humanize/language/english.rb +11 -0
  22. data/lib/edtf/humanize/language/french.rb +36 -0
  23. data/lib/edtf/humanize/language/italian.rb +34 -0
  24. data/lib/edtf/humanize/season.rb +4 -4
  25. data/lib/edtf/humanize/set.rb +4 -12
  26. data/lib/edtf/humanize/unknown.rb +5 -3
  27. data/lib/edtf/humanize/version.rb +3 -1
  28. data/spec/edtf_humanize_en_spec.rb +102 -0
  29. data/spec/edtf_humanize_fr_spec.rb +110 -0
  30. data/spec/edtf_humanize_it_spec.rb +110 -0
  31. data/spec/spec_helper.rb +103 -0
  32. metadata +92 -112
  33. data/Rakefile +0 -34
  34. data/lib/edtf/humanize/formats.rb +0 -73
  35. data/lib/tasks/edtf_humanize_tasks.rake +0 -4
  36. data/test/dummy/README.rdoc +0 -28
  37. data/test/dummy/Rakefile +0 -6
  38. data/test/dummy/app/assets/javascripts/application.js +0 -13
  39. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  40. data/test/dummy/app/controllers/application_controller.rb +0 -5
  41. data/test/dummy/app/helpers/application_helper.rb +0 -2
  42. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  43. data/test/dummy/bin/bundle +0 -3
  44. data/test/dummy/bin/rails +0 -4
  45. data/test/dummy/bin/rake +0 -4
  46. data/test/dummy/bin/setup +0 -29
  47. data/test/dummy/config.ru +0 -4
  48. data/test/dummy/config/application.rb +0 -26
  49. data/test/dummy/config/boot.rb +0 -5
  50. data/test/dummy/config/database.yml +0 -25
  51. data/test/dummy/config/environment.rb +0 -5
  52. data/test/dummy/config/environments/development.rb +0 -41
  53. data/test/dummy/config/environments/production.rb +0 -79
  54. data/test/dummy/config/environments/test.rb +0 -42
  55. data/test/dummy/config/initializers/assets.rb +0 -11
  56. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  57. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  58. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  59. data/test/dummy/config/initializers/inflections.rb +0 -16
  60. data/test/dummy/config/initializers/mime_types.rb +0 -4
  61. data/test/dummy/config/initializers/session_store.rb +0 -3
  62. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  63. data/test/dummy/config/locales/en.yml +0 -23
  64. data/test/dummy/config/routes.rb +0 -56
  65. data/test/dummy/config/secrets.yml +0 -22
  66. data/test/dummy/db/test.sqlite3 +0 -0
  67. data/test/dummy/log/test.log +0 -865
  68. data/test/dummy/public/404.html +0 -67
  69. data/test/dummy/public/422.html +0 -67
  70. data/test/dummy/public/500.html +0 -66
  71. data/test/dummy/public/favicon.ico +0 -0
  72. data/test/edtf_humanize_test.rb +0 -78
  73. data/test/test_helper.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ca4afd67f78503900311e3cd852ae9ee59a94710
4
- data.tar.gz: f3440398bac5c838fdce163fd66bad1f68ed0443
2
+ SHA256:
3
+ metadata.gz: cc48511e90b2d4e45ff0be51e918e017d62d416e30e20c170a4fc5665995d47e
4
+ data.tar.gz: eabab9819e11f79c8b99e510e8136f8458724e4314b8e0dd8cc5fdf1932f86e2
5
5
  SHA512:
6
- metadata.gz: 1e5fac118d56ffc03fca59f928149ec04c1a0ceb56600860b2aa171333b075c17d6b54ef7375c33eb929489340071c8b5e9b66e517d44e9a1ffb5cfd398e4e68
7
- data.tar.gz: 8102964632e73d8d389e4e14f0634f9598f5d7b453dcea957c89f04b80562d23e0b4b1250bf2e8d9c5a23e9a76c39b641be98b379a46540c271b54b6384067c0
6
+ metadata.gz: 31eeb4f4ca204efdfa7b323b48968eb1e9a4f50511a1e811a0e171657459b7b6f531d70020befdfd266b7bede99ae326313b5bb38305f1b864e7aaabcc40638a
7
+ data.tar.gz: 1fac59abdcc0142f3ff2f7ff210dc3b2acfa8f5171c4614710791d7540ecd924469dd11743818a31615ee4ec9687b723e80970d055eb1a99bfc73207d901cc78
@@ -0,0 +1,44 @@
1
+ en:
2
+ edtf:
3
+ terms:
4
+ approximate_date_prefix_day: "circa "
5
+ approximate_date_prefix_month: "circa "
6
+ approximate_date_prefix_year: "circa "
7
+ approximate_date_suffix_day: ""
8
+ approximate_date_suffix_month: ""
9
+ approximate_date_suffix_year: ""
10
+ century_suffix: "s"
11
+ decade_prefix: ""
12
+ decade_suffix: "s"
13
+ interval_prefix_day: ""
14
+ interval_prefix_month: ""
15
+ interval_prefix_year: ""
16
+ interval_connector_approximate: " to "
17
+ interval_connector_day: " to "
18
+ interval_connector_open: " to "
19
+ interval_connector_month: " to "
20
+ interval_connector_year: " to "
21
+ interval_unspecified_suffix: "s"
22
+ open_start_interval_with_day: "until %{date}"
23
+ open_start_interval_with_month: "until %{date}"
24
+ open_start_interval_with_year: "until %{date}"
25
+ open_end_interval_with_day: "since %{date}"
26
+ open_end_interval_with_month: "since %{date}"
27
+ open_end_interval_with_year: "since %{date}"
28
+ set_dates_connector_exclusive: ", "
29
+ set_dates_connector_inclusive: ", "
30
+ set_earlier_prefix_exclusive: 'on or before '
31
+ set_earlier_prefix_inclusive: 'on and before '
32
+ set_last_date_connector_exclusive: " or "
33
+ set_last_date_connector_inclusive: " and "
34
+ set_later_prefix_exclusive: 'on or after '
35
+ set_later_prefix_inclusive: 'on and after '
36
+ set_two_dates_connector_exclusive: " or "
37
+ set_two_dates_connector_inclusive: " and "
38
+ uncertain_date_suffix: "?"
39
+ unknown: 'unknown'
40
+ unspecified_digit_substitute: "x"
41
+ formats:
42
+ day_precision_strftime_format: "%B %-d, %Y"
43
+ month_precision_strftime_format: "%B %Y"
44
+ year_precision_strftime_format: "%Y"
@@ -0,0 +1,55 @@
1
+ fr:
2
+ date:
3
+ day_names: [Dimanche, Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi]
4
+ abbr_day_names: [Dim, Lun, Mar, Mer, Jeu, Ven, Sam]
5
+ # Don't forget the nil at the beginning; there's no such thing as a 0th month
6
+ month_names: [~, Janvier, Février, Mars, Avril, Mai, Juin, Juillet, Août, Septembre, Octobre, Novembre, Decembre]
7
+ abbr_month_names: [~, Jan, Fev, Mar, Avr, Mai, Jun, Jul, Aou, Sep, Oct, Nov, Dec]
8
+ seasons:
9
+ spring: "printemps"
10
+ summer: "été"
11
+ autumn: "automne"
12
+ winter: "hiver"
13
+ edtf:
14
+ terms:
15
+ approximate_date_prefix_day: ""
16
+ approximate_date_prefix_month: ""
17
+ approximate_date_prefix_year: ""
18
+ approximate_date_suffix_day: " environ"
19
+ approximate_date_suffix_month: " environ"
20
+ approximate_date_suffix_year: " environ"
21
+ decade_prefix: "Les années "
22
+ decade_suffix: ""
23
+ century_suffix: ""
24
+ interval_prefix_day: "Du "
25
+ interval_prefix_month: "De "
26
+ interval_prefix_year: "De "
27
+ interval_connector_approximate: " à "
28
+ interval_connector_open: " à "
29
+ interval_connector_day: " au "
30
+ interval_connector_month: " à "
31
+ interval_connector_year: " à "
32
+ interval_unspecified_suffix: "s"
33
+ open_start_interval_with_day: "Jusqu'au %{date}"
34
+ open_start_interval_with_month: "Jusqu'en %{date}"
35
+ open_start_interval_with_year: "Jusqu'en %{date}"
36
+ open_end_interval_with_day: "Depuis le %{date}"
37
+ open_end_interval_with_month: "Depuis %{date}"
38
+ open_end_interval_with_year: "Depuis %{date}"
39
+ set_dates_connector_exclusive: ", "
40
+ set_dates_connector_inclusive: ", "
41
+ set_earlier_prefix_exclusive: 'Le ou avant '
42
+ set_earlier_prefix_inclusive: 'Le et avant '
43
+ set_last_date_connector_exclusive: " ou "
44
+ set_last_date_connector_inclusive: " et "
45
+ set_later_prefix_exclusive: 'Le ou après '
46
+ set_later_prefix_inclusive: 'Le et après '
47
+ set_two_dates_connector_exclusive: " ou "
48
+ set_two_dates_connector_inclusive: " et "
49
+ uncertain_date_suffix: "?"
50
+ unknown: 'Inconnue'
51
+ unspecified_digit_substitute: "x"
52
+ formats:
53
+ day_precision_strftime_format: "%-d %B %Y"
54
+ month_precision_strftime_format: "%B %Y"
55
+ year_precision_strftime_format: "%Y"
@@ -0,0 +1,55 @@
1
+ it:
2
+ date:
3
+ day_names: [domenica, lunedì, martedì, mercoledì, giovedì, venerdì, sabato]
4
+ abbr_day_names: [dom, lun, mar, mer, gio, ven, sab]
5
+ # Don't forget the nil at the beginning; there's no such thing as a 0th month
6
+ month_names: [~, gennaio, febbraio, marzo, aprile, maggio, giugno, luglio, agosto, settembre, ottobre, novembre, dicembre]
7
+ abbr_month_names: [~, gen, feb, mar, apr, mag, giu, lug, ago, set, ott, nov, dic]
8
+ seasons:
9
+ spring: "primavera"
10
+ summer: "estate"
11
+ autumn: "autunno"
12
+ winter: "inverno"
13
+ edtf:
14
+ terms:
15
+ approximate_date_prefix_day: "circa "
16
+ approximate_date_prefix_month: "circa "
17
+ approximate_date_prefix_year: "circa "
18
+ approximate_date_suffix_day: ""
19
+ approximate_date_suffix_month: ""
20
+ approximate_date_suffix_year: ""
21
+ decade_prefix: "anni "
22
+ decade_suffix: ""
23
+ century_suffix: ""
24
+ interval_prefix_day: ""
25
+ interval_prefix_month: ""
26
+ interval_prefix_year: ""
27
+ interval_connector_approximate: " - "
28
+ interval_connector_open: " - "
29
+ interval_connector_day: " - "
30
+ interval_connector_month: " - "
31
+ interval_connector_year: " - "
32
+ interval_unspecified_suffix: ""
33
+ open_start_interval_with_day: "fino a %{date}"
34
+ open_start_interval_with_month: "fino a %{date}"
35
+ open_start_interval_with_year: "fino a %{date}"
36
+ open_end_interval_with_day: "%{date} - "
37
+ open_end_interval_with_month: "%{date} - "
38
+ open_end_interval_with_year: "%{date} - "
39
+ set_dates_connector_exclusive: ", "
40
+ set_dates_connector_inclusive: ", "
41
+ set_earlier_prefix_exclusive: "prima di "
42
+ set_earlier_prefix_inclusive: "prima di "
43
+ set_last_date_connector_exclusive: " o "
44
+ set_last_date_connector_inclusive: " e "
45
+ set_later_prefix_exclusive: "dopo "
46
+ set_later_prefix_inclusive: "dopo "
47
+ set_two_dates_connector_exclusive: " o "
48
+ set_two_dates_connector_inclusive: " e "
49
+ uncertain_date_suffix: " ?"
50
+ unknown: "data sconosciuta"
51
+ unspecified_digit_substitute: "x"
52
+ formats:
53
+ day_precision_strftime_format: "%-d %B %Y"
54
+ month_precision_strftime_format: "%B %Y"
55
+ year_precision_strftime_format: "%Y"
@@ -1 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'edtf/humanize'
4
+
5
+ I18n.load_path +=
6
+ Dir.glob("#{File.dirname(__FILE__)}/../config/locales/*.{rb,yml}")
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Edtf
2
4
  module Humanize
3
-
4
5
  require 'edtf'
5
6
 
6
- require 'edtf/humanize/formats'
7
+ require 'edtf/humanize/language'
7
8
  require 'edtf/humanize/decade'
8
9
  require 'edtf/humanize/century'
9
10
  require 'edtf/humanize/season'
@@ -11,6 +12,18 @@ module Edtf
11
12
  require 'edtf/humanize/set'
12
13
  require 'edtf/humanize/unknown'
13
14
  require 'edtf/humanize/iso_date'
15
+ require 'edtf/humanize/language/default/formats'
16
+ require 'edtf/humanize/language/default/decade'
17
+ require 'edtf/humanize/language/default/century'
18
+ require 'edtf/humanize/language/default/season'
19
+ require 'edtf/humanize/language/default/interval'
20
+ require 'edtf/humanize/language/default/set'
21
+ require 'edtf/humanize/language/default/unknown'
22
+ require 'edtf/humanize/language/default/iso_date'
23
+ require 'edtf/humanize/language/default'
24
+ require 'edtf/humanize/language/english'
25
+ require 'edtf/humanize/language/french'
26
+ require 'edtf/humanize/language/italian'
14
27
 
15
28
  EDTF::Decade.include Edtf::Humanize::Decade
16
29
  EDTF::Century.include Edtf::Humanize::Century
@@ -20,7 +33,6 @@ module Edtf
20
33
  EDTF::Unknown.include Edtf::Humanize::Unknown
21
34
  Date.include Edtf::Humanize::IsoDate
22
35
 
23
-
24
36
  def self.configuration
25
37
  @configuration ||= Configuration.new
26
38
  end
@@ -34,47 +46,18 @@ module Edtf
34
46
  end
35
47
 
36
48
  class Configuration
37
-
38
- attr_accessor :day_precision_strftime_format,
39
- :month_precision_strftime_format,
40
- :year_precision_strftime_format,
41
- :approximate_date_prefix,
42
- :uncertain_date_suffix,
43
- :decade_suffix,
44
- :century_suffix,
45
- :unspecified_digit_substitute,
46
- :interval_connector,
47
- :set_dates_connector,
48
- :set_last_date_connector,
49
- :set_two_dates_connector,
50
- :interval_unspecified_suffix,
51
- :unknown
52
-
53
49
  def initialize
54
- @day_precision_strftime_format = "%B %-d, %Y"
55
- @month_precision_strftime_format = "%B %Y"
56
- @year_precision_strftime_format = "%Y"
57
-
58
- @approximate_date_prefix = "circa "
59
-
60
- @uncertain_date_suffix = "?"
61
-
62
- @decade_suffix = "s"
63
- @century_suffix = "s"
64
-
65
- @unspecified_digit_substitute = "x"
66
-
67
- @interval_connector = " to "
68
- @interval_unspecified_suffix = "s"
69
-
70
- @set_dates_connector = ", "
71
- @set_last_date_connector = " or "
72
- @set_two_dates_connector = " or "
73
-
74
- @unknown = "unknown"
50
+ @language_strategies = {
51
+ default: Edtf::Humanize::Language::Default,
52
+ en: Edtf::Humanize::Language::English,
53
+ fr: Edtf::Humanize::Language::French,
54
+ it: Edtf::Humanize::Language::Italian
55
+ }
75
56
  end
76
57
 
58
+ def language_strategy(language)
59
+ @language_strategies[language.to_sym] || @language_strategies[:default]
60
+ end
77
61
  end
78
-
79
62
  end
80
63
  end
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Edtf
2
4
  module Humanize
3
5
  module Century
6
+ include Edtf::Humanize::Language
4
7
 
5
- include Edtf::Humanize::Formats
6
-
7
8
  def humanize
8
- "#{self.begin.year}#{Edtf::Humanize.configuration.century_suffix}"
9
+ language_strategy::Century.humanizer(self)
9
10
  end
10
-
11
11
  end
12
12
  end
13
13
  end
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Edtf
2
4
  module Humanize
3
5
  module Decade
6
+ include Edtf::Humanize::Language
4
7
 
5
- include Edtf::Humanize::Formats
6
-
7
8
  def humanize
8
- "#{self.begin.year}#{Edtf::Humanize.configuration.decade_suffix}"
9
+ language_strategy::Decade.humanizer(self)
9
10
  end
10
-
11
11
  end
12
12
  end
13
13
  end
@@ -1,26 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Edtf
2
4
  module Humanize
3
5
  module Interval
4
-
5
- include Edtf::Humanize::Formats
6
+ include Edtf::Humanize::Language
6
7
 
7
8
  def humanize
8
- "#{apply_if_approximate(self.from)}#{simple_date_format(self.from)}#{Edtf::Humanize.configuration.interval_connector}#{simple_date_format(self.to)}"
9
- end
10
-
11
- private
12
-
13
- # '198u/199u' => 1980s to 1990s
14
- def apply_if_unspecified_year date
15
- display = date_precision(date)
16
- if date.respond_to? :unspecified?
17
- if date.unspecified? :year
18
- display << Edtf::Humanize.configuration.interval_unspecified_suffix
19
- end
20
- end
21
- display
9
+ language_strategy::Interval.humanizer(self)
22
10
  end
23
-
24
11
  end
25
12
  end
26
13
  end
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Edtf
2
4
  module Humanize
3
5
  module IsoDate
4
-
5
- include Edtf::Humanize::Formats
6
+ include Edtf::Humanize::Language
6
7
 
7
8
  def humanize
8
- "#{apply_if_approximate(self)}#{simple_date_format(self)}"
9
+ language_strategy::IsoDate.humanizer(self)
9
10
  end
10
-
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Edtf
4
+ module Humanize
5
+ module Language
6
+ extend self
7
+
8
+ def language_strategy
9
+ Edtf::Humanize.configuration.language_strategy(I18n.locale)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Edtf
4
+ module Humanize
5
+ module Language
6
+ module Default
7
+ include Century
8
+ include Decade
9
+ include Interval
10
+ include IsoDate
11
+ include Season
12
+ include Set
13
+ include Unknown
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Edtf
4
+ module Humanize
5
+ module Language
6
+ module Default
7
+ module Century
8
+ include Edtf::Humanize::Language::Default::Formats
9
+
10
+ extend self
11
+
12
+ def humanizer(date)
13
+ "#{date.begin.year}" \
14
+ "#{I18n.t('edtf.terms.century_suffix', default: 's')}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Edtf
4
+ module Humanize
5
+ module Language
6
+ module Default
7
+ module Decade
8
+ include Edtf::Humanize::Language::Default::Formats
9
+
10
+ extend self
11
+
12
+ def humanizer(date)
13
+ "#{I18n.t('edtf.terms.decade_prefix', default: '')}" \
14
+ "#{date.begin.year}" \
15
+ "#{I18n.t('edtf.terms.decade_suffix', default: 's')}"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Edtf
4
+ module Humanize
5
+ module Language
6
+ module Default
7
+ module Formats
8
+ extend self
9
+
10
+ private
11
+
12
+ def date_format(date)
13
+ "#{apply_if_unspecified_year(date)}#{apply_if_uncertain(date)}"
14
+ end
15
+
16
+ def date_precision(date)
17
+ if date.respond_to? :precision
18
+ case date.precision
19
+ when :day # 2010-10-25
20
+ day_precision_format(date)
21
+ when :month # 2010-10
22
+ month_precision_format(date)
23
+ when :year # 2010
24
+ year_precision_format(date)
25
+ end
26
+ else
27
+ date
28
+ end
29
+ end
30
+
31
+ # October 5, 1995
32
+ def day_precision_format(date)
33
+ I18n.localize(
34
+ date,
35
+ format: I18n.t('edtf.formats.day_precision_strftime_format',
36
+ default: '%B %-d, %Y')
37
+ )
38
+ end
39
+
40
+ # October 1995
41
+ def month_precision_format(date)
42
+ I18n.localize(
43
+ date,
44
+ format: I18n.t('edtf.formats.month_precision_strftime_format',
45
+ default: '%B %Y')
46
+ )
47
+ end
48
+
49
+ # 1995
50
+ def year_precision_format(date)
51
+ date.strftime(I18n.t('edtf.formats.year_precision_strftime_format',
52
+ default: '%Y'))
53
+ end
54
+
55
+ # '1990~' => circa 1990
56
+ def apply_prefix_if_approximate(date)
57
+ return unless date.respond_to?(:approximate?) && date.approximate?
58
+
59
+ case date.precision
60
+ when :year
61
+ I18n.t('edtf.terms.approximate_date_prefix_year',
62
+ default: 'circa ')
63
+ when :month
64
+ I18n.t('edtf.terms.approximate_date_prefix_month',
65
+ default: 'circa ')
66
+ when :day
67
+ I18n.t('edtf.terms.approximate_date_prefix_day',
68
+ default: 'circa ')
69
+ end
70
+ end
71
+
72
+ # '1990~' => 1990 environ
73
+ def apply_suffix_if_approximate(date)
74
+ return '' unless date.respond_to?(:approximate?) &&
75
+ date.approximate?
76
+
77
+ case date.precision
78
+ when :year
79
+ I18n.t('edtf.terms.approximate_date_suffix_year', default: '')
80
+ when :month
81
+ I18n.t('edtf.terms.approximate_date_suffix_month', default: '')
82
+ when :day
83
+ I18n.t('edtf.terms.approximate_date_suffix_day', default: '')
84
+ end
85
+ end
86
+
87
+ # '1990?' => 1990?
88
+ def apply_if_uncertain(date)
89
+ return '' unless date.respond_to?(:uncertain?) && date.uncertain?
90
+
91
+ I18n.t('edtf.terms.uncertain_date_suffix', default: '?')
92
+ end
93
+
94
+ # '198u' => 198x
95
+ def apply_if_unspecified_year(date)
96
+ display = date_precision(date)
97
+ if date.respond_to? :unspecified?
98
+ if date.unspecified? :year
99
+ year_substitute =
100
+ date.year_precision.edtf.gsub(
101
+ /u/,
102
+ I18n.t('edtf.terms.unspecified_digit_substitute',
103
+ default: 'x')
104
+ )
105
+ display.gsub!(date.year.to_s, year_substitute)
106
+ end
107
+ end
108
+ display
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end