dates_from_string 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/dates_from_string.rb +12 -12
- data/lib/dates_from_string/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcccdda19e565c99699a5f0d8c6fb817d638dac1
|
4
|
+
data.tar.gz: ee541a880654b1303f544ddc3b8daa77a8ee18e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4923d3dab2741a944e9850fd705e12734ce8b0a7380f54f7fa29b0cb6c701589cdeb0a450ece7c822c60eba2e4749c82df7d853888ff3fa30526e5feed4d852a
|
7
|
+
data.tar.gz: 3162c55e8fe7585ba3ade3de7646ab8952774f1f34e8e0cde1b6ef39a0af612abbf4071e7642085928fbce3d1c557eb96a39b110486b88f83097078e48390a93
|
data/README.md
CHANGED
@@ -88,6 +88,13 @@ dates_from_string.get_structure(input)
|
|
88
88
|
# {:type=>:month, :value=>"04", :distance=>1, :key_words=>[]},
|
89
89
|
# {:type=>:year, :value=>"1948", :distance=>0, :key_words=>[]}]
|
90
90
|
#
|
91
|
+
|
92
|
+
input = 'circa 1960 and full date 07 Jun 1941'
|
93
|
+
#=> return
|
94
|
+
#[{:type=>:year, :value=>"1960", :distance=>5, :key_words=>[]},
|
95
|
+
#{:type=>:day, :value=>"07", :distance=>1, :key_words=>[]},
|
96
|
+
#{:type=>:month, :value=>"06", :distance=>1, :key_words=>[]},
|
97
|
+
#{:type=>:year, :value=>"1941", :distance=>0, :key_words=>[]}]
|
91
98
|
```
|
92
99
|
|
93
100
|
## Development
|
data/lib/dates_from_string.rb
CHANGED
@@ -66,18 +66,18 @@ class DatesFromString
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def get_full_date(string)
|
69
|
-
if
|
70
|
-
|
71
|
-
elsif
|
72
|
-
|
73
|
-
elsif
|
74
|
-
|
75
|
-
elsif
|
76
|
-
|
77
|
-
elsif
|
78
|
-
|
79
|
-
elsif
|
80
|
-
|
69
|
+
if (result = string.match(/\d{4}-\d{2}-\d{2}/))
|
70
|
+
result.to_s.split("-")
|
71
|
+
elsif (result = string.match(/\d{2}-\d{2}-\d{4}/))
|
72
|
+
result.to_s.split("-").reverse
|
73
|
+
elsif (result = string.match(/\d{4}\.\d{2}\.\d{2}/))
|
74
|
+
result.to_s.split(".")
|
75
|
+
elsif (result = string.match(/\d{2}\.\d{2}\.\d{4}/))
|
76
|
+
result.to_s.split(".").reverse
|
77
|
+
elsif (result = string.match(/\d{4}\/\d{2}\/\d{2}/))
|
78
|
+
result.to_s.split("/")
|
79
|
+
elsif (result = string.match(/\d{2}\/\d{2}\/\d{4}/))
|
80
|
+
result.to_s.split("/").reverse
|
81
81
|
# elsif string =~(/\d{2}\s{1}(Jan|Feb|Mar|Apr|May|Jun|Jul|Apr|Sep|Oct|Nov|Dec)\s{1}\d{4}/)
|
82
82
|
# string.to_date.to_s.split("-")
|
83
83
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dates_from_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Chechaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|