isodoc-i18n 1.1.9 → 1.1.10

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: e6ff9dd68aee9f2481e2c3b3efb12eb227d534841dd30ac23fa7402f64a3ffd2
4
- data.tar.gz: 5b6b0bd8eb4b8323cf8650a5dba48c966226f2898ac812beb5f5b3f31cd91b1f
3
+ metadata.gz: 17fcd1159b3550278a757d9bf50e2fde08d83b1c2be92b14f3ad6789dc509f20
4
+ data.tar.gz: fce8b97a8ac2f5df8754eb62b5994a74a5983098c00c259a5d751da9b30a3f11
5
5
  SHA512:
6
- metadata.gz: a3333a3f5386017bf62a88d8b82597477702965cf7aa9505b00927dd883420cb3a881363774a07311653703316d2f591ad1bb8b2f21d485b034ad2d9356d6544
7
- data.tar.gz: b980154492673ddd83d2cd3c90fcde55856a14e055f493df0372cc627ffd2602a197c2e3ccb0680e3c942c058540551634f4c3a7d7c51c0ba9eb77f35d422c18
6
+ metadata.gz: 18cc15dbfc165f6b0428ecb40a804065f1493c7c3fb77dd98a944f6613c8cf18c93920c559b5354eea818f4623d43e6be7dd1c58979556739bd4935811e0f935
7
+ data.tar.gz: 8d1e430afb9e49a7a82868c2987266fac810c0b4bf4e30df2e67965ed3462e5dcaa289199fa9fc29e9bbe306cca427ee6b7c712821c1ec424a1f20dcf548aee3
@@ -0,0 +1,60 @@
1
+ require "date"
2
+
3
+ module IsoDoc
4
+ class I18n
5
+ def date(value, format)
6
+ date_i18n(DateTime.iso8601(value)
7
+ .strftime(convert_date_format(format)))
8
+ end
9
+
10
+ def convert_date_format(fmt)
11
+ fmt.gsub(/%_/, " ")
12
+ .gsub(/%(\^?)([BbhPpAa])/, "%\u200c\\1\\2<%\\2>")
13
+ end
14
+
15
+ def date_i18n(val)
16
+ day_i18n(month_i18n(am_pm_i18n(val)))
17
+ end
18
+
19
+ def am_pm_i18n(val)
20
+ val.gsub(/%\u200cP<am>/, @cal.periods[:am].downcase)
21
+ .gsub(/%\u200cP<pm>/, @cal.periods[:pm].downcase)
22
+ .gsub(/%\u200cp<AM>/, @cal.periods[:am].upcase)
23
+ .gsub(/%\u200cp<PM>/, @cal.periods[:pm].upcase)
24
+ end
25
+
26
+ def month_i18n(val)
27
+ { B: :wide, b: :abbreviated, h: :abbreviated }.each do |f, t|
28
+ @cal_en.calendar_data[:months][:format][t].each do |k, v|
29
+ m = @cal.calendar_data[:months][:format][t][k]
30
+ val.gsub!(/%\u200c#{f}<#{v}>/, m)
31
+ val.gsub!(/%\u200c\^#{f}<#{v}>/, m.upcase)
32
+ end
33
+ end
34
+ val
35
+ end
36
+
37
+ def day_i18n(val)
38
+ { A: :wide, a: :abbreviated }.each do |f, t|
39
+ @cal_en.calendar_data[:days][:format][t].each do |k, v|
40
+ m = @cal.calendar_data[:days][:format][t][k]
41
+ val.gsub!(/%\u200c#{f}<#{v}>/, m)
42
+ val.gsub!(/%\u200c\^#{f}<#{v}>/, m.upcase)
43
+ end
44
+ end
45
+ val
46
+ end
47
+ end
48
+ end
49
+
50
+ # %B - The full month name (``January'')
51
+ # %^B uppercased (``JANUARY'')
52
+ # %b - The abbreviated month name (``Jan'')
53
+ # %^b uppercased (``JAN'')
54
+ # %h - Equivalent to %b
55
+ # %P - Meridian indicator, lowercase (``am'' or ``pm'')
56
+ # %p - Meridian indicator, uppercase (``AM'' or ``PM'')
57
+ # %A - The full weekday name (``Sunday'')
58
+ # %^A uppercased (``SUNDAY'')
59
+ # %a - The abbreviated name (``Sun'')
60
+ # %^a uppercased (``SUN'')
@@ -1,5 +1,5 @@
1
1
  module IsoDoc
2
2
  class I18n
3
- VERSION = "1.1.9".freeze
3
+ VERSION = "1.1.10".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -210,6 +210,7 @@ files:
210
210
  - isodoc-i18n.gemspec
211
211
  - lib/isodoc-i18n.rb
212
212
  - lib/isodoc-yaml/i18n-en.yaml
213
+ - lib/isodoc/date.rb
213
214
  - lib/isodoc/i18n-yaml.rb
214
215
  - lib/isodoc/i18n.rb
215
216
  - lib/isodoc/i18n/version.rb