kronos 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/FORMATS.md +51 -0
- data/Gemfile +0 -6
- data/Gemfile.lock +7 -15
- data/NOTES.md +55 -0
- data/Rakefile +2 -1
- data/lib/kronos.rb +97 -30
- data/lib/version.rb +1 -1
- data/spec/parse_spec.rb +74 -49
- metadata +29 -35
data/FORMATS.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Options for Time.strftime / Time.strptime
|
2
|
+
|
3
|
+
%a - abbreviated weekday name according to the current locale
|
4
|
+
%A - full weekday name according to the current locale
|
5
|
+
%b - abbreviated month name according to the current locale
|
6
|
+
%B - full month name according to the current locale
|
7
|
+
%c - preferred date and time representation for the current locale
|
8
|
+
%C - century number (the year divided by 100 and truncated to an integer,
|
9
|
+
range 00 to 99)
|
10
|
+
%d - day of the month as a decimal number (range 01 to 31)
|
11
|
+
%D - same as %m/%d/%y
|
12
|
+
%e - day of the month as a decimal number, a single digit is preceded by
|
13
|
+
a space (range ' 1' to '31')
|
14
|
+
%g - like %G, but without the century.
|
15
|
+
%G - The 4-digit year corresponding to the ISO week number (see %V).
|
16
|
+
This has the same format and value as %Y, except that if the ISO week
|
17
|
+
number to the previous or next year, that year is used instead.
|
18
|
+
%h - same as %b
|
19
|
+
%H - hour as a decimal number using a 24-hour clock (range 00 to 23)
|
20
|
+
%I - hour as a decimal number using a 12-hour clock (range 01 to 12)
|
21
|
+
%j - day of the year as a decimal number (range 001 to 366)
|
22
|
+
%m - month as a decimal number (range 01 to 12)
|
23
|
+
%M - minute as a decimal number
|
24
|
+
%n - newline character
|
25
|
+
%p - either `am' or `pm' according to the given time value, or the
|
26
|
+
corresponding strings for the current locale
|
27
|
+
%r - time in a.m. and p.m. notation
|
28
|
+
%R - time in 24 hour notation
|
29
|
+
%S - second as a decimal number
|
30
|
+
%t - tab character
|
31
|
+
%T - current time, equal to %H:%M:%S
|
32
|
+
%u - weekday as a decimal number [1,7], with 1 representing Monday
|
33
|
+
%U - week number of the current year as a decimal number, starting with
|
34
|
+
the first Sunday as the first day of the first week
|
35
|
+
%V - The ISO 8601:1988 week number of the current year as a decimal
|
36
|
+
number, range 01 to 53, where week 1 is the first week that has at
|
37
|
+
least 4 days in the current year, and with Monday as the first day
|
38
|
+
of the week. (Use %G or %g for the year component that corresponds
|
39
|
+
to the week number for the specified timestamp.)
|
40
|
+
%W - week number of the current year as a decimal number, starting with
|
41
|
+
the first Monday as the first day of the first week
|
42
|
+
%w - day of the week as a decimal, Sunday being 0
|
43
|
+
%x - preferred date representation for the current locale
|
44
|
+
without the time
|
45
|
+
%X - preferred time representation for the current locale
|
46
|
+
without the date
|
47
|
+
%y - year as a decimal number without a century (range 00 to 99)
|
48
|
+
%Y - year as a decimal number including the century
|
49
|
+
%Z or %z - time zone or name or abbreviation
|
50
|
+
%% - a literal `%' character
|
51
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,28 +4,20 @@ PATH
|
|
4
4
|
kronos (0.1.9)
|
5
5
|
|
6
6
|
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
7
|
specs:
|
9
8
|
diff-lcs (1.1.2)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
rspec (2.2.0)
|
17
|
-
rspec-core (~> 2.2)
|
18
|
-
rspec-expectations (~> 2.2)
|
19
|
-
rspec-mocks (~> 2.2)
|
20
|
-
rspec-core (2.2.1)
|
21
|
-
rspec-expectations (2.2.0)
|
9
|
+
rspec (2.3.0)
|
10
|
+
rspec-core (~> 2.3.0)
|
11
|
+
rspec-expectations (~> 2.3.0)
|
12
|
+
rspec-mocks (~> 2.3.0)
|
13
|
+
rspec-core (2.3.1)
|
14
|
+
rspec-expectations (2.3.0)
|
22
15
|
diff-lcs (~> 1.1.2)
|
23
|
-
rspec-mocks (2.
|
16
|
+
rspec-mocks (2.3.0)
|
24
17
|
|
25
18
|
PLATFORMS
|
26
19
|
ruby
|
27
20
|
|
28
21
|
DEPENDENCIES
|
29
|
-
jeweler (~> 1.5.1)
|
30
22
|
kronos!
|
31
23
|
rspec (~> 2.2)
|
data/NOTES.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# 2010
|
2
|
+
|
3
|
+
Date.parse('2010')
|
4
|
+
ArgumentError: invalid date
|
5
|
+
|
6
|
+
Date.strptime('2010', '%m/%d/%Y')
|
7
|
+
ArgumentError: invalid date
|
8
|
+
|
9
|
+
Chronic.parse('2010')
|
10
|
+
TypeError: can't convert Chronic::RepeaterTime::Tick into an exact number
|
11
|
+
|
12
|
+
Timeliness.parse('2010')
|
13
|
+
nil
|
14
|
+
|
15
|
+
# January
|
16
|
+
|
17
|
+
Date.parse('January')
|
18
|
+
=> #<Date: 2010-01-01 (4910395/2,0,2299161)>
|
19
|
+
|
20
|
+
Date.strptime('January', '%m/%d/%Y')
|
21
|
+
ArgumentError: invalid date
|
22
|
+
|
23
|
+
Chronic.parse('January')
|
24
|
+
=> 2011-01-16 12:00:00 -0500
|
25
|
+
|
26
|
+
Timeliness.parse('January')
|
27
|
+
nil
|
28
|
+
|
29
|
+
# February 2010
|
30
|
+
|
31
|
+
Date.parse('February 2010')
|
32
|
+
=> #<Date: 2010-02-01 (4910457/2,0,2299161)>
|
33
|
+
|
34
|
+
Date.strptime('February 2010', '%m/%d/%Y')
|
35
|
+
ArgumentError: invalid date
|
36
|
+
|
37
|
+
Chronic.parse('February 2010')
|
38
|
+
=> 2010-02-15 00:00:00 -0500
|
39
|
+
|
40
|
+
Timeliness.parse('February 2010')
|
41
|
+
nil
|
42
|
+
|
43
|
+
# February 9, 2010
|
44
|
+
|
45
|
+
Date.parse('February 9, 2010')
|
46
|
+
=> #<Date: 2010-02-09 (4910473/2,0,2299161)>
|
47
|
+
|
48
|
+
Date.strptime('February 9, 2010', '%m/%d/%Y')
|
49
|
+
ArgumentError: invalid date
|
50
|
+
|
51
|
+
Chronic.parse('February 9, 2010')
|
52
|
+
nil
|
53
|
+
|
54
|
+
Timeliness.parse('February 9, 2010')
|
55
|
+
nil
|
data/Rakefile
CHANGED
@@ -11,7 +11,8 @@ Jeweler::Tasks.new do |gem|
|
|
11
11
|
gem.email = "djames@sunlightfoundation.com"
|
12
12
|
gem.homepage = "http://github.com/djsun/kronos"
|
13
13
|
gem.authors = ["David James"]
|
14
|
-
gem.add_development_dependency "rspec", "~> 2.
|
14
|
+
gem.add_development_dependency "rspec", "~> 2.3"
|
15
|
+
gem.add_development_dependency "jeweler", "~> 1.5"
|
15
16
|
gem.rubyforge_project = 'kronos'
|
16
17
|
# gem is a Gem::Specification
|
17
18
|
# see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/lib/kronos.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.expand_path(
|
2
|
-
require '
|
1
|
+
require File.expand_path('../version', __FILE__)
|
2
|
+
require 'date'
|
3
3
|
|
4
4
|
class Kronos
|
5
5
|
|
@@ -8,49 +8,116 @@ class Kronos
|
|
8
8
|
|
9
9
|
attr_accessor :year, :month, :day
|
10
10
|
|
11
|
-
IGNORE_PATTERN = Regexp.compile(
|
11
|
+
IGNORE_PATTERN = Regexp.compile('^prior')
|
12
12
|
|
13
13
|
def parse(string)
|
14
14
|
if string.nil? || string =~ IGNORE_PATTERN
|
15
15
|
nil # do nothing
|
16
|
-
elsif
|
17
|
-
|
18
|
-
|
16
|
+
elsif\
|
17
|
+
p = parse_date(string, '%Y-%m-%d') || # 1988-09-23
|
18
|
+
p = parse_date(string, '%Y-%b-%d') || # 1988-Sep-23
|
19
|
+
p = parse_date(string, '%Y-%B-%d') || # 1988-September-23
|
20
|
+
p = parse_date(string, '%y-%m-%d') || # 88-9-23
|
21
|
+
p = parse_date(string, '%y-%b-%d') || # 88-Sep-23
|
22
|
+
p = parse_date(string, '%y-%B-%d') || # 88-September-23
|
23
|
+
p = parse_date(string, '%m/%d/%Y') || # 9/23/1988
|
24
|
+
p = parse_date(string, '%b/%d/%Y') || # Sep/23/1988
|
25
|
+
p = parse_date(string, '%B/%d/%Y') || # September/23/1988
|
26
|
+
p = parse_date(string, '%m/%d/%y') || # 11/23/88
|
27
|
+
p = parse_date(string, '%b/%d/%y') || # Sep/23/88
|
28
|
+
p = parse_date(string, '%B/%d/%y') || # September/23/88
|
29
|
+
p = parse_date(string, '%m-%d-%Y') || # 11-23-1988
|
30
|
+
p = parse_date(string, '%b-%d-%Y') || # Sep-23-1988
|
31
|
+
p = parse_date(string, '%B-%d-%Y') || # September-23-1988
|
32
|
+
p = parse_date(string, '%m %d %Y') || # 11 23 1988
|
33
|
+
p = parse_date(string, '%b %d %Y') || # Sep 23 1988
|
34
|
+
p = parse_date(string, '%B %d %Y') || # September 23 1988
|
35
|
+
p = parse_date(string, '%m %d %y') || # 11 23 88
|
36
|
+
p = parse_date(string, '%b %d %y') || # Sep 23 88
|
37
|
+
p = parse_date(string, '%B %d %y') || # September 23 88
|
38
|
+
p = parse_date(string, '%d-%b-%Y') || # 23-Sep-1988
|
39
|
+
p = parse_date(string, '%d-%B-%Y') || # 23-September-1988
|
40
|
+
p = parse_date(string, '%d-%b-%y') || # 23-Sep-88
|
41
|
+
p = parse_date(string, '%d-%B-%y') || # 23-September-88
|
42
|
+
p = parse_date(string, '%d %b %Y') || # 23 Sep 1988
|
43
|
+
p = parse_date(string, '%d %B %Y') || # 23 September 1988
|
44
|
+
p = parse_date(string, '%d %b %y') || # 23 Sep 88
|
45
|
+
p = parse_date(string, '%d %B %y') || # 23 September 88
|
46
|
+
false
|
47
|
+
self.year = to_full_year(p.year)
|
48
|
+
self.month = p.month
|
49
|
+
self.day = p.day
|
50
|
+
elsif\
|
51
|
+
p = parse_date(string, '%Y-%m') || # 1976-4
|
52
|
+
p = parse_date(string, '%Y-%b') || # 1976-Apr
|
53
|
+
p = parse_date(string, '%Y-%B') || # 1976-April
|
54
|
+
p = parse_date(string, '%m/%Y') || # 4/1976
|
55
|
+
p = parse_date(string, '%b/%Y') || # Apr/1976
|
56
|
+
p = parse_date(string, '%B/%Y') || # April/1976
|
57
|
+
p = parse_date(string, '%m-%Y') || # 4-1976
|
58
|
+
p = parse_date(string, '%b-%Y') || # Apr-1976
|
59
|
+
p = parse_date(string, '%B-%Y') || # April-1976
|
60
|
+
p = parse_date(string, '%m %Y') || # 4 1976
|
61
|
+
p = parse_date(string, '%b %Y') || # Apr 1976
|
62
|
+
p = parse_date(string, '%B %Y') || # April 1976
|
63
|
+
p = parse_date(string, '%m/%y') || # 4/76
|
64
|
+
p = parse_date(string, '%b/%y') || # Apr/76
|
65
|
+
p = parse_date(string, '%B/%y') || # April/76
|
66
|
+
p = parse_date(string, '%m-%y') || # 4-76
|
67
|
+
p = parse_date(string, '%b-%y') || # Apr-76
|
68
|
+
p = parse_date(string, '%B-%y') || # April-76
|
69
|
+
p = parse_date(string, '%m %y') || # 4 76
|
70
|
+
p = parse_date(string, '%b %y') || # Apr 76
|
71
|
+
p = parse_date(string, '%B %y') || # April 76
|
72
|
+
false
|
73
|
+
self.year = to_full_year(p.year)
|
74
|
+
self.month = p.month
|
75
|
+
elsif\
|
76
|
+
p = parse_date(string, '%Y') || # 1991
|
77
|
+
p = parse_date(string, '%y') || # 91
|
78
|
+
false
|
79
|
+
self.year = to_full_year(p.year)
|
80
|
+
elsif\
|
81
|
+
string =~ /^[']?(\d{2})$/ # '91
|
19
82
|
self.year = to_full_year($1.to_i)
|
20
|
-
else
|
21
|
-
values = ParseDate.parsedate(string)
|
22
|
-
if values[0]
|
23
|
-
# ParseDate parsed a year
|
24
|
-
self.year = to_full_year(values[0])
|
25
|
-
self.month = values[1]
|
26
|
-
self.day = values[2]
|
27
|
-
elsif values[2]
|
28
|
-
# ParseDate parsed a day but not a year
|
29
|
-
self.year = to_full_year(values[2])
|
30
|
-
self.month = values[1]
|
31
|
-
self.day = nil
|
32
|
-
end
|
33
83
|
end
|
34
84
|
self
|
35
85
|
end
|
36
86
|
|
87
|
+
# This method:
|
88
|
+
# 1. Swallows ArgumentError from Date.strptime
|
89
|
+
# 2. Does not trust a match from Date.strptime unless it matches the
|
90
|
+
# inverse operation, namely Date#strftime.
|
91
|
+
# 3. However, the inverse operation is complicated by the way that
|
92
|
+
# #strftime handles leading zeros. For now, I have a hack that
|
93
|
+
# removes leading zeros.
|
94
|
+
def parse_date(original, format)
|
95
|
+
parsed = Date.strptime(original, format)
|
96
|
+
t1 = parsed.strftime(format)
|
97
|
+
t2 = t1.gsub('/0', '/').gsub('-0', '-').gsub(/^0/, '')
|
98
|
+
return unless original == t1 || original == t2
|
99
|
+
parsed
|
100
|
+
rescue ArgumentError
|
101
|
+
nil
|
102
|
+
end
|
103
|
+
|
37
104
|
def to_s
|
38
|
-
s =
|
105
|
+
s = ''
|
39
106
|
raise Invalid, errors unless valid?
|
40
|
-
s <<
|
41
|
-
s <<
|
42
|
-
s <<
|
107
|
+
s << '%04i' % year if year
|
108
|
+
s << '-%02i' % month if month
|
109
|
+
s << '-%02i' % day if day
|
43
110
|
s
|
44
111
|
end
|
45
112
|
|
46
113
|
def errors
|
47
114
|
errors = []
|
48
115
|
if day && (!month || !year)
|
49
|
-
errors <<
|
116
|
+
errors << 'if day is given, then month and year must also be given'
|
50
117
|
elsif month && !year
|
51
|
-
errors <<
|
118
|
+
errors << 'if month is given, then year must also be given'
|
52
119
|
elsif !year
|
53
|
-
errors <<
|
120
|
+
errors << 'year must be given'
|
54
121
|
else
|
55
122
|
if day && !((1 .. 31) === day)
|
56
123
|
errors << "day (#{day}) must be between 1 and 31"
|
@@ -100,11 +167,11 @@ class Kronos
|
|
100
167
|
elsif self.day == other.day
|
101
168
|
false
|
102
169
|
else
|
103
|
-
raise Exception,
|
170
|
+
raise Exception, 'unexpected error'
|
104
171
|
end
|
105
172
|
end
|
106
173
|
else
|
107
|
-
raise Exception,
|
174
|
+
raise Exception, 'unexpected error'
|
108
175
|
end
|
109
176
|
end
|
110
177
|
|
@@ -146,11 +213,11 @@ class Kronos
|
|
146
213
|
elsif self.day == other.day
|
147
214
|
false
|
148
215
|
else
|
149
|
-
raise Exception,
|
216
|
+
raise Exception, 'unexpected error'
|
150
217
|
end
|
151
218
|
end
|
152
219
|
else
|
153
|
-
raise Exception,
|
220
|
+
raise Exception, 'unexpected error'
|
154
221
|
end
|
155
222
|
end
|
156
223
|
|
data/lib/version.rb
CHANGED
data/spec/parse_spec.rb
CHANGED
@@ -2,109 +2,134 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "Kronos" do
|
4
4
|
|
5
|
+
it "1/17/2007" do
|
6
|
+
c = Kronos.parse("1/17/2007")
|
7
|
+
[c.year, c.month, c.day].should == [2007, 1, 17]
|
8
|
+
end
|
9
|
+
|
10
|
+
it "01/17/2007" do
|
11
|
+
c = Kronos.parse("01/17/2007")
|
12
|
+
[c.year, c.month, c.day].should == [2007, 1, 17]
|
13
|
+
end
|
14
|
+
|
15
|
+
it "05/09/2007" do
|
16
|
+
c = Kronos.parse("05/09/2007")
|
17
|
+
[c.year, c.month, c.day].should == [2007, 5, 9]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "05-09-2007" do
|
21
|
+
c = Kronos.parse("05-09-2007")
|
22
|
+
[c.year, c.month, c.day].should == [2007, 5, 9]
|
23
|
+
end
|
24
|
+
|
5
25
|
it "15-Mar-2001" do
|
6
26
|
c = Kronos.parse("15-Mar-2001")
|
7
|
-
c.year.should
|
8
|
-
|
9
|
-
|
27
|
+
[c.year, c.month, c.day].should == [2001, 3, 15]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "30-March-2001" do
|
31
|
+
c = Kronos.parse("30-March-2001")
|
32
|
+
[c.year, c.month, c.day].should == [2001, 3, 30]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "6 Dec 2001" do
|
36
|
+
c = Kronos.parse("6 Dec 2001")
|
37
|
+
[c.year, c.month, c.day].should == [2001, 12, 6]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "23 Jan 23" do
|
41
|
+
c = Kronos.parse("23 Jan 23")
|
42
|
+
[c.year, c.month, c.day].should == [2023, 1, 23]
|
43
|
+
end
|
44
|
+
|
45
|
+
it "23 Jan 1923" do
|
46
|
+
c = Kronos.parse("23 Jan 1923")
|
47
|
+
[c.year, c.month, c.day].should == [1923, 1, 23]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "12 Nov 77" do
|
51
|
+
c = Kronos.parse("12 Nov 77")
|
52
|
+
[c.year, c.month, c.day].should == [1977, 11, 12]
|
53
|
+
end
|
54
|
+
|
55
|
+
it "Nov 12 1977" do
|
56
|
+
c = Kronos.parse("Nov 12 1977")
|
57
|
+
[c.year, c.month, c.day].should == [1977, 11, 12]
|
10
58
|
end
|
11
59
|
|
12
60
|
it "January 1976" do
|
13
61
|
c = Kronos.parse("January 1976")
|
14
|
-
c.year.should
|
15
|
-
|
16
|
-
|
62
|
+
[c.year, c.month, c.day].should == [1976, 1, nil]
|
63
|
+
end
|
64
|
+
|
65
|
+
it "Jun 1976" do
|
66
|
+
c = Kronos.parse("Jun 1976")
|
67
|
+
[c.year, c.month, c.day].should == [1976, 6, nil]
|
68
|
+
end
|
69
|
+
|
70
|
+
it "Jul-71" do
|
71
|
+
c = Kronos.parse("Jul-71")
|
72
|
+
[c.year, c.month, c.day].should == [1971, 7, nil]
|
17
73
|
end
|
18
74
|
|
19
75
|
it "1991" do
|
20
76
|
c = Kronos.parse("1991")
|
21
|
-
c.year.should
|
22
|
-
c.month.should == nil
|
23
|
-
c.day.should == nil
|
77
|
+
[c.year, c.month, c.day].should == [1991, nil, nil]
|
24
78
|
end
|
25
79
|
|
26
80
|
it "91" do
|
27
81
|
c = Kronos.parse("91")
|
28
|
-
c.year.should
|
29
|
-
c.month.should == nil
|
30
|
-
c.day.should == nil
|
82
|
+
[c.year, c.month, c.day].should == [1991, nil, nil]
|
31
83
|
end
|
32
84
|
|
33
85
|
it "'91" do
|
34
86
|
c = Kronos.parse("'91")
|
35
|
-
c.year.should
|
36
|
-
c.month.should == nil
|
37
|
-
c.day.should == nil
|
87
|
+
[c.year, c.month, c.day].should == [1991, nil, nil]
|
38
88
|
end
|
39
89
|
|
40
90
|
it "2019" do
|
41
91
|
c = Kronos.parse("2019")
|
42
|
-
c.year.should
|
43
|
-
c.month.should == nil
|
44
|
-
c.day.should == nil
|
92
|
+
[c.year, c.month, c.day].should == [2019, nil, nil]
|
45
93
|
end
|
46
94
|
|
47
95
|
it "19" do
|
48
96
|
c = Kronos.parse("19")
|
49
|
-
c.year.should
|
50
|
-
c.month.should == nil
|
51
|
-
c.day.should == nil
|
97
|
+
[c.year, c.month, c.day].should == [2019, nil, nil]
|
52
98
|
end
|
53
99
|
|
54
100
|
it "'19" do
|
55
101
|
c = Kronos.parse("'19")
|
56
|
-
c.year.should
|
57
|
-
c.month.should == nil
|
58
|
-
c.day.should == nil
|
59
|
-
end
|
60
|
-
|
61
|
-
it "1/17/2007" do
|
62
|
-
c = Kronos.parse("1/17/2007")
|
63
|
-
c.year.should == 2007
|
64
|
-
c.month.should == 1
|
65
|
-
c.day.should == 17
|
102
|
+
[c.year, c.month, c.day].should == [2019, nil, nil]
|
66
103
|
end
|
67
104
|
|
68
105
|
it "Aug-96" do
|
69
106
|
c = Kronos.parse("Aug-96")
|
70
|
-
c.year.should
|
71
|
-
c.month.should == 8
|
72
|
-
c.day.should == nil
|
107
|
+
[c.year, c.month, c.day].should == [1996, 8, nil]
|
73
108
|
end
|
74
109
|
|
75
110
|
it "15-Mar-96" do
|
76
111
|
c = Kronos.parse("15-Mar-96")
|
77
|
-
c.year.should
|
78
|
-
c.month.should == 3
|
79
|
-
c.day.should == 15
|
112
|
+
[c.year, c.month, c.day].should == [1996, 3, 15]
|
80
113
|
end
|
81
114
|
|
82
115
|
it "nil" do
|
83
116
|
c = Kronos.parse(nil)
|
84
|
-
c.year.should
|
85
|
-
c.month.should == nil
|
86
|
-
c.day.should == nil
|
117
|
+
[c.year, c.month, c.day].should == [nil, nil, nil]
|
87
118
|
end
|
88
119
|
|
89
120
|
it "empty string" do
|
90
121
|
c = Kronos.parse("")
|
91
|
-
c.year.should
|
92
|
-
c.month.should == nil
|
93
|
-
c.day.should == nil
|
122
|
+
[c.year, c.month, c.day].should == [nil, nil, nil]
|
94
123
|
end
|
95
124
|
|
96
125
|
it "unknown" do
|
97
126
|
c = Kronos.parse("unknown")
|
98
|
-
c.year.should
|
99
|
-
c.month.should == nil
|
100
|
-
c.day.should == nil
|
127
|
+
[c.year, c.month, c.day].should == [nil, nil, nil]
|
101
128
|
end
|
102
129
|
|
103
130
|
it "prior to 1998" do
|
104
131
|
c = Kronos.parse("prior to 1998")
|
105
|
-
c.year.should
|
106
|
-
c.month.should == nil
|
107
|
-
c.day.should == nil
|
132
|
+
[c.year, c.month, c.day].should == [nil, nil, nil]
|
108
133
|
end
|
109
134
|
|
110
135
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kronos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 23
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
7
|
+
- 3
|
9
8
|
- 0
|
10
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- David James
|
@@ -15,69 +14,64 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-18 00:00:00 -05:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
21
|
name: kronos
|
25
|
-
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
23
|
none: false
|
27
24
|
requirements:
|
28
25
|
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 3
|
31
27
|
segments:
|
32
28
|
- 0
|
33
29
|
version: "0"
|
34
|
-
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
type: :development
|
30
|
+
type: :runtime
|
37
31
|
prerelease: false
|
38
|
-
|
39
|
-
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
36
|
none: false
|
41
37
|
requirements:
|
42
38
|
- - ~>
|
43
39
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 1
|
45
40
|
segments:
|
46
|
-
-
|
47
|
-
-
|
48
|
-
|
49
|
-
version: 1.5.1
|
50
|
-
requirement: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
41
|
+
- 2
|
42
|
+
- 2
|
43
|
+
version: "2.2"
|
52
44
|
type: :development
|
53
45
|
prerelease: false
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
54
48
|
name: rspec
|
55
|
-
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
50
|
none: false
|
57
51
|
requirements:
|
58
52
|
- - ~>
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 7
|
61
54
|
segments:
|
62
55
|
- 2
|
63
|
-
-
|
64
|
-
version: "2.
|
65
|
-
requirement: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
56
|
+
- 3
|
57
|
+
version: "2.3"
|
67
58
|
type: :development
|
68
59
|
prerelease: false
|
69
|
-
|
70
|
-
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: jeweler
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
64
|
none: false
|
72
65
|
requirements:
|
73
66
|
- - ~>
|
74
67
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 7
|
76
68
|
segments:
|
77
|
-
-
|
78
|
-
-
|
79
|
-
version: "
|
80
|
-
|
69
|
+
- 1
|
70
|
+
- 5
|
71
|
+
version: "1.5"
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: *id004
|
81
75
|
description: Kronos provides flexible date parsing. Currently just a thin layer on top of ParseDate.
|
82
76
|
email: djames@sunlightfoundation.com
|
83
77
|
executables: []
|
@@ -90,9 +84,11 @@ extra_rdoc_files:
|
|
90
84
|
files:
|
91
85
|
- .bundle/config
|
92
86
|
- .document
|
87
|
+
- FORMATS.md
|
93
88
|
- Gemfile
|
94
89
|
- Gemfile.lock
|
95
90
|
- LICENSE
|
91
|
+
- NOTES.md
|
96
92
|
- README.md
|
97
93
|
- Rakefile
|
98
94
|
- kronos.gemspec
|
@@ -121,7 +117,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
117
|
requirements:
|
122
118
|
- - ">="
|
123
119
|
- !ruby/object:Gem::Version
|
124
|
-
hash: 3
|
125
120
|
segments:
|
126
121
|
- 0
|
127
122
|
version: "0"
|
@@ -130,7 +125,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
125
|
requirements:
|
131
126
|
- - ">="
|
132
127
|
- !ruby/object:Gem::Version
|
133
|
-
hash: 3
|
134
128
|
segments:
|
135
129
|
- 0
|
136
130
|
version: "0"
|