date-formats 0.2.3 → 0.2.4

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: cd3d09c615122d2c212fa208fc87582cb54f1d87
4
- data.tar.gz: 8fae32bd84325cccceba67cf5a7c5b51674e1057
3
+ metadata.gz: baa48968774f8b6836837a91b553c7682f1ad779
4
+ data.tar.gz: 9b78d9218496470e487fdfece20bf22bdcd073e0
5
5
  SHA512:
6
- metadata.gz: 8177dfbd4a314462dc06d807883191731f12f32cba2e552cf071b8ffdb933abcd3722ed40d5df6fc97b34260804c52a0c2af02347252267ca54a6eb0e7bd9b0c
7
- data.tar.gz: 18f96bdd0194d938929c476ac9437f57b7366557cc76634985f424e8aa8f8778146abf2ad94c4b94fa382a1370330a64c9d32d3a7abaa2d8fdcefe29983e05ad
6
+ metadata.gz: 93b169c1b9bb6bdd7b4a87856de4caf02f1aae80f85a3de3d00d7e62170c124799c353e898c7796678b1fbd8a17849825fdebf167b3b25f383fd6f0290874609
7
+ data.tar.gz: 2c369457cce08c866baac1cf03627d6c5c664ae1753bdd143d9b01560931ac2b77dc87a88263c76e2a718e28bab40ff5fef50d9a1a67b6f58201158ddddf4525
data/README.md CHANGED
@@ -44,6 +44,54 @@ DateFormats.parse( 'Lundi 1 Janvier', lang: 'fr')
44
44
  #=> <Date: 2019-01-01 ((2458485j,0s,0n),+0s,2299161j)>
