pseudo_date 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pseudo_date/parser.rb +1 -1
- data/lib/pseudo_date/version.rb +1 -1
- data/spec/parser_spec.rb +34 -14
- metadata +2 -2
data/lib/pseudo_date/parser.rb
CHANGED
@@ -75,7 +75,7 @@ class Parser
|
|
75
75
|
month, day = [day, month] if month.to_i > 12 && month.to_i > day.to_i
|
76
76
|
end
|
77
77
|
elsif input.length == 4 # 2004
|
78
|
-
year = input.to_s
|
78
|
+
year = input.to_s
|
79
79
|
elsif input.length == 2 # 85
|
80
80
|
year = (input.to_i > Date.today.year.to_s.slice(2..4).to_i) ? "19#{input}" : "20#{input}"
|
81
81
|
elsif input.match(/\w/) # Jun 23, 2004
|
data/lib/pseudo_date/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe "PseudoDate Parsing" do
|
|
8
8
|
@year = '1985'
|
9
9
|
@string_date = 'Jun 25, 1985'
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
context "date hash" do
|
13
13
|
it "should parse an exact hash" do
|
14
14
|
pd = PseudoDate.new(:year => @year, :day => @day, :month => @month)
|
@@ -24,7 +24,7 @@ describe "PseudoDate Parsing" do
|
|
24
24
|
pd.year.should == @year
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
# 19850625
|
29
29
|
context "yearmonthday" do
|
30
30
|
it 'should be exact precision' do
|
@@ -38,7 +38,7 @@ describe "PseudoDate Parsing" do
|
|
38
38
|
pd.year.should == @year
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
# 1985-25-06
|
43
43
|
context "year-day-month" do
|
44
44
|
it 'should be exact precision' do
|
@@ -52,7 +52,7 @@ describe "PseudoDate Parsing" do
|
|
52
52
|
pd.year.should == @year
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
# 06-25-1985
|
57
57
|
context "month-day-year" do
|
58
58
|
it 'should be exact precision' do
|
@@ -66,7 +66,7 @@ describe "PseudoDate Parsing" do
|
|
66
66
|
pd.year.should == @year
|
67
67
|
end
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
# 25-06-1985
|
71
71
|
context "day-month-year" do
|
72
72
|
it 'should be exact precision' do
|
@@ -80,7 +80,7 @@ describe "PseudoDate Parsing" do
|
|
80
80
|
pd.year.should == @year
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
# 06/25/1985
|
85
85
|
context "month/day/year" do
|
86
86
|
it 'should be exact precision' do
|
@@ -94,7 +94,7 @@ describe "PseudoDate Parsing" do
|
|
94
94
|
pd.year.should == @year
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
# 06/1985
|
99
99
|
context "month/year" do
|
100
100
|
it 'should be partial precision' do
|
@@ -107,7 +107,7 @@ describe "PseudoDate Parsing" do
|
|
107
107
|
pd.year.should == @year
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
# 85
|
112
112
|
context "two digit year" do
|
113
113
|
it 'should be year precision' do
|
@@ -120,16 +120,36 @@ describe "PseudoDate Parsing" do
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
# 1985
|
124
123
|
context "four digit year" do
|
124
|
+
|
125
125
|
it 'should be year precision' do
|
126
126
|
PseudoDate.new(@year).precision.should == 'year'
|
127
127
|
end
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
|
129
|
+
# 1885
|
130
|
+
context "in the 19th century" do
|
131
|
+
it 'should match original input' do
|
132
|
+
pd = PseudoDate.new('1885')
|
133
|
+
pd.year.should == '1885'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# 1985
|
138
|
+
context "in the 20th century" do
|
139
|
+
it 'should match original input' do
|
140
|
+
pd = PseudoDate.new('1985')
|
141
|
+
pd.year.should == '1985'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# 2085
|
146
|
+
context "in the 21st century" do
|
147
|
+
it 'should match original input' do
|
148
|
+
pd = PseudoDate.new('2085')
|
149
|
+
pd.year.should == '2085'
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
133
153
|
end
|
134
154
|
|
135
155
|
# Jun 25, 1985
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudo_date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|