home_run 0.9.0-x86-mswin32-60
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/CHANGELOG +3 -0
- data/LICENSE +19 -0
- data/README.rdoc +314 -0
- data/Rakefile +136 -0
- data/bench/cpu_bench.rb +279 -0
- data/bench/dt_garbage_bench.rb +11 -0
- data/bench/dt_mem_bench.rb +14 -0
- data/bench/garbage_bench.rb +11 -0
- data/bench/mem_bench.rb +14 -0
- data/bin/home_run +91 -0
- data/default.mspec +12 -0
- data/ext/1.8/date_ext.so +0 -0
- data/ext/1.9/date_ext.so +0 -0
- data/ext/date/format.rb +842 -0
- data/ext/date.rb +7 -0
- data/ext/date_ext.c +4548 -0
- data/ext/date_parser.c +367 -0
- data/ext/date_parser.rl +134 -0
- data/ext/datetime.c +2804 -0
- data/ext/extconf.rb +6 -0
- data/spec/date/accessor_spec.rb +176 -0
- data/spec/date/add_month_spec.rb +26 -0
- data/spec/date/add_spec.rb +23 -0
- data/spec/date/boat_spec.rb +38 -0
- data/spec/date/civil_spec.rb +147 -0
- data/spec/date/commercial_spec.rb +153 -0
- data/spec/date/constants_spec.rb +44 -0
- data/spec/date/conversions_spec.rb +246 -0
- data/spec/date/day_spec.rb +73 -0
- data/spec/date/downto_spec.rb +17 -0
- data/spec/date/eql_spec.rb +16 -0
- data/spec/date/format_spec.rb +52 -0
- data/spec/date/gregorian_spec.rb +52 -0
- data/spec/date/hash_spec.rb +11 -0
- data/spec/date/julian_spec.rb +129 -0
- data/spec/date/leap_spec.rb +19 -0
- data/spec/date/minus_month_spec.rb +25 -0
- data/spec/date/minus_spec.rb +51 -0
- data/spec/date/next_prev_spec.rb +108 -0
- data/spec/date/ordinal_spec.rb +83 -0
- data/spec/date/parse_spec.rb +442 -0
- data/spec/date/parsing_spec.rb +77 -0
- data/spec/date/relationship_spec.rb +28 -0
- data/spec/date/step_spec.rb +109 -0
- data/spec/date/strftime_spec.rb +223 -0
- data/spec/date/strptime_spec.rb +201 -0
- data/spec/date/succ_spec.rb +20 -0
- data/spec/date/today_spec.rb +15 -0
- data/spec/date/upto_spec.rb +17 -0
- data/spec/datetime/accessor_spec.rb +218 -0
- data/spec/datetime/add_month_spec.rb +26 -0
- data/spec/datetime/add_spec.rb +36 -0
- data/spec/datetime/boat_spec.rb +43 -0
- data/spec/datetime/constructor_spec.rb +142 -0
- data/spec/datetime/conversions_spec.rb +54 -0
- data/spec/datetime/day_spec.rb +73 -0
- data/spec/datetime/downto_spec.rb +39 -0
- data/spec/datetime/eql_spec.rb +17 -0
- data/spec/datetime/format_spec.rb +59 -0
- data/spec/datetime/hash_spec.rb +11 -0
- data/spec/datetime/leap_spec.rb +19 -0
- data/spec/datetime/minus_month_spec.rb +25 -0
- data/spec/datetime/minus_spec.rb +77 -0
- data/spec/datetime/next_prev_spec.rb +138 -0
- data/spec/datetime/now_spec.rb +18 -0
- data/spec/datetime/parse_spec.rb +390 -0
- data/spec/datetime/parsing_spec.rb +77 -0
- data/spec/datetime/relationship_spec.rb +28 -0
- data/spec/datetime/step_spec.rb +155 -0
- data/spec/datetime/strftime_spec.rb +118 -0
- data/spec/datetime/strptime_spec.rb +117 -0
- data/spec/datetime/succ_spec.rb +24 -0
- data/spec/datetime/upto_spec.rb +39 -0
- data/spec/spec_helper.rb +59 -0
- metadata +154 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "DateTime#strftime" do
|
4
|
+
|
5
|
+
it "should be able to print the date time" do
|
6
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime.should == "2000-04-06T10:11:12+00:00"
|
7
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime.should == DateTime.civil(2000, 4, 6, 10, 11, 12).to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be able to print the hour in a 24 hour clock with leading zero" do
|
11
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%H').should == "10"
|
12
|
+
DateTime.civil(2000, 4, 6, 13, 11, 12).strftime('%H').should == "13"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to print the hour in a 12 hour clock with leading zero" do
|
16
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%I').should == "10"
|
17
|
+
DateTime.civil(2000, 4, 6, 13, 11, 12).strftime('%I').should == "01"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be able to print the hour in a 24 hour clock with leading space" do
|
21
|
+
DateTime.civil(2000, 4, 6, 9, 11, 12).strftime('%k').should == " 9"
|
22
|
+
DateTime.civil(2000, 4, 6, 13, 11, 12).strftime('%k').should == "13"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be able to print the hour in a 12 hour clock with leading space" do
|
26
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%l').should == "10"
|
27
|
+
DateTime.civil(2000, 4, 6, 13, 11, 12).strftime('%l').should == " 1"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to print the number of milliseconds of the second" do
|
31
|
+
DateTime.civil(2008, 11, 12, 14, 3, 30, -8/24.0).strftime('%L').should == "000"
|
32
|
+
(DateTime.civil(2008, 11, 12, 14, 3, 31, 8/24.0) + (0.5/86400)).strftime('%L').should == "500"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to print the minute with leading zero" do
|
36
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%M').should == "11"
|
37
|
+
DateTime.civil(2000, 4, 6, 10, 14, 12).strftime('%M').should == "14"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be able to print the number of nanoseconds of the second" do
|
41
|
+
DateTime.civil(2008, 11, 12, 14, 3, 30, -8/24.0).strftime('%N').should == "000000000"
|
42
|
+
(DateTime.civil(2008, 11, 12, 14, 3, 31, 8/24.0) + (0.5/86400)).strftime('%N').should == "500000000"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be able to print the meridian indicator in lower case" do
|
46
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%P').should == "am"
|
47
|
+
DateTime.civil(2000, 4, 6, 13, 11, 12).strftime('%P').should == "pm"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be able to print the meridian indicator in upper case" do
|
51
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%p').should == "AM"
|
52
|
+
DateTime.civil(2000, 4, 6, 13, 11, 12).strftime('%p').should == "PM"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should be able to print the number of milliseconds since the unix epoch" do
|
56
|
+
DateTime.civil(2008, 11, 12, 14, 3, 30, -8/24.0).strftime('%Q').should == "1226527410000"
|
57
|
+
(DateTime.civil(2008, 11, 12, 14, 3, 31, 8/24.0) + (0.5/86400)).strftime('%Q').should == "1226469811500"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should be able to print the second with leading zero" do
|
61
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%S').should == "12"
|
62
|
+
DateTime.civil(2000, 4, 6, 10, 11, 13).strftime('%S').should == "13"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be able to print the number of seconds since the unix epoch" do
|
66
|
+
DateTime.civil(2008, 11, 12, 14, 3, 30, -8/24.0).strftime('%s').should == "1226527410"
|
67
|
+
DateTime.civil(2008, 11, 12, 14, 3, 31, 8/24.0).strftime('%s').should == "1226469811"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be able to print the time zone offset as a string of hours and minutes" do
|
71
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%z').should == "+0000"
|
72
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, -0.5).strftime('%z').should == "-1200"
|
73
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, 0.5).strftime('%z').should == "+1200"
|
74
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, -1/24.0).strftime('%z').should == "-0100"
|
75
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, 1/24.0).strftime('%z').should == "+0100"
|
76
|
+
|
77
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%Z').should == "+00:00"
|
78
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, -0.5).strftime('%Z').should == "-12:00"
|
79
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, 0.5).strftime('%Z').should == "+12:00"
|
80
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, -1/24.0).strftime('%Z').should == "-01:00"
|
81
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, 1/24.0).strftime('%Z').should == "+01:00"
|
82
|
+
end
|
83
|
+
|
84
|
+
############################
|
85
|
+
# Specs that combine stuff #
|
86
|
+
############################
|
87
|
+
|
88
|
+
it "should be able to print the common date" do
|
89
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime("%c").should == "Thu Apr 6 10:11:12 2000"
|
90
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime("%c").should == DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%a %b %e %H:%M:%S %Y')
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should be able to print the hour and minute" do
|
94
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime("%R").should == "10:11"
|
95
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime("%R").should == DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%H:%M')
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should be able to show the hour, minute, second, and am/pm flag" do
|
99
|
+
DateTime.civil(2000, 4, 9, 10, 11, 12).strftime("%r").should == "10:11:12 AM"
|
100
|
+
DateTime.civil(2000, 4, 9, 13, 11, 12).strftime("%r").should == " 1:11:12 PM"
|
101
|
+
DateTime.civil(2000, 4, 9, 10, 11, 12).strftime("%r").should == DateTime.civil(2000, 4, 9, 10, 11, 12).strftime('%I:%M:%S %p')
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should be able to show the hour, minute, and second" do
|
105
|
+
DateTime.civil(2000, 4, 9, 10, 11, 12).strftime("%T").should == "10:11:12"
|
106
|
+
DateTime.civil(2000, 4, 9, 13, 11, 12).strftime("%T").should == "13:11:12"
|
107
|
+
DateTime.civil(2000, 4, 9, 10, 11, 12).strftime("%T").should == DateTime.civil(2000, 4, 9, 10, 11, 12).strftime('%H:%M:%S')
|
108
|
+
DateTime.civil(2000, 4, 9, 10, 11, 12).strftime("%X").should == "10:11:12"
|
109
|
+
DateTime.civil(2000, 4, 9, 13, 11, 12).strftime("%X").should == "13:11:12"
|
110
|
+
DateTime.civil(2000, 4, 9, 10, 11, 12).strftime("%X").should == DateTime.civil(2000, 4, 9, 10, 11, 12).strftime('%H:%M:%S')
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should be able to print the common date and timezone" do
|
114
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime("%+").should == "Thu Apr 6 10:11:12 +00:00 2000"
|
115
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12, 0.5).strftime("%+").should == "Thu Apr 6 10:11:12 +12:00 2000"
|
116
|
+
DateTime.civil(2000, 4, 6, 10, 11, 12).strftime("%+").should == DateTime.civil(2000, 4, 6, 10, 11, 12).strftime('%a %b %e %H:%M:%S %Z %Y')
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "DateTime.strptime" do
|
4
|
+
before do
|
5
|
+
@t = Time.now
|
6
|
+
end
|
7
|
+
|
8
|
+
it "._strptime should be a hash of values" do
|
9
|
+
DateTime._strptime('2008-10-11T01:00:02+0000').should == {:offset=>0, :zone=>"+0000", :sec=>2, :year=>2008, :hour=>1, :mday=>11, :min=>0, :mon=>10}
|
10
|
+
DateTime._strptime('2008-10-11', '%Y-%m-%d').should == {:year=>2008, :mon=>10, :mday=>11}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have defaults and an optional sg value" do
|
14
|
+
DateTime.strptime('2008-10-11T00:00:00+00:00').should == DateTime.civil(2008, 10, 11)
|
15
|
+
DateTime.strptime('2008-10-11', '%Y-%m-%d').should == DateTime.civil(2008, 10, 11)
|
16
|
+
DateTime.strptime('2008-10-11', '%Y-%m-%d', 1).should == DateTime.civil(2008, 10, 11)
|
17
|
+
DateTime.strptime.should == DateTime.jd
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be able to parse the date time" do
|
21
|
+
DateTime.strptime("2000-04-06T10:11:12+00:00").should == DateTime.civil(2000, 4, 6, 10, 11, 12)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be able to parse the hour in a 24 hour clock with leading zero" do
|
25
|
+
DateTime.strptime("10", '%H').should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 0, 0)
|
26
|
+
DateTime.strptime("09", '%H').should == DateTime.civil(@t.year, @t.mon, @t.day, 9, 0, 0)
|
27
|
+
DateTime.strptime("2000 16", '%Y %H').should == DateTime.civil(2000, 1, 1, 16, 0, 0)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to parse the hour in a 12 hour clock with leading zero with meridian indicator" do
|
31
|
+
DateTime.strptime("10 AM", '%I %p').should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 0, 0)
|
32
|
+
DateTime.strptime("03 04 04 PM", '%m %d %I %p').should == DateTime.civil(@t.year, 3, 4, 16, 0, 0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to parse the hour in a 24 hour clock with leading space" do
|
36
|
+
DateTime.strptime("10", '%k').should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 0, 0)
|
37
|
+
DateTime.strptime(" 9", '%k').should == DateTime.civil(@t.year, @t.mon, @t.day, 9, 0, 0)
|
38
|
+
DateTime.strptime("10 16", '%d %k').should == DateTime.civil(@t.year, @t.mon, 10, 16, 0, 0)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be able to parse the hour in a 12 hour clock with leading space with meridian indicator" do
|
42
|
+
DateTime.strptime("10 am", '%l %P').should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 0, 0)
|
43
|
+
DateTime.strptime(" 4 pm", '%l %P').should == DateTime.civil(@t.year, @t.mon, @t.day, 16, 0, 0)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be able to parse the number of milliseconds of the second" do
|
47
|
+
DateTime.strptime("10 000", '%M %L').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0)
|
48
|
+
DateTime.strptime("10 500", '%M %L').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0) + (0.5/86400)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be able to parse the minute with leading zero" do
|
52
|
+
DateTime.strptime("10", '%M').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0)
|
53
|
+
DateTime.strptime("09", '%M').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 9, 0)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be able to parse the number of nanoseconds of the second" do
|
57
|
+
DateTime.strptime("10 000000000", '%M %N').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0)
|
58
|
+
DateTime.strptime("10 500000000", '%M %N').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 10, 0) + (0.5/86400)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should be able to parse the number of seconds since the unix epoch" do
|
62
|
+
Date.strptime("954979200", "%s").should == Date.civil(2000, 4, 6)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be able to parse the number of milliseconds since the unix epoch" do
|
66
|
+
DateTime.strptime("1226527410000", '%Q').should == DateTime.civil(2008, 11, 12, 22, 3, 30, 0)
|
67
|
+
DateTime.strptime("1226527411000", '%Q').should == DateTime.civil(2008, 11, 12, 22, 3, 31, 0)
|
68
|
+
DateTime.strptime("32511888001500", "%Q").should == DateTime.civil(3000, 4, 6, 0, 0, 1) + (0.5/86400)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should be able to parse the second with leading zero" do
|
72
|
+
DateTime.strptime("10", '%S').should == DateTime.civil(@t.year, @t.mon, @t.day, 0, 0, 10)
|
73
|
+
DateTime.strptime("10 09", '%H %S').should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 0, 9)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should be able to parse the number of seconds since the unix epoch" do
|
77
|
+
DateTime.strptime("1226527410", '%s').should == DateTime.civil(2008, 11, 12, 22, 3, 30, 0)
|
78
|
+
DateTime.strptime("1226527411", '%s').should == DateTime.civil(2008, 11, 12, 22, 3, 31, 0)
|
79
|
+
DateTime.strptime("32511888001", "%s").should == DateTime.civil(3000, 4, 6, 0, 0, 1)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should be able to parse the time zone offset as a string of hours and minutes" do
|
83
|
+
DateTime.strptime("2000 +0000", '%Y %z').offset.should == 0
|
84
|
+
DateTime.strptime("2000 Z", '%Y %z').offset.should == 0
|
85
|
+
DateTime.strptime("2000 -1200", '%Y %z').offset.should == -0.5
|
86
|
+
DateTime.strptime("2000 +1200", '%Y %z').offset.should == 0.5
|
87
|
+
DateTime.strptime("2000 -01:00", '%Y %z').offset.should == -1/24.0
|
88
|
+
DateTime.strptime("2000 +01:00", '%Y %z').offset.should == 1/24.0
|
89
|
+
end
|
90
|
+
|
91
|
+
############################
|
92
|
+
# Specs that combine stuff #
|
93
|
+
############################
|
94
|
+
|
95
|
+
it "should be able to parse the common date" do
|
96
|
+
DateTime.strptime("Thu Apr 6 10:11:12 2000", "%c").should == DateTime.civil(2000, 4, 6, 10, 11, 12)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should be able to parse the hour and minute" do
|
100
|
+
DateTime.strptime("10:11", "%R").should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 11, 0)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should be able to parse the hour, minute, second, and am/pm flag" do
|
104
|
+
DateTime.strptime("10:11:12 AM", "%r").should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 11, 12)
|
105
|
+
DateTime.strptime("01:11:12 PM", "%r").should == DateTime.civil(@t.year, @t.mon, @t.day, 13, 11, 12)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should be able to parse the hour, minute, and second" do
|
109
|
+
DateTime.strptime("10:11:12", "%T").should == DateTime.civil(@t.year, @t.mon, @t.day, 10, 11, 12)
|
110
|
+
DateTime.strptime("01:11:12", "%X").should == DateTime.civil(@t.year, @t.mon, @t.day, 1, 11, 12)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should be able to parse the common date and timezone" do
|
114
|
+
DateTime.strptime("Thu Apr 6 10:11:12 +0000 2000", "%+").should == DateTime.civil(2000, 4, 6, 10, 11, 12)
|
115
|
+
DateTime.strptime("Thu Apr 6 10:11:12 +1200 2000", "%+").should == DateTime.civil(2000, 4, 6, 10, 11, 12, 0.5)
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "DateTime#succ" do
|
4
|
+
it "should be the next day" do
|
5
|
+
ds = DateTime.civil(2008, 10, 11)
|
6
|
+
ds.succ.should == DateTime.civil(2008, 10, 12)
|
7
|
+
ds = DateTime.civil(2008, 10, 31)
|
8
|
+
ds.succ.should == DateTime.civil(2008, 11, 1)
|
9
|
+
ds = DateTime.commercial(2008, 2, 7)
|
10
|
+
ds.succ.should == DateTime.commercial(2008, 3, 1)
|
11
|
+
ds = DateTime.jd(2008)
|
12
|
+
ds.succ.should == DateTime.jd(2009)
|
13
|
+
ds = DateTime.ordinal(2008, 366)
|
14
|
+
ds.succ.should == DateTime.ordinal(2009, 1)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be aliased as next" do
|
18
|
+
DateTime.civil(2008, 10, 11).next.should == DateTime.civil(2008, 10, 12)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should keep the same fractional component" do
|
22
|
+
DateTime.civil(2008, 10, 11, 12, 13, 14).succ.should == DateTime.civil(2008, 10, 12, 12, 13, 14)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "DateTime#upto" do
|
4
|
+
|
5
|
+
it "should be able to step forward in time" do
|
6
|
+
ds = DateTime.civil(2008, 10, 11)
|
7
|
+
de = DateTime.civil(2008, 9, 29)
|
8
|
+
count = 0
|
9
|
+
de.upto(ds) do |d|
|
10
|
+
d.should <= ds
|
11
|
+
d.should >= de
|
12
|
+
count += 1
|
13
|
+
end
|
14
|
+
count.should == 13
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should respect fractional days" do
|
18
|
+
ds = DateTime.civil(2008, 10, 11, 0)
|
19
|
+
de = DateTime.civil(2008, 9, 29, 12)
|
20
|
+
count = 0
|
21
|
+
de.upto(ds) do |d|
|
22
|
+
d.should <= ds
|
23
|
+
d.should >= de
|
24
|
+
count += 1
|
25
|
+
end
|
26
|
+
count.should == 12
|
27
|
+
|
28
|
+
ds = DateTime.civil(2008, 10, 11, 12)
|
29
|
+
de = DateTime.civil(2008, 9, 29, 0)
|
30
|
+
count = 0
|
31
|
+
de.upto(ds) do |d|
|
32
|
+
d.should <= ds
|
33
|
+
d.should >= de
|
34
|
+
count += 1
|
35
|
+
end
|
36
|
+
count.should == 13
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
unless ENV['MSPEC_RUNNER']
|
2
|
+
begin
|
3
|
+
require "pp"
|
4
|
+
require 'mspec/version'
|
5
|
+
require 'mspec/helpers'
|
6
|
+
require 'mspec/guards'
|
7
|
+
require 'mspec/runner/shared'
|
8
|
+
require 'mspec/matchers/be_ancestor_of'
|
9
|
+
require 'mspec/matchers/output'
|
10
|
+
require 'mspec/matchers/output_to_fd'
|
11
|
+
require 'mspec/matchers/complain'
|
12
|
+
require 'mspec/matchers/equal_element'
|
13
|
+
require 'mspec/matchers/equal_utf16'
|
14
|
+
require 'mspec/matchers/match_yaml'
|
15
|
+
require 'mspec/matchers/have_class_variable'
|
16
|
+
require 'mspec/matchers/have_constant'
|
17
|
+
require 'mspec/matchers/have_instance_method'
|
18
|
+
require 'mspec/matchers/have_instance_variable'
|
19
|
+
require 'mspec/matchers/have_method'
|
20
|
+
require 'mspec/matchers/have_private_instance_method'
|
21
|
+
require 'mspec/matchers/have_protected_instance_method'
|
22
|
+
require 'mspec/matchers/have_public_instance_method'
|
23
|
+
|
24
|
+
# Code to setup HOME directory correctly on Windows
|
25
|
+
# This duplicates Ruby 1.9 semantics for defining HOME
|
26
|
+
platform_is :windows do
|
27
|
+
if ENV['HOME']
|
28
|
+
ENV['HOME'] = ENV['HOME'].tr '\\', '/'
|
29
|
+
elsif ENV['HOMEDIR'] && ENV['HOMEDRIVE']
|
30
|
+
ENV['HOME'] = File.join(ENV['HOMEDRIVE'], ENV['HOMEDIR'])
|
31
|
+
elsif ENV['HOMEDIR']
|
32
|
+
ENV['HOME'] = ENV['HOMEDIR']
|
33
|
+
elsif ENV['HOMEDRIVE']
|
34
|
+
ENV['HOME'] = ENV['HOMEDRIVE']
|
35
|
+
elsif ENV['USERPROFILE']
|
36
|
+
ENV['HOME'] = ENV['USERPROFILE']
|
37
|
+
else
|
38
|
+
puts "No suitable HOME environment found. This means that all of"
|
39
|
+
puts "HOME, HOMEDIR, HOMEDRIVE, and USERPROFILE are not set"
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
TOLERANCE = 0.00003 unless Object.const_defined?(:TOLERANCE)
|
45
|
+
rescue LoadError
|
46
|
+
puts "Please install the MSpec gem to run the specs."
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
CODE_LOADING_DIR = File.expand_path "../fixtures/code", __FILE__
|
52
|
+
|
53
|
+
minimum_version = "1.5.17"
|
54
|
+
unless MSpec::VERSION >= minimum_version
|
55
|
+
puts "Please install MSpec version >= #{minimum_version} to run the specs"
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
|
59
|
+
$VERBOSE = nil unless ENV['OUTPUT_WARNINGS']
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: home_run
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 59
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
11
|
+
platform: x86-mswin32-60
|
12
|
+
authors:
|
13
|
+
- Jeremy Evans
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-20 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: |
|
23
|
+
home_run is an implementation of ruby's Date/DateTime classes in C,
|
24
|
+
with much better performance (20-200x) than the version in the
|
25
|
+
standard library, while being almost completely compatible.
|
26
|
+
|
27
|
+
email: code@jeremyevans.net
|
28
|
+
executables:
|
29
|
+
- home_run
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.rdoc
|
34
|
+
- CHANGELOG
|
35
|
+
- LICENSE
|
36
|
+
files:
|
37
|
+
- LICENSE
|
38
|
+
- CHANGELOG
|
39
|
+
- README.rdoc
|
40
|
+
- Rakefile
|
41
|
+
- default.mspec
|
42
|
+
- bin/home_run
|
43
|
+
- ext/date/format.rb
|
44
|
+
- ext/date_ext.c
|
45
|
+
- ext/extconf.rb
|
46
|
+
- ext/date.rb
|
47
|
+
- ext/date_parser.c
|
48
|
+
- ext/date_parser.rl
|
49
|
+
- ext/datetime.c
|
50
|
+
- spec/date/strptime_spec.rb
|
51
|
+
- spec/date/next_prev_spec.rb
|
52
|
+
- spec/date/downto_spec.rb
|
53
|
+
- spec/date/leap_spec.rb
|
54
|
+
- spec/date/minus_spec.rb
|
55
|
+
- spec/date/minus_month_spec.rb
|
56
|
+
- spec/date/format_spec.rb
|
57
|
+
- spec/date/add_month_spec.rb
|
58
|
+
- spec/date/add_spec.rb
|
59
|
+
- spec/date/eql_spec.rb
|
60
|
+
- spec/date/relationship_spec.rb
|
61
|
+
- spec/date/gregorian_spec.rb
|
62
|
+
- spec/date/parse_spec.rb
|
63
|
+
- spec/date/day_spec.rb
|
64
|
+
- spec/date/julian_spec.rb
|
65
|
+
- spec/date/parsing_spec.rb
|
66
|
+
- spec/date/accessor_spec.rb
|
67
|
+
- spec/date/upto_spec.rb
|
68
|
+
- spec/date/step_spec.rb
|
69
|
+
- spec/date/commercial_spec.rb
|
70
|
+
- spec/date/boat_spec.rb
|
71
|
+
- spec/date/succ_spec.rb
|
72
|
+
- spec/date/conversions_spec.rb
|
73
|
+
- spec/date/civil_spec.rb
|
74
|
+
- spec/date/hash_spec.rb
|
75
|
+
- spec/date/constants_spec.rb
|
76
|
+
- spec/date/today_spec.rb
|
77
|
+
- spec/date/ordinal_spec.rb
|
78
|
+
- spec/date/strftime_spec.rb
|
79
|
+
- spec/datetime/strptime_spec.rb
|
80
|
+
- spec/datetime/next_prev_spec.rb
|
81
|
+
- spec/datetime/downto_spec.rb
|
82
|
+
- spec/datetime/leap_spec.rb
|
83
|
+
- spec/datetime/minus_spec.rb
|
84
|
+
- spec/datetime/minus_month_spec.rb
|
85
|
+
- spec/datetime/format_spec.rb
|
86
|
+
- spec/datetime/add_month_spec.rb
|
87
|
+
- spec/datetime/add_spec.rb
|
88
|
+
- spec/datetime/eql_spec.rb
|
89
|
+
- spec/datetime/relationship_spec.rb
|
90
|
+
- spec/datetime/constructor_spec.rb
|
91
|
+
- spec/datetime/now_spec.rb
|
92
|
+
- spec/datetime/parse_spec.rb
|
93
|
+
- spec/datetime/day_spec.rb
|
94
|
+
- spec/datetime/parsing_spec.rb
|
95
|
+
- spec/datetime/accessor_spec.rb
|
96
|
+
- spec/datetime/upto_spec.rb
|
97
|
+
- spec/datetime/step_spec.rb
|
98
|
+
- spec/datetime/boat_spec.rb
|
99
|
+
- spec/datetime/succ_spec.rb
|
100
|
+
- spec/datetime/conversions_spec.rb
|
101
|
+
- spec/datetime/hash_spec.rb
|
102
|
+
- spec/datetime/strftime_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
- bench/dt_mem_bench.rb
|
105
|
+
- bench/garbage_bench.rb
|
106
|
+
- bench/cpu_bench.rb
|
107
|
+
- bench/dt_garbage_bench.rb
|
108
|
+
- bench/mem_bench.rb
|
109
|
+
- ext/1.8/date_ext.so
|
110
|
+
- ext/1.9/date_ext.so
|
111
|
+
has_rdoc: true
|
112
|
+
homepage: http://github.com/jeremyevans/home_run
|
113
|
+
licenses: []
|
114
|
+
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options:
|
117
|
+
- --quiet
|
118
|
+
- --line-numbers
|
119
|
+
- --inline-source
|
120
|
+
- --title
|
121
|
+
- "home_run: Fast Date/DateTime classes for ruby"
|
122
|
+
- --main
|
123
|
+
- README.rdoc
|
124
|
+
require_paths:
|
125
|
+
- ext
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 59
|
132
|
+
segments:
|
133
|
+
- 1
|
134
|
+
- 8
|
135
|
+
- 6
|
136
|
+
version: 1.8.6
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
requirements: []
|
147
|
+
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 1.3.7
|
150
|
+
signing_key:
|
151
|
+
specification_version: 3
|
152
|
+
summary: Fast Date/DateTime classes for ruby
|
153
|
+
test_files: []
|
154
|
+
|