45
45
  ```
46
46
 
47
+ Pre-configured date formats for now include:
48
+
49
+ **Base - Work for All Languages**
50
+
51
+ - `YYYY_MM_DD_hh_mm` e.g. 2020-01-19 22:00 or 2020-1-19 22:00
52
+ - `YYYY_MM_DD` e.g. 2020-01-19 or 2020-1-19
53
+ - `DD_MM_YYYY_hh_mm` e.g. 19.01.2020 22.00 or 19.1.2020 22:00
54
+ - `DD_MM_hh_mm` e.g. 19.01. 22.00 or 19.1. 22:00
55
+ - `DD_MM_YYYY` e.g. 19.01.2020 or 19.1.2020
56
+ - `DD_MM` e.g. 19.01. or 19.1.
57
+
58
+ **English (`en`)**
59
+
60
+ - `DD_MONTH_YYYY_hh_mm` e.g. 19 Jan 2020 22:00
61
+ - `MONTH_DD_YYYY_hh_mm` e.g. Jan 19 2020 22:00 or Jan 19, 2020 22:00
62
+ - `MONTH_DD_hh_mm` e.g. Jan 19 22:00
63
+ - `MONTH_DD_YYYY` e.g. Jan 19 2020 or Jan 19, 2020 or January 19, 2020
64
+ - `DAY_MONTH_DD` e.g. Sun Jan 19 or Sun, Jan 19 or Sunday, January 19
65
+ - `MONTH_DD` e.g. Jan 19 or Jan/19
66
+ - `DD_MONTH` e.g. 19 Jan or 19/Jan
67
+
68
+ **Spanish / Español (`es`)**
69
+
70
+ - `DAY_DD_MONTH_hh_mm` e.g. Dom 19 Ene 22:00 or Dom 19 Ene 22h00
71
+ - `DAY_DD_MONTH` e.g. Dom 19 Ene or Dom 19 Enero
72
+ - `DD_MONTH` e.g. 19 Ene
73
+ - `DAY_DD_MM` e.g. Dom 19.01. or Dom 19.1.
74
+
75
+ **Portuguese / Português (`pt`)**
76
+
77
+ - `DD_MM_YYYY_DAY` e.g. 19/1/2020 Domenica
78
+ - `DAY_DD_MONTH` e.g. Dom 19 Jan or Dom 19 Janeiro
79
+ - `DAY_DD_MM` e.g. Dom 19/01 or Dom 19/1
80
+
81
+ **French / Français (`fr`)**
82
+
83
+ - `DAY_DD_MONTH` e.g. Dim. 19 Janv or Dim. 19 Janvier
84
+
85
+ **Italian / Italiano (`it`)**
86
+
87
+ - `DAY_MM_DD` e.g. Dom. 19.1.
88
+
89
+ **German / Deutsch (`de`)**
90
+
91
+ - `DAY_MM_DD` e.g. So 19.1. or So 19.01.
92
+
93
+
94
+
47
95
  How does it work?
48
96
  The `date-formats` library uses text patterns (that is, regular expressions)
49
97
  for defining and parsing new date formats.
@@ -122,6 +170,7 @@ Décembre Déce Déc
122
170
  And so on.
123
171
 
124
172
 
173
+
125
174
  ## License
126
175
 
127
176
  The `date-formats` scripts are dedicated to the public domain.
@@ -210,7 +210,7 @@ ES__DAY_DD_MONTH__DATE_TIME_RE = /\b
210
210
 
211
211
  # e.g. Vie. 16.8. or Sáb. 17.8.
212
212
  # or Vie 16.8. or Sáb 17.8.
213
- ES__DAY_MM_DD__DATE_RE = /\b
213
+ ES__DAY_DD_MM__DATE_RE = /\b
214
214
  (?<day_name>#{DAY_ES})
215
215
  \.? # note: make dot optional
216
216
  \s
@@ -259,6 +259,33 @@ PT__DD_MM_YYYY_DAY__DATE_RE = /\b
259
259
  (?<day_name>#{DAY_PT})
260
260
  \b/x
261
261
 
262
+ # e.g. Sáb, 13/Maio or Qui, 08/Junho
263
+ # or Sáb 13 Maio or Qui 8 Junho
264
+ PT__DAY_DD_MONTH__DATE_RE = /\b
265
+ (?<day_name>#{DAY_PT})
266
+ \.? # note: make dot optional
267
+ ,? # note: allow optional comma too
268
+ \s
269
+ (?<day>\d{1,2})
270
+ (?: \/|\s )
271
+ (?<month_name>#{MONTH_PT})
272
+ \b/x
273
+
274
+ # e.g. Sáb, 29/07 or Seg, 31/07
275
+ # Sáb 29/07 or Seg 31/07
276
+ PT__DAY_DD_MM__DATE_RE = /\b
277
+ (?<day_name>#{DAY_PT})
278
+ \.? # note: make dot optional
279
+ ,? # note: allow optional comma too
280
+ \s
281
+ (?<day>\d{1,2})
282
+ \/
283
+ (?<month>\d{1,2})
284
+ \b/x
285
+
286
+
287
+
288
+
262
289
 
263
290
  # e.g. Fr. 26.7. or Sa. 27.7.
264
291
  # or Fr 26.7. or Sa 27.7.
@@ -306,12 +333,14 @@ FORMATS_ES = [
306
333
  [ ES__DAY_DD_MONTH__DATE_TIME_RE, '[ES_DAY_DD_MONTH_hh_mm]' ],
307
334
  [ ES__DAY_DD_MONTH__DATE_RE, '[ES_DAY_DD_MONTH]' ],
308
335
  [ ES__DD_MONTH__DATE_RE, '[ES_DD_MONTH]' ],
309
- [ ES__DAY_MM_DD__DATE_RE, '[ES_DAY_MM_DD]' ],
336
+ [ ES__DAY_DD_MM__DATE_RE, '[ES_DAY_DD_MM]' ],
310
337
  ]
311
338
 
312
339
 
313
340
  FORMATS_PT = [
314
341
  [ PT__DD_MM_YYYY_DAY__DATE_RE, '[PT_DD_MM_YYYY_DAY]' ],
342
+ [ PT__DAY_DD_MONTH__DATE_RE, '[PT_DAY_DD_MONTH]' ],
343
+ [ PT__DAY_DD_MM__DATE_RE, '[PT_DAY_DD_MM]' ],
315
344
  ]
316
345
 
317
346
  FORMATS_DE = [
@@ -1,5 +1,10 @@
1
1
  module DateFormats
2
2
 
3
+ ###
4
+ # sources:
5
+ ## see https://web.library.yale.edu/cataloging/months
6
+ ## and others
7
+
3
8
  # todo: make more generic for reuse
4
9
  ### fix:
5
10
  ## use date/en.txt or en.txt etc. -- why? why not?
@@ -27,13 +32,13 @@ TXT
27
32
 
28
33
 
29
34
  DAY_NAMES[:en] = <<TXT
30
- Monday Mon
35
+ Monday Mon Mo
31
36
  Tuesday Tues Tue Tu
32
- Wednesday Wed
37
+ Wednesday Wed We
33
38
  Thursday Thurs Thur Thu Th
34
- Friday Fri
35
- Saturday Sat
36
- Sunday Sun
39
+ Friday Fri Fr
40
+ Saturday Sat Sa
41
+ Sunday Sun Su
37
42
  TXT
38
43
 
39
44
 
@@ -117,18 +122,18 @@ TXT
117
122
 
118
123
 
119
124
  MONTH_NAMES[:it] = <<TXT
120
- Gennaio
121
- Febbraio
122
- Marzo
123
- Aprile
124
- Maggio
125
+ Gennaio Genn
126
+ Febbraio Febbr
127
+ Marzo Mar
128
+ Aprile Apr
129
+ Maggio Magg
125
130
  Giugno
126
131
  Luglio
127
- Agosto
128
- Settembre
129
- Ottobre
130
- Novembre
131
- Dicembre
132
+ Agosto Ag
133
+ Settembre Sett
134
+ Ottobre Ott
135
+ Novembre Nov
136
+ Dicembre Dic
132
137
  TXT
133
138
 
134
139
  DAY_NAMES[:it] = <<TXT
@@ -143,18 +148,18 @@ TXT
143
148
 
144
149
 
145
150
  MONTH_NAMES[:pt] = <<TXT
146
- Janeiro
147
- Fevereiro
151
+ Janeiro Jan
152
+ Fevereiro Fev
148
153
  Março
149
154
  Abril
150
155
  Maio
151
156
  Junho
152
157
  Julho
153
158
  Agosto
154
- Setembro
155
- Outubro
156
- Novembro
157
- Dezembro
159
+ Setembro Set
160
+ Outubro Out
161
+ Novembro Nov
162
+ Dezembro Dez
158
163
  TXT
159
164
 
160
165
  DAY_NAMES[:pt] = <<TXT
@@ -163,7 +168,7 @@ Terça-feira Ter
163
168
  Quarta-feira Qua
164
169
  Quinta-feira Qui
165
170
  Sexta-feira Sex
166
- Sábado Sab
171
+ Sábado Sáb Sab # note: add unaccented variant (for abbreviation) - why? why not?
167
172
  Domingo Dom
168
173
  TXT
169
174
 
@@ -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 = 3
7
+ PATCH = 4
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -14,10 +14,10 @@ class TestParseEs < MiniTest::Test
14
14
  [ '12 Ene', '2019-01-12', '[ES_DD_MONTH]' ],
15
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_DD_MM]' ],
18
+ [ 'Sáb. 17.08.', '2019-08-17', '[ES_DAY_DD_MM]' ],
19
+ [ 'Sáb 17.8.', '2019-08-17', '[ES_DAY_DD_MM]' ],
20
+ [ '[Sáb 17.8.]', '2019-08-17', '[[ES_DAY_DD_MM]]' ],
21
21
 
22
22
  [ 'Sáb 5 Ene', '2019-01-05', '[ES_DAY_DD_MONTH]'],
23
23
  [ 'Sáb. 05 Ene', '2019-01-05', '[ES_DAY_DD_MONTH]'],
@@ -18,6 +18,18 @@ class TestParsePt < MiniTest::Test
18
18
  [ '09/04/2003 - Quarta-feira', '2003-04-09', '[PT_DD_MM_YYYY_DAY]' ],
19
19
  [ '9/4/2003 Quarta-feira', '2003-04-09', '[PT_DD_MM_YYYY_DAY]' ],
20
20
  [ '[9/4/2003 Quarta-feira]', '2003-04-09', '[[PT_DD_MM_YYYY_DAY]]' ],
21
+
22
+ [ 'Sáb, 13/Maio', '2003-05-13', '[PT_DAY_DD_MONTH]' ],
23
+ [ 'Sáb 13 Maio', '2003-05-13', '[PT_DAY_DD_MONTH]' ],
24
+
25
+ [ 'Qui, 08/Junho', '2003-06-08', '[PT_DAY_DD_MONTH]' ],
26
+ [ 'Qui 8 Junho', '2003-06-08', '[PT_DAY_DD_MONTH]' ],
27
+
28
+ [ 'Sáb, 29/07', '2003-07-29', '[PT_DAY_DD_MM]' ],
29
+ [ 'Sáb 29/7', '2003-07-29', '[PT_DAY_DD_MM]' ],
30
+
31
+ [ 'Seg, 31/07', '2003-07-31', '[PT_DAY_DD_MM]' ],
32
+ [ 'Seg 31/7', '2003-07-31', '[PT_DAY_DD_MM]' ],
21
33
  ]
22
34
 
23
35
  assert_dates( data, start: Date.new( 2003, 1, 1 ), lang: 'pt' )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date-formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-26 00:00:00.000000000 Z
11
+ date: 2019-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils