kronos 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/kronos.gemspec +1 -1
- data/lib/kronos.rb +3 -0
- data/spec/kronos_spec.rb +9 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/kronos.gemspec
CHANGED
data/lib/kronos.rb
CHANGED
@@ -4,11 +4,14 @@ class Kronos
|
|
4
4
|
|
5
5
|
attr_accessor :year, :month, :day
|
6
6
|
|
7
|
+
IGNORE_PATTERN = Regexp.compile("^prior")
|
8
|
+
|
7
9
|
def parse(string)
|
8
10
|
if string =~ /^\d{4}$/
|
9
11
|
self.year = string.to_i
|
10
12
|
elsif string =~ /^[']?(\d{2})$/
|
11
13
|
self.year = to_full_year($1.to_i)
|
14
|
+
elsif string =~ IGNORE_PATTERN
|
12
15
|
else
|
13
16
|
values = ParseDate.parsedate(string)
|
14
17
|
if values[0]
|
data/spec/kronos_spec.rb
CHANGED
@@ -132,7 +132,15 @@ describe "Kronos" do
|
|
132
132
|
c = Kronos.parse("unknown")
|
133
133
|
c.year.should == nil
|
134
134
|
c.month.should == nil
|
135
|
-
c.day.should
|
135
|
+
c.day.should == nil
|
136
|
+
c.to_hash.should == {}
|
137
|
+
end
|
138
|
+
|
139
|
+
it "prior to 1998" do
|
140
|
+
c = Kronos.parse("prior to 1998")
|
141
|
+
c.year.should == nil
|
142
|
+
c.month.should == nil
|
143
|
+
c.day.should == nil
|
136
144
|
c.to_hash.should == {}
|
137
145
|
end
|
138
146
|
|