home_run 0.9.0-x86-mingw32 → 0.9.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +46 -0
- data/README.rdoc +45 -33
- data/Rakefile +26 -67
- data/bench/cpu_bench.rb +1 -54
- data/bench/cpu_bench_util.rb +55 -0
- data/bench/parser_bench.rb +20 -0
- data/bin/home_run +14 -17
- data/default.mspec +1 -1
- data/ext/{date_ext.c → date_ext/date_ext.c} +95 -208
- data/ext/date_ext/date_ext.h +187 -0
- data/ext/date_ext/date_parser.c +852 -0
- data/ext/date_ext/date_parser.rl +352 -0
- data/ext/{datetime.c → date_ext/datetime.c} +120 -77
- data/ext/date_ext/extconf.rb +6 -0
- data/lib/1.8/date_ext.so +0 -0
- data/lib/1.9/date_ext.so +0 -0
- data/{ext → lib}/date/format.rb +1 -1
- data/lib/date.rb +7 -0
- data/lib/home_run.rb +5 -0
- data/spec/date/allocate_spec.rb +7 -0
- data/spec/date/encoding_spec.rb +42 -0
- data/spec/date/limits_spec.rb +121 -0
- data/spec/date/parse_spec.rb +154 -0
- data/spec/date/parsing_spec.rb +11 -0
- data/spec/date/step_spec.rb +22 -0
- data/spec/date/strptime_spec.rb +35 -3
- data/spec/datetime/add_spec.rb +4 -4
- data/spec/datetime/allocate_spec.rb +7 -0
- data/spec/datetime/encoding_spec.rb +42 -0
- data/spec/datetime/limits_spec.rb +170 -0
- data/spec/datetime/parse_spec.rb +73 -0
- data/spec/datetime/parsing_spec.rb +4 -0
- data/spec/datetime/step_spec.rb +22 -0
- data/spec/datetime/strptime_spec.rb +10 -0
- metadata +24 -14
- data/ext/1.8/date_ext.so +0 -0
- data/ext/1.9/date_ext.so +0 -0
- data/ext/date.rb +0 -7
- data/ext/date_parser.c +0 -367
- data/ext/date_parser.rl +0 -134
- data/ext/extconf.rb +0 -6
@@ -0,0 +1,170 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "DateTime limits: " do
|
4
|
+
before do
|
5
|
+
@d1 = DateTime.jd(DateTime::JULIAN - 1)
|
6
|
+
@d2 = DateTime.jd(DateTime::GREGORIAN + 1)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "#+ and #- should raise RangeError for dates that are too large or small" do
|
10
|
+
proc{DateTime.jd(@d1.jd) + 1}.should raise_error(RangeError)
|
11
|
+
proc{DateTime.jd(@d2.jd) - 1}.should raise_error(RangeError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "#<< and #>> should raise RangeError for dates that are too large or small" do
|
15
|
+
proc{DateTime.jd(@d1.jd) >> 1}.should raise_error(RangeError)
|
16
|
+
proc{DateTime.jd(@d2.jd) << 1}.should raise_error(RangeError)
|
17
|
+
end
|
18
|
+
|
19
|
+
ruby_version_is "1.9" do
|
20
|
+
it "#next_year and #prev_year should raise RangeError for dates that are too large or small" do
|
21
|
+
proc{DateTime.jd(@d1.jd).next_year}.should raise_error(RangeError)
|
22
|
+
proc{DateTime.jd(@d2.jd).prev_year}.should raise_error(RangeError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it ".jd should raise RangeError for dates that are too large or small" do
|
27
|
+
proc{DateTime.jd(@d1.jd + 1)}.should raise_error(RangeError)
|
28
|
+
proc{DateTime.jd(@d2.jd - 1)}.should raise_error(RangeError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it ".jd should not raise for dates that are not too large or small" do
|
32
|
+
proc{DateTime.jd(@d1.jd)}.should_not raise_error
|
33
|
+
proc{DateTime.jd(@d2.jd)}.should_not raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it ".new! should raise RangeError for dates that are too large or small" do
|
37
|
+
proc{DateTime.new!(@d1.jd + 1)}.should raise_error(RangeError)
|
38
|
+
# Need to use 1.5 instead of 1 because new! adds a half day
|
39
|
+
proc{DateTime.new!(@d2.jd - 1.5)}.should raise_error(RangeError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it ".new! should not raise for dates that are not too large or small" do
|
43
|
+
proc{DateTime.new!(@d1.jd)}.should_not raise_error
|
44
|
+
proc{DateTime.new!(@d2.jd)}.should_not raise_error
|
45
|
+
end
|
46
|
+
|
47
|
+
it ".civil should raise RangeError for dates that are too large or small" do
|
48
|
+
proc{DateTime.civil(@d1.year, @d1.month, @d1.day + 1)}.should raise_error(RangeError)
|
49
|
+
proc{DateTime.civil(@d2.year, @d2.month, @d2.day - 1)}.should raise_error(RangeError)
|
50
|
+
end
|
51
|
+
|
52
|
+
it ".civil should not raise for dates that are not too large or small" do
|
53
|
+
proc{DateTime.civil(@d1.year, @d1.month, @d1.day)}.should_not raise_error
|
54
|
+
proc{DateTime.civil(@d2.year, @d2.month, @d2.day)}.should_not raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it ".civil should correctly convert dates within limits to JD" do
|
58
|
+
DateTime.civil(@d1.year, @d1.month, @d1.day).jd.should == @d1.jd
|
59
|
+
DateTime.civil(@d2.year, @d2.month, @d2.day).jd.should == @d2.jd
|
60
|
+
end
|
61
|
+
|
62
|
+
it ".commercial should raise RangeError for dates that are too large or small" do
|
63
|
+
proc{DateTime.commercial(@d1.cwyear, @d1.cwday == 6 ? @d1.cweek + 1 : @d1.cweek, @d1.cwday == 6 ? 1 : @d1.cwday + 1)}.should raise_error(RangeError)
|
64
|
+
proc{DateTime.commercial(@d2.cwyear, @d2.cwday == 1 ? @d2.cweek - 1 : @d2.cweek, @d2.cwday == 1 ? 7 : @d2.cwday - 1)}.should raise_error(RangeError)
|
65
|
+
end
|
66
|
+
|
67
|
+
it ".commercial should not raise for dates that are not too large or small" do
|
68
|
+
proc{DateTime.commercial(@d1.cwyear, @d1.cweek, @d1.cwday)}.should_not raise_error
|
69
|
+
proc{DateTime.commercial(@d2.cwyear, @d2.cweek, @d2.cwday)}.should_not raise_error
|
70
|
+
end
|
71
|
+
|
72
|
+
it ".commercial should correctly convert dates within limits to JD" do
|
73
|
+
DateTime.commercial(@d1.cwyear, @d1.cweek, @d1.cwday).jd.should == @d1.jd
|
74
|
+
DateTime.commercial(@d2.cwyear, @d2.cweek, @d2.cwday).jd.should == @d2.jd
|
75
|
+
end
|
76
|
+
|
77
|
+
it ".ordinal should raise RangeError for dates that are too large or small" do
|
78
|
+
proc{DateTime.ordinal(@d1.year, @d1.yday + 1)}.should raise_error(RangeError)
|
79
|
+
proc{DateTime.ordinal(@d2.year, @d2.yday - 1)}.should raise_error(RangeError)
|
80
|
+
end
|
81
|
+
|
82
|
+
it ".ordinal should not raise for dates that are not too large or small" do
|
83
|
+
proc{DateTime.ordinal(@d1.year, @d1.yday)}.should_not raise_error
|
84
|
+
proc{DateTime.ordinal(@d2.year, @d2.yday)}.should_not raise_error
|
85
|
+
end
|
86
|
+
|
87
|
+
it ".ordinal should correctly convert dates within limits to JD" do
|
88
|
+
DateTime.ordinal(@d1.year, @d1.yday).jd.should == @d1.jd
|
89
|
+
DateTime.ordinal(@d2.year, @d2.yday).jd.should == @d2.jd
|
90
|
+
end
|
91
|
+
|
92
|
+
it ".parse should raise RangeError for civil dates that are too large or small" do
|
93
|
+
proc{DateTime.parse("#{@d1.year}-#{@d1.month}-#{@d1.day+1}")}.should raise_error(RangeError)
|
94
|
+
proc{DateTime.parse("#{@d2.year}-#{@d2.month}-#{@d2.day-1}")}.should raise_error(RangeError)
|
95
|
+
end
|
96
|
+
|
97
|
+
it ".parse should not raise for civil dates that are not too large or small" do
|
98
|
+
proc{DateTime.parse("#{@d1.year}-#{@d1.month}-#{@d1.day}")}.should_not raise_error
|
99
|
+
proc{DateTime.parse("#{@d2.year}-#{@d2.month}-#{@d2.day}")}.should_not raise_error
|
100
|
+
end
|
101
|
+
|
102
|
+
it ".parse should correctly convert civil dates within limits to JD" do
|
103
|
+
DateTime.parse("#{@d1.year}-#{@d1.month}-#{@d1.day}").jd.should == @d1.jd
|
104
|
+
DateTime.parse("#{@d2.year}-#{@d2.month}-#{@d2.day}").jd.should == @d2.jd
|
105
|
+
end
|
106
|
+
|
107
|
+
it ".strptime should raise RangeError for civil dates that are too large or small" do
|
108
|
+
proc{DateTime.strptime("#{@d1.year}-#{@d1.month}-#{@d1.day+1}", "%Y-%m-%d")}.should raise_error(RangeError)
|
109
|
+
proc{DateTime.strptime("#{@d2.year}-#{@d2.month}-#{@d2.day-1}", "%Y-%m-%d")}.should raise_error(RangeError)
|
110
|
+
end
|
111
|
+
|
112
|
+
it ".strptime should not raise for civil dates that are not too large or small" do
|
113
|
+
proc{DateTime.strptime("#{@d1.year}-#{@d1.month}-#{@d1.day}", "%Y-%m-%d")}.should_not raise_error
|
114
|
+
proc{DateTime.strptime("#{@d2.year}-#{@d2.month}-#{@d2.day}", "%Y-%m-%d")}.should_not raise_error
|
115
|
+
end
|
116
|
+
|
117
|
+
it ".strptime should correctly convert civil dates within limits to JD" do
|
118
|
+
DateTime.strptime("#{@d1.year}-#{@d1.month}-#{@d1.day}", "%Y-%m-%d").jd.should == @d1.jd
|
119
|
+
DateTime.strptime("#{@d2.year}-#{@d2.month}-#{@d2.day}", "%Y-%m-%d").jd.should == @d2.jd
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "DateTime offset limits: " do
|
125
|
+
it "methods should raise ArgumentError for offets that are too large or small" do
|
126
|
+
max = (14 + 1.0/60)/24
|
127
|
+
min = -(14 + 1.0/60)/24
|
128
|
+
proc{DateTime.civil(2009, 1, 1, 0, 0, 0, max)}.should raise_error(ArgumentError)
|
129
|
+
proc{DateTime.civil(2009, 1, 1, 0, 0, 0, min)}.should raise_error(ArgumentError)
|
130
|
+
proc{DateTime.commercial(2009, 1, 1, 0, 0, 0, max)}.should raise_error(ArgumentError)
|
131
|
+
proc{DateTime.commercial(2009, 1, 1, 0, 0, 0, min)}.should raise_error(ArgumentError)
|
132
|
+
proc{DateTime.ordinal(2009, 1, 0, 0, 0, max)}.should raise_error(ArgumentError)
|
133
|
+
proc{DateTime.ordinal(2009, 1, 0, 0, 0, min)}.should raise_error(ArgumentError)
|
134
|
+
proc{DateTime.jd(2009, 0, 0, 0, max)}.should raise_error(ArgumentError)
|
135
|
+
proc{DateTime.jd(2009, 0, 0, 0, min)}.should raise_error(ArgumentError)
|
136
|
+
proc{DateTime.new!(2009, max)}.should raise_error(ArgumentError)
|
137
|
+
proc{DateTime.new!(2009, min)}.should raise_error(ArgumentError)
|
138
|
+
proc{DateTime.parse("00:00:00+14:01", "%H:%M:%S%z")}.should raise_error(ArgumentError)
|
139
|
+
proc{DateTime.parse("00:00:00-14:01", "%H:%M:%S%z")}.should raise_error(ArgumentError)
|
140
|
+
proc{DateTime.strptime("00:00:00+14:01", "%H:%M:%S%z")}.should raise_error(ArgumentError)
|
141
|
+
proc{DateTime.strptime("00:00:00-14:01", "%H:%M:%S%z")}.should raise_error(ArgumentError)
|
142
|
+
|
143
|
+
d = DateTime.jd(2009)
|
144
|
+
proc{d.new_offset(max)}.should raise_error(ArgumentError)
|
145
|
+
proc{d.new_offset(min)}.should raise_error(ArgumentError)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "methods should not raise for offsets that are not too large or small" do
|
149
|
+
max = 14.0/24
|
150
|
+
min = -14.0/24
|
151
|
+
proc{DateTime.civil(2009, 1, 1, 0, 0, 0, max)}.should_not raise_error
|
152
|
+
proc{DateTime.civil(2009, 1, 1, 0, 0, 0, min)}.should_not raise_error
|
153
|
+
proc{DateTime.commercial(2009, 1, 1, 0, 0, 0, max)}.should_not raise_error
|
154
|
+
proc{DateTime.commercial(2009, 1, 1, 0, 0, 0, min)}.should_not raise_error
|
155
|
+
proc{DateTime.ordinal(2009, 1, 0, 0, 0, max)}.should_not raise_error
|
156
|
+
proc{DateTime.ordinal(2009, 1, 0, 0, 0, min)}.should_not raise_error
|
157
|
+
proc{DateTime.jd(2009, 0, 0, 0, max)}.should_not raise_error
|
158
|
+
proc{DateTime.jd(2009, 0, 0, 0, min)}.should_not raise_error
|
159
|
+
proc{DateTime.new!(2009, max)}.should_not raise_error
|
160
|
+
proc{DateTime.new!(2009, min)}.should_not raise_error
|
161
|
+
proc{DateTime.parse("00:00:00+14:00", "%H:%M:%S%z")}.should_not raise_error
|
162
|
+
proc{DateTime.parse("00:00:00-14:00", "%H:%M:%S%z")}.should_not raise_error
|
163
|
+
proc{DateTime.strptime("00:00:00+14:00", "%H:%M:%S%z")}.should_not raise_error
|
164
|
+
proc{DateTime.strptime("00:00:00-14:00", "%H:%M:%S%z")}.should_not raise_error
|
165
|
+
|
166
|
+
d = DateTime.jd(2009)
|
167
|
+
proc{d.new_offset(max)}.should_not raise_error
|
168
|
+
proc{d.new_offset(min)}.should_not raise_error
|
169
|
+
end
|
170
|
+
end
|
data/spec/datetime/parse_spec.rb
CHANGED
@@ -82,40 +82,113 @@ describe "DateTime#parse" do
|
|
82
82
|
proc{DateTime.parse(Time.now.to_s)}.should_not raise_error
|
83
83
|
end
|
84
84
|
|
85
|
+
it "can handle a leftover DD as an hour if the day has already been parsed" do
|
86
|
+
DateTime.parse("2009-12-13 10").should == DateTime.civil(2009, 12, 13, 10)
|
87
|
+
end
|
88
|
+
|
85
89
|
it "can handle DD as month day number" do
|
86
90
|
DateTime.parse("10").should == DateTime.civil(Date.today.year, Date.today.month, 10)
|
87
91
|
DateTime.parse("10 01:02:03").should == DateTime.civil(Date.today.year, Date.today.month, 10, 1, 2, 3)
|
88
92
|
end
|
89
93
|
|
94
|
+
it "can handle DDz as day and zone" do
|
95
|
+
DateTime.parse("10z").should == DateTime.civil(Date.today.year, Date.today.month, 10)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "can handle DD+DD as day and zone" do
|
99
|
+
DateTime.parse("10+11").should == DateTime.civil(Date.today.year, Date.today.month, 10, 0, 0, 0, 11/24.0)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "can handle DD[DDDD] as day and zone" do
|
103
|
+
DateTime.parse("10[1112]").should == DateTime.civil(Date.today.year, Date.today.month, 10, 0, 0, 0, 11.2/24.0)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "can handle DD.D as second" do
|
107
|
+
DateTime.parse("11.1").should == DateTime.civil(Date.today.year, Date.today.month, Date.today.day, 0, 0, 11) + 0.1/86400
|
108
|
+
end
|
109
|
+
|
110
|
+
it "can handle DDtDD as hour" do
|
111
|
+
DateTime.parse("11t12").should == DateTime.civil(Date.today.year, Date.today.month, 11, 12, 0, 0)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "can handle DDtDDDD as hour and minute" do
|
115
|
+
DateTime.parse("11t1213").should == DateTime.civil(Date.today.year, Date.today.month, 11, 12, 13, 0)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "can handle DDtDDDDDD as hour, minute, and second" do
|
119
|
+
DateTime.parse("11t121314").should == DateTime.civil(Date.today.year, Date.today.month, 11, 12, 13, 14)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "can handle DDtDDDDDD.D as hour, minute, and second" do
|
123
|
+
DateTime.parse("11t121314.1").should == DateTime.civil(Date.today.year, Date.today.month, 11, 12, 13, 14) + 0.1/86400
|
124
|
+
end
|
125
|
+
|
90
126
|
it "can handle DDD as year day number" do
|
91
127
|
DateTime.parse("050").should == DateTime.civil(Date.today.year, 2, 19)
|
92
128
|
DateTime.parse("050 1:02:03").should == DateTime.civil(Date.today.year, 2, 19, 1, 2, 3)
|
93
129
|
end
|
94
130
|
|
131
|
+
it "can handle DDD.D as minute and second" do
|
132
|
+
DateTime.parse("211.1").should == DateTime.civil(Date.today.year, Date.today.month, Date.today.day, 0, 2, 11) + 0.1/86400
|
133
|
+
end
|
134
|
+
|
95
135
|
it "can handle MMDD as month and day" do
|
96
136
|
DateTime.parse("1108").should == DateTime.civil(Date.today.year, 11, 8)
|
97
137
|
DateTime.parse("1108 10:02:03").should == DateTime.civil(Date.today.year, 11, 8, 10, 2, 3)
|
98
138
|
end
|
99
139
|
|
140
|
+
it "can handle DDDD.D as minute and second" do
|
141
|
+
DateTime.parse("1211.1").should == DateTime.civil(Date.today.year, Date.today.month, Date.today.day, 0, 12, 11) + 0.1/86400
|
142
|
+
end
|
143
|
+
|
100
144
|
it "can handle YYDDD as year and day number" do
|
101
145
|
DateTime.parse("10100").should == DateTime.civil(2010, 4, 10)
|
102
146
|
DateTime.parse("10100 23:02:03").should == DateTime.civil(2010, 4, 10, 23, 2, 3)
|
103
147
|
end
|
104
148
|
|
149
|
+
it "can handle DDDDD.D as hour, minute, and second" do
|
150
|
+
DateTime.parse("31211.1").should == DateTime.civil(Date.today.year, Date.today.month, Date.today.day, 3, 12, 11) + 0.1/86400
|
151
|
+
end
|
152
|
+
|
105
153
|
it "can handle YYMMDD as year month and day" do
|
106
154
|
DateTime.parse("201023").should == DateTime.civil(2020, 10, 23)
|
107
155
|
DateTime.parse("201023 23:02:03 +0800").should == DateTime.civil(2020, 10, 23, 23, 2, 3, 8/24.0)
|
108
156
|
end
|
109
157
|
|
158
|
+
it "can handle DDDDDD.D as hour, minute, and second" do
|
159
|
+
DateTime.parse("131211.1").should == DateTime.civil(Date.today.year, Date.today.month, Date.today.day, 13, 12, 11) + 0.1/86400
|
160
|
+
end
|
161
|
+
|
110
162
|
it "can handle YYYYDDD as year and day number" do
|
111
163
|
DateTime.parse("1910100").should == DateTime.civil(1910, 4, 10)
|
112
164
|
DateTime.parse("1910100 23:02:03 -0101").should == DateTime.civil(1910, 4, 10, 23, 2, 3, -61/1440.0)
|
113
165
|
end
|
114
166
|
|
167
|
+
it "can handle DDDDDDD.D as day, hour, minute, and second" do
|
168
|
+
DateTime.parse("4131211.1").should == DateTime.civil(Date.today.year, Date.today.month, 4, 13, 12, 11) + 0.1/86400
|
169
|
+
end
|
170
|
+
|
115
171
|
it "can handle YYYYMMDD as year and day number" do
|
116
172
|
DateTime.parse("19101101").should == DateTime.civil(1910, 11, 1)
|
117
173
|
DateTime.parse("19101101T23:02:03 +0000").should == DateTime.civil(1910, 11, 1, 23, 2, 3)
|
118
174
|
end
|
175
|
+
|
176
|
+
it "can handle DDDDDDDD.D as day, hour, minute, and second" do
|
177
|
+
DateTime.parse("14131211.1").should == DateTime.civil(Date.today.year, Date.today.month, 14, 13, 12, 11) + 0.1/86400
|
178
|
+
end
|
179
|
+
|
180
|
+
it "can handle DDDDDDDD.D as month, day, hour, minute, and second" do
|
181
|
+
DateTime.parse("1014131211.1").should == DateTime.civil(Date.today.year, 10, 14, 13, 12, 11) + 0.1/86400
|
182
|
+
end
|
183
|
+
|
184
|
+
it "can handle DDDDDDDDDD.D as year, month, day, hour, minute, and second" do
|
185
|
+
DateTime.parse("091014131211.1").should == DateTime.civil(2009, 10, 14, 13, 12, 11) + 0.1/86400
|
186
|
+
end
|
187
|
+
|
188
|
+
it "can handle DDDDDDDDDDDD.D as year, month, day, hour, minute, and second" do
|
189
|
+
DateTime.parse("20091014131211.1").should == DateTime.civil(2009, 10, 14, 13, 12, 11) + 0.1/86400
|
190
|
+
end
|
191
|
+
|
119
192
|
end
|
120
193
|
|
121
194
|
describe :date_parse, :shared => true do
|
@@ -9,6 +9,8 @@ ruby_version_is "1.9" do
|
|
9
9
|
|
10
10
|
it "._iso8601 should parse an ISO8601 format" do
|
11
11
|
DateTime._iso8601("2009-01-02T03:04:05+12:00").should == {:year=>2009, :mon=>1, :mday=>2, :hour=>3, :min=>4, :sec=>5, :offset=>43200, :zone=>'+12:00'}
|
12
|
+
DateTime._iso8601("03:04:05+12:00").should == {:hour=>3, :min=>4, :sec=>5, :offset=>43200, :zone=>'+12:00'}
|
13
|
+
DateTime._iso8601(" 030405.1+1200").should == {:hour=>3, :min=>4, :sec=>5, :offset=>43200, :zone=>'+1200', :sec_fraction=>0.1}
|
12
14
|
end
|
13
15
|
|
14
16
|
it "._jisx03010 should parse an JIS X 0301 format" do
|
@@ -38,6 +40,8 @@ ruby_version_is "1.9" do
|
|
38
40
|
|
39
41
|
it "._xmlschema should parse an ISO8601 format" do
|
40
42
|
DateTime._xmlschema("2009-01-02T03:04:05+12:00").should == {:year=>2009, :mon=>1, :mday=>2, :hour=>3, :min=>4, :sec=>5, :offset=>43200, :zone=>'+12:00'}
|
43
|
+
DateTime._xmlschema("03:04:05+12:00").should == {:hour=>3, :min=>4, :sec=>5, :offset=>43200, :zone=>'+12:00'}
|
44
|
+
DateTime._xmlschema("---01+12:00").should == {:mday=>1, :offset=>43200, :zone=>'+12:00'}
|
41
45
|
end
|
42
46
|
|
43
47
|
it ".httpdate should parse an HTTP format" do
|
data/spec/datetime/step_spec.rb
CHANGED
@@ -2,6 +2,28 @@ require File.expand_path('../../spec_helper', __FILE__)
|
|
2
2
|
|
3
3
|
describe "DateTime#step" do
|
4
4
|
|
5
|
+
ruby_version_is "" ... "1.9" do
|
6
|
+
it "should require a block" do
|
7
|
+
proc{DateTime.now.step(DateTime.now)}.should raise_error(LocalJumpError)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
ruby_version_is "1.9" do
|
12
|
+
it "should return an enumerator without a block" do
|
13
|
+
ds = DateTime.civil(2008, 10, 11)
|
14
|
+
de = DateTime.civil(2008, 9, 29)
|
15
|
+
e = de.step(ds)
|
16
|
+
e.should be_kind_of(Enumerator)
|
17
|
+
count = 0
|
18
|
+
e.each do |d|
|
19
|
+
d.should <= ds
|
20
|
+
d.should >= de
|
21
|
+
count += 1
|
22
|
+
end.should == de
|
23
|
+
count.should == 13
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
5
27
|
it "should be able to step forward in time" do
|
6
28
|
ds = DateTime.civil(2008, 10, 11)
|
7
29
|
de = DateTime.civil(2008, 9, 29)
|
@@ -48,6 +48,11 @@ describe "DateTime.strptime" do
|
|
48
48
|
DateTime.strptime("10 500", '%M %L').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0) + (0.5/86400)
|
49
49
|
end
|
50
50
|
|
51
|
+
it "should be able to parse the number of milliseconds of the second with trailing numbers" do
|
52
|
+
DateTime.strptime("10 0000", '%M %L0').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0)
|
53
|
+
DateTime.strptime("10 50012", '%M %L%m').should == DateTime.civil(@t.year, 12, 1, 0, 10, 0) + (0.5/86400)
|
54
|
+
end
|
55
|
+
|
51
56
|
it "should be able to parse the minute with leading zero" do
|
52
57
|
DateTime.strptime("10", '%M').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0)
|
53
58
|
DateTime.strptime("09", '%M').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 9, 0)
|
@@ -58,6 +63,11 @@ describe "DateTime.strptime" do
|
|
58
63
|
DateTime.strptime("10 500000000", '%M %N').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0) + (0.5/86400)
|
59
64
|
end
|
60
65
|
|
66
|
+
it "should be able to parse the number of nanoseconds of the second with trailing numbers" do
|
67
|
+
DateTime.strptime("10 0000000000", '%M %N0').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0)
|
68
|
+
DateTime.strptime("10 50000000012", '%M %N%m').should == DateTime.civil(@t.year, 12, 1, 0, 10, 0) + (0.5/86400)
|
69
|
+
end
|
70
|
+
|
61
71
|
it "should be able to parse the number of seconds since the unix epoch" do
|
62
72
|
Date.strptime("954979200", "%s").should == Date.civil(2000, 4, 6)
|
63
73
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: home_run
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Jeremy Evans
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-31 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -40,19 +40,23 @@ files:
|
|
40
40
|
- Rakefile
|
41
41
|
- default.mspec
|
42
42
|
- bin/home_run
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
- ext/
|
47
|
-
- ext/date_parser.c
|
48
|
-
- ext/
|
49
|
-
- ext/
|
43
|
+
- lib/date/format.rb
|
44
|
+
- lib/home_run.rb
|
45
|
+
- lib/date.rb
|
46
|
+
- ext/date_ext/date_ext.c
|
47
|
+
- ext/date_ext/date_parser.c
|
48
|
+
- ext/date_ext/datetime.c
|
49
|
+
- ext/date_ext/date_ext.h
|
50
|
+
- ext/date_ext/extconf.rb
|
51
|
+
- ext/date_ext/date_parser.rl
|
52
|
+
- spec/date/limits_spec.rb
|
50
53
|
- spec/date/strptime_spec.rb
|
51
54
|
- spec/date/next_prev_spec.rb
|
52
55
|
- spec/date/downto_spec.rb
|
53
56
|
- spec/date/leap_spec.rb
|
54
57
|
- spec/date/minus_spec.rb
|
55
58
|
- spec/date/minus_month_spec.rb
|
59
|
+
- spec/date/encoding_spec.rb
|
56
60
|
- spec/date/format_spec.rb
|
57
61
|
- spec/date/add_month_spec.rb
|
58
62
|
- spec/date/add_spec.rb
|
@@ -72,16 +76,19 @@ files:
|
|
72
76
|
- spec/date/conversions_spec.rb
|
73
77
|
- spec/date/civil_spec.rb
|
74
78
|
- spec/date/hash_spec.rb
|
79
|
+
- spec/date/allocate_spec.rb
|
75
80
|
- spec/date/constants_spec.rb
|
76
81
|
- spec/date/today_spec.rb
|
77
82
|
- spec/date/ordinal_spec.rb
|
78
83
|
- spec/date/strftime_spec.rb
|
84
|
+
- spec/datetime/limits_spec.rb
|
79
85
|
- spec/datetime/strptime_spec.rb
|
80
86
|
- spec/datetime/next_prev_spec.rb
|
81
87
|
- spec/datetime/downto_spec.rb
|
82
88
|
- spec/datetime/leap_spec.rb
|
83
89
|
- spec/datetime/minus_spec.rb
|
84
90
|
- spec/datetime/minus_month_spec.rb
|
91
|
+
- spec/datetime/encoding_spec.rb
|
85
92
|
- spec/datetime/format_spec.rb
|
86
93
|
- spec/datetime/add_month_spec.rb
|
87
94
|
- spec/datetime/add_spec.rb
|
@@ -99,6 +106,7 @@ files:
|
|
99
106
|
- spec/datetime/succ_spec.rb
|
100
107
|
- spec/datetime/conversions_spec.rb
|
101
108
|
- spec/datetime/hash_spec.rb
|
109
|
+
- spec/datetime/allocate_spec.rb
|
102
110
|
- spec/datetime/strftime_spec.rb
|
103
111
|
- spec/spec_helper.rb
|
104
112
|
- bench/dt_mem_bench.rb
|
@@ -106,8 +114,10 @@ files:
|
|
106
114
|
- bench/cpu_bench.rb
|
107
115
|
- bench/dt_garbage_bench.rb
|
108
116
|
- bench/mem_bench.rb
|
109
|
-
-
|
110
|
-
-
|
117
|
+
- bench/parser_bench.rb
|
118
|
+
- bench/cpu_bench_util.rb
|
119
|
+
- lib/1.8/date_ext.so
|
120
|
+
- lib/1.9/date_ext.so
|
111
121
|
has_rdoc: true
|
112
122
|
homepage: http://github.com/jeremyevans/home_run
|
113
123
|
licenses: []
|
@@ -122,7 +132,7 @@ rdoc_options:
|
|
122
132
|
- --main
|
123
133
|
- README.rdoc
|
124
134
|
require_paths:
|
125
|
-
-
|
135
|
+
- lib
|
126
136
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
137
|
none: false
|
128
138
|
requirements:
|
data/ext/1.8/date_ext.so
DELETED
Binary file
|
data/ext/1.9/date_ext.so
DELETED
Binary file
|