date-formats 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc67b4f49a89aa6bc05ab8836ed1da60e4378705
4
- data.tar.gz: 0f2e024892406fc95e7b365e41782dec1441612f
3
+ metadata.gz: cd3d09c615122d2c212fa208fc87582cb54f1d87
4
+ data.tar.gz: 8fae32bd84325cccceba67cf5a7c5b51674e1057
5
5
  SHA512:
6
- metadata.gz: 2e75b49ee32ad7d9b0178509a70da635b388cb50496eedfc13cef9ecf87af0e9bccd0cdb8e1c154e7c25a7f62c7543f6dfccc00368bead0df940352f0a4bb135
7
- data.tar.gz: a4e71ff6484a61df679baea147d91b5e49ae5da4db169fc2e44b759109a878ac25d936ab3587aa2a79d0af35d4c1554acfa106cfbbe483e90ff8b76cae554da7
6
+ metadata.gz: 8177dfbd4a314462dc06d807883191731f12f32cba2e552cf071b8ffdb933abcd3722ed40d5df6fc97b34260804c52a0c2af02347252267ca54a6eb0e7bd9b0c
7
+ data.tar.gz: 18f96bdd0194d938929c476ac9437f57b7366557cc76634985f424e8aa8f8778146abf2ad94c4b94fa382a1370330a64c9d32d3a7abaa2d8fdcefe29983e05ad
@@ -6,6 +6,9 @@ module DateFormats
6
6
  # e.g. 2012-09-14 20:30 => YYYY-MM-DD HH:MM
7
7
  # note: allow 2012-9-3 7:30 e.g. no leading zero required
8
8
  # regex_db
9
+
10
+ ## todo/fix: add rule with allowed / separator (e.g. 2019/12/11)
11
+ ## BUT must be used in all following case too (NO mix'n'match allowed e.g. 2019-11/12)
9
12
  DB__DATE_TIME_RE = /\b
10
13
  (?<year>\d{4})
11
14
  -
@@ -14,7 +17,7 @@ DB__DATE_TIME_RE = /\b
14
17
  (?<day>\d{1,2})
15
18
  \s+
16
19
  (?<hours>\d{1,2})
17
- :
20
+ [:.hH]
18
21
  (?<minutes>\d{2})
19
22
  \b/x
20
23
 
@@ -42,7 +45,7 @@ DD_MM_YYYY__DATE_TIME_RE = /\b
42
45
  (?<year>\d{4})
43
46
  \s+
44
47
  (?<hours>\d{1,2})
45
- [:.]
48
+ [:.hH]
46
49
  (?<minutes>\d{2})
47
50
  \b/x
48
51
 
@@ -57,7 +60,7 @@ DD_MM__DATE_TIME_RE = /\b
57
60
  \.
58
61
  \s+
59
62
  (?<hours>\d{1,2})
60
- [:.]
63
+ [:.hH]
61
64
  (?<minutes>\d{2})
62
65
  \b/x
63
66
 
@@ -86,6 +89,7 @@ DD_MM__DATE_RE = /\b
86
89
 
87
90
  ##
88
91
  # e.g. 12 May 2013 14:00 => D|DD.MMM.YYYY H|HH:MM
92
+ # or 12 May 2013 14h00
89
93
  EN__DD_MONTH_YYYY__DATE_TIME_RE = /\b
90
94
  (?<day>\d{1,2})
91
95
  \s
@@ -94,7 +98,7 @@ EN__DD_MONTH_YYYY__DATE_TIME_RE = /\b
94
98
  (?<year>\d{4})
95
99
  \s+
96
100
  (?<hours>\d{1,2})
97
- :
101
+ [:hH]
98
102
  (?<minutes>\d{2})
99
103
  \b/x
100
104
 
@@ -105,44 +109,53 @@ EN__DD_MONTH__DATE_RE = /\b
105
109
  (?<month_name>#{MONTH_EN})
106
110
  \b/x
107
111
 
108
- # e.g. Fri Aug/9
112
+ # e.g. Fri Aug/9 or Fri Aug 9
113
+ # Fri, Aug/9 or Fri, Aug 9
109
114
  EN__DAY_MONTH_DD__DATE_RE = /\b
110
115
  (?<day_name>#{DAY_EN})
116
+ ,? # note: allow optional comma
111
117
  \s
112
118
  (?<month_name>#{MONTH_EN})
113
- \/
119
+ (?: \/|\s )
114
120
  (?<day>\d{1,2})
115
121
  \b/x
116
122
 
117
- # e.g. Jun/12 2011 14:00
123
+ # e.g. Jun/12 2011 14:00 or
124
+ # Jun 12, 2011 14:00 or
125
+ # Jun 12, 2011 14h00
118
126
  EN__MONTH_DD_YYYY__DATE_TIME_RE = /\b
119
127
  (?<month_name>#{MONTH_EN})
120
- \/
128
+ (?: \/|\s )
121
129
  (?<day>\d{1,2})
130
+ ,? # note: allow optional comma
122
131
  \s
123
132
  (?<year>\d{4})
124
133
  \s+
125
134
  (?<hours>\d{1,2})
126
- :
135
+ [:hH]
127
136
  (?<minutes>\d{2})
128
137
  \b/x
129
138
 
130
139
  # e.g. Jun/12 14:00 w/ implied year H|HH:MM
140
+ # or Jun 12 14h00
131
141
  EN__MONTH_DD__DATE_TIME_RE = /\b
132
142
  (?<month_name>#{MONTH_EN})
133
- \/
143
+ (?: \/|\s )
134
144
  (?<day>\d{1,2})
135
145
  \s+
136
146
  (?<hours>\d{1,2})
137
- :
147
+ [:hH]
138
148
  (?<minutes>\d{2})
139
149
  \b/x
140
150
 
141
151
  # e.g. Jun/12 2013
152
+ # or Jun 12 2013
153
+ # or Jun 12, 2013
142
154
  EN__MONTH_DD_YYYY__DATE_RE = /\b
143
155
  (?<month_name>#{MONTH_EN})
144
- \/
156
+ (?: \/|\s )
145
157
  (?<day>\d{1,2})
158
+ ,? # note: allow optional comma
146
159
  \s
147
160
  (?<year>\d{4})
148
161
  \b/x
@@ -152,14 +165,17 @@ EN__MONTH_DD_YYYY__DATE_RE = /\b
152
165
  # -- fix: might eat french weekday mar 12 is mardi (mar) !!! see FR__ pattern
153
166
  # fix: remove space again for now - and use simple en date reader or something!!!
154
167
  ## was [\/ ] changed back to \/
168
+
169
+ ## check if [\/ ] works!!!! in \x mode ??
155
170
  EN__MONTH_DD__DATE_RE = /\b
156
171
  (?<month_name>#{MONTH_EN})
157
- \/
172
+ (?: \/|\s )
158
173
  (?<day>\d{1,2})
159
174
  \b/x
160
175
 
161
176
 
162
177
 
178
+
163
179
  # e.g. 12 Ene w/ implied year
164
180
  ES__DD_MONTH__DATE_RE = /\b
165
181
  (?<day>\d{1,2})
@@ -167,6 +183,31 @@ ES__DD_MONTH__DATE_RE = /\b
167
183
  (?<month_name>#{MONTH_ES})
168
184
  \b/x
169
185
 
186
+ # e.g. Vie 12 Ene w/ implied year
187
+ ES__DAY_DD_MONTH__DATE_RE = /\b
188
+ (?<day_name>#{DAY_ES})
189
+ \.? # note: make dot optional
190
+ \s
191
+ (?<day>\d{1,2})
192
+ \s
193
+ (?<month_name>#{MONTH_ES})
194
+ \b/x
195
+
196
+ # e.g. Sáb 5 Ene 19:30
197
+ ES__DAY_DD_MONTH__DATE_TIME_RE = /\b
198
+ (?<day_name>#{DAY_ES})
199
+ \.? # note: make dot optional
200
+ \s
201
+ (?<day>\d{1,2})
202
+ \s
203
+ (?<month_name>#{MONTH_ES})
204
+ \s+
205
+ (?<hours>\d{1,2})
206
+ [:hH]
207
+ (?<minutes>\d{2})
208
+ \b/x
209
+
210
+
170
211
  # e.g. Vie. 16.8. or Sáb. 17.8.
171
212
  # or Vie 16.8. or Sáb 17.8.
172
213
  ES__DAY_MM_DD__DATE_RE = /\b
@@ -221,9 +262,11 @@ PT__DD_MM_YYYY_DAY__DATE_RE = /\b
221
262
 
222
263
  # e.g. Fr. 26.7. or Sa. 27.7.
223
264
  # or Fr 26.7. or Sa 27.7.
265
+ # or Fr, 26.7. or Sa, 27.7.
224
266
  DE__DAY_MM_DD__DATE_RE = /\b
225
267
  (?<day_name>#{DAY_DE})
226
268
  \.? # note: make dot optional
269
+ ,? # note: allow optional comma too
227
270
  \s
228
271
  (?<day>\d{1,2})
229
272
  \.
@@ -260,10 +303,13 @@ FORMATS_FR = [
260
303
  ]
261
304
 
262
305
  FORMATS_ES = [
306
+ [ ES__DAY_DD_MONTH__DATE_TIME_RE, '[ES_DAY_DD_MONTH_hh_mm]' ],
307
+ [ ES__DAY_DD_MONTH__DATE_RE, '[ES_DAY_DD_MONTH]' ],
263
308
  [ ES__DD_MONTH__DATE_RE, '[ES_DD_MONTH]' ],
264
309
  [ ES__DAY_MM_DD__DATE_RE, '[ES_DAY_MM_DD]' ],
265
310
  ]
266
311
 
312
+
267
313
  FORMATS_PT = [
268
314
  [ PT__DD_MM_YYYY_DAY__DATE_RE, '[PT_DD_MM_YYYY_DAY]' ],
269
315
  ]
@@ -27,13 +27,13 @@ TXT
27
27
 
28
28
 
29
29
  DAY_NAMES[:en] = <<TXT
30
- Monday Mon
31
- Tuesday Tues Tue Tu
32
- Wednesday Wed
30
+ Monday Mon
31
+ Tuesday Tues Tue Tu
32
+ Wednesday Wed
33
33
  Thursday Thurs Thur Thu Th
34
- Friday Fri
35
- Saturday Sat
36
- Sunday Sun
34
+ Friday Fri
35
+ Saturday Sat
36
+ Sunday Sun
37
37
  TXT
38
38
 
39
39
 
@@ -65,31 +65,31 @@ TXT
65
65
 
66
66
 
67
67
  MONTH_NAMES[:es] = <<TXT
68
- Enero Ene
69
- Febrero Feb
70
- Marzo Mar
71
- Abril Abr
72
- Mayo May
73
- Junio Jun
74
- Julio Jul
75
- Agosto Ago
76
- Septiembre Sept Sep Set ## check set in use??
77
- Octubre Oct
78
- Noviembre Nov
79
- Diciembre Dic
68
+ Enero Ene
69
+ Febrero Feb
70
+ Marzo Mar
71
+ Abril Abr
72
+ Mayo May
73
+ Junio Jun
74
+ Julio Jul
75
+ Agosto Ago
76
+ Septiembre Sept Sep Set ## check Set in use??
77
+ Octubre Oct
78
+ Noviembre Nov
79
+ Diciembre Dic
80
80
  TXT
81
81
 
82
82
  DAY_NAMES[:es] = <<TXT
83
- Lunes Lun Lu
84
- Martes Mar Ma
85
- Miércoles Mié Mi
86
- Jueves Jue Ju
87
- Viernes Vie Vi
88
- Sábado Sáb Sá
89
- Domingo Dom Do
83
+ Lunes Lun Lu
84
+ Martes Mar Ma
85
+ Miércoles Mié Mie Mi # note: add unaccented variant (for abbreviation) - why? why not?
86
+ Jueves Jue Ju
87
+ Viernes Vie Vi
88
+ Sábado Sáb Sab Sa # note: add unaccented variants (for abbreviations) - why? why not?
89
+ Domingo Dom Do
90
90
  TXT
91
91
 
92
-
92
+
93
93
  MONTH_NAMES[:de] = <<TXT
94
94
  Jänner Januar Jan Jän # note: in Austria - Jänner; in Deutschland Januar allow both ??
95
95
  Feber Februar Feb
@@ -114,8 +114,8 @@ Freitag Fr
114
114
  Samstag Sa
115
115
  Sonntag So
116
116
  TXT
117
-
118
-
117
+
118
+
119
119
  MONTH_NAMES[:it] = <<TXT
120
120
  Gennaio
121
121
  Febbraio
@@ -140,7 +140,7 @@ Venerdì Ven
140
140
  Sabato Sab
141
141
  Domenica Dom Do
142
142
  TXT
143
-
143
+
144
144
 
145
145
  MONTH_NAMES[:pt] = <<TXT
146
146
  Janeiro
@@ -166,8 +166,8 @@ Sexta-feira Sex
166
166
  Sábado Sab
167
167
  Domingo Dom
168
168
  TXT
169
-
170
-
169
+
170
+
171
171
  MONTH_NAMES[:ro] = <<TXT
172
172
  Ianuarie
173
173
  Februarie
@@ -194,7 +194,7 @@ Duminică Du
194
194
  TXT
195
195
 
196
196
 
197
-
197
+
198
198
  DAY_NAMES[:nl] = <<TXT
199
199
  Maandag Ma
200
200
  Dinsdag Di
@@ -224,10 +224,10 @@ Péntek P
224
224
  Szombat Szo
225
225
  Vasárnap Vas
226
226
  TXT
227
-
228
-
229
-
230
-
227
+
228
+
229
+
230
+
231
231
  ############################################
232
232
  ## convert (unparsed) text to (parsed) lines with words
233
233
  MONTH_NAMES.each {|k,v| MONTH_NAMES[k] = parse_month(v) }
@@ -4,7 +4,7 @@
4
4
  module DateFormats
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 2
7
- PATCH = 2
7
+ PATCH = 3
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -12,7 +12,12 @@ class TestParse < MiniTest::Test
12
12
  def test_date
13
13
  data = [
14
14
  [ '19.01.2013 22.00', '2013-01-19 22:00', '[DD_MM_YYYY_hh_mm]' ],
15
+ [ '19.01.2013 22h00', '2013-01-19 22:00', '[DD_MM_YYYY_hh_mm]' ],
16
+ [ '19.01.2013 22:00', '2013-01-19 22:00', '[DD_MM_YYYY_hh_mm]' ],
15
17
  [ '21.01.2013 21.30', '2013-01-21 21:30', '[DD_MM_YYYY_hh_mm]' ],
18
+ [ '21.01.2013 21:30', '2013-01-21 21:30', '[DD_MM_YYYY_hh_mm]' ],
19
+ [ '21.01.2013 21H30', '2013-01-21 21:30', '[DD_MM_YYYY_hh_mm]' ],
20
+
16
21
  [ '26.01.2013', '2013-01-26', '[DD_MM_YYYY]' ],
17
22
  [ '[26.01.2013]', '2013-01-26', '[[DD_MM_YYYY]]' ],
18
23
  [ '[21.1.]', '2013-01-21', '[[DD_MM]]' ]
@@ -14,6 +14,8 @@ class TestParseDe < MiniTest::Test
14
14
  [ 'Fr. 26.7.', '2019-07-26', '[DE_DAY_MM_DD]' ],
15
15
  [ 'Fr. 26.07.', '2019-07-26', '[DE_DAY_MM_DD]' ],
16
16
  [ 'Fr 26.7.', '2019-07-26', '[DE_DAY_MM_DD]' ],
17
+ [ 'Fr., 26.07.', '2019-07-26', '[DE_DAY_MM_DD]' ],
18
+ [ 'Fr, 26.7.', '2019-07-26', '[DE_DAY_MM_DD]' ],
17
19
  [ '[Fr. 26.7.]', '2019-07-26', '[[DE_DAY_MM_DD]]' ],
18
20
  ]
19
21
 
@@ -11,18 +11,29 @@ class TestParseEn < MiniTest::Test
11
11
 
12
12
  def test_date
13
13
  data = [
14
- [ 'Jun/12 2011 14:00', '2011-06-12 14:00', '[EN_MONTH_DD_YYYY_hh_mm]' ],
15
- [ 'Oct/12 2013 16:00', '2013-10-12 16:00', '[EN_MONTH_DD_YYYY_hh_mm]' ],
16
-
17
- [ 'Jan/26 2011', '2011-01-26', '[EN_MONTH_DD_YYYY]' ],
18
- [ 'Jan/26', '2013-01-26', '[EN_MONTH_DD]' ],
19
- [ '26 January', '2013-01-26', '[EN_DD_MONTH]' ],
20
-
21
- [ 'Jun/13', '2013-06-13', '[EN_MONTH_DD]' ],
22
- [ '13 June', '2013-06-13', '[EN_DD_MONTH]' ],
23
-
24
- [ 'Fri Aug/9', '2013-08-09', '[EN_DAY_MONTH_DD]' ],
25
- [ '[Fri Aug/9]', '2013-08-09', '[[EN_DAY_MONTH_DD]]' ],
14
+ [ 'Jun/12 2011 14:00', '2011-06-12 14:00', '[EN_MONTH_DD_YYYY_hh_mm]' ],
15
+ [ 'Jun 12 2011 14:00', '2011-06-12 14:00', '[EN_MONTH_DD_YYYY_hh_mm]' ],
16
+ [ 'Jun 12, 2011 14h00', '2011-06-12 14:00', '[EN_MONTH_DD_YYYY_hh_mm]' ],
17
+ [ 'Oct/12 2013 16:00', '2013-10-12 16:00', '[EN_MONTH_DD_YYYY_hh_mm]' ],
18
+ [ 'Oct 12, 2013 16H00', '2013-10-12 16:00', '[EN_MONTH_DD_YYYY_hh_mm]' ],
19
+
20
+ [ 'Jan/26 2011', '2011-01-26', '[EN_MONTH_DD_YYYY]' ],
21
+ [ 'Jan/26, 2011', '2011-01-26', '[EN_MONTH_DD_YYYY]' ],
22
+ [ 'Jan 26, 2011', '2011-01-26', '[EN_MONTH_DD_YYYY]' ],
23
+
24
+ [ 'Jan/26', '2013-01-26', '[EN_MONTH_DD]' ],
25
+ [ 'Jan 26', '2013-01-26', '[EN_MONTH_DD]' ],
26
+ [ 'Jun/13', '2013-06-13', '[EN_MONTH_DD]' ],
27
+
28
+ [ '26 January', '2013-01-26', '[EN_DD_MONTH]' ],
29
+ [ '13 June', '2013-06-13', '[EN_DD_MONTH]' ],
30
+
31
+ [ 'Fri Aug/9', '2013-08-09', '[EN_DAY_MONTH_DD]' ],
32
+ [ 'Fri Aug 9', '2013-08-09', '[EN_DAY_MONTH_DD]' ],
33
+ [ 'Fri, Aug 9', '2013-08-09', '[EN_DAY_MONTH_DD]' ],
34
+ [ '[Fri Aug/9]', '2013-08-09', '[[EN_DAY_MONTH_DD]]' ],
35
+ [ '[Fri Aug 9]', '2013-08-09', '[[EN_DAY_MONTH_DD]]' ],
36
+ [ '[Fri, Aug 9]', '2013-08-09', '[[EN_DAY_MONTH_DD]]' ],
26
37
  ]
27
38
 
28
39
  assert_dates( data, start: Date.new( 2013, 1, 1 ), lang: 'en' )
@@ -11,13 +11,21 @@ class TestParseEs < MiniTest::Test
11
11
 
12
12
  def test_date
13
13
  data = [
14
- [ '12 Ene', '2019-01-12', '[ES_DD_MONTH]' ],
15
- [ '[12 Ene]', '2019-01-12', '[[ES_DD_MONTH]]' ],
14
+ [ '12 Ene', '2019-01-12', '[ES_DD_MONTH]' ],
15
+ [ '[12 Ene]', '2019-01-12', '[[ES_DD_MONTH]]' ],
16
16
 
17
- [ 'Sáb. 17.8.', '2019-08-17', '[ES_DAY_MM_DD]' ],
18
- [ 'Sáb. 17.08.', '2019-08-17', '[ES_DAY_MM_DD]' ],
19
- [ 'Sáb 17.8.', '2019-08-17', '[ES_DAY_MM_DD]' ],
20
- [ '[Sáb 17.8.]', '2019-08-17', '[[ES_DAY_MM_DD]]' ],
17
+ [ 'Sáb. 17.8.', '2019-08-17', '[ES_DAY_MM_DD]' ],
18
+ [ 'Sáb. 17.08.', '2019-08-17', '[ES_DAY_MM_DD]' ],
19
+ [ 'Sáb 17.8.', '2019-08-17', '[ES_DAY_MM_DD]' ],
20
+ [ '[Sáb 17.8.]', '2019-08-17', '[[ES_DAY_MM_DD]]' ],
21
+
22
+ [ 'Sáb 5 Ene', '2019-01-05', '[ES_DAY_DD_MONTH]'],
23
+ [ 'Sáb. 05 Ene', '2019-01-05', '[ES_DAY_DD_MONTH]'],
24
+ [ '[Sáb 5 Ene]', '2019-01-05', '[[ES_DAY_DD_MONTH]]'],
25
+
26
+ [ 'Sáb 5 Ene 19:30', '2019-01-05 19:30', '[ES_DAY_DD_MONTH_hh_mm]'],
27
+ [ 'Sáb. 05 Ene 19:30', '2019-01-05 19:30', '[ES_DAY_DD_MONTH_hh_mm]'],
28
+ [ 'Sáb. 5 Ene 19h30', '2019-01-05 19:30', '[ES_DAY_DD_MONTH_hh_mm]'],
21
29
  ]
22
30
 
23
31
  assert_dates( data, start: Date.new( 2019, 1, 1 ), lang: 'es' )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date-formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer