date_ext 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/date_ext.gemspec +1 -1
- data/lib/quarter.rb +2 -2
- data/test/quarter_test.rb +13 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/date_ext.gemspec
CHANGED
data/lib/quarter.rb
CHANGED
@@ -32,8 +32,8 @@ class Quarter
|
|
32
32
|
|
33
33
|
def months; (first_month..last_month).to_a; end
|
34
34
|
|
35
|
-
def first_month; Month.new(@year
|
36
|
-
def last_month; Month.new(@year
|
35
|
+
def first_month; Month.new(@year,((@quarter - 1)*3)+1); end
|
36
|
+
def last_month; Month.new(@year,((@quarter - 1)*3)+3); end
|
37
37
|
|
38
38
|
def dates; (first_date..last_date).to_a; end
|
39
39
|
|
data/test/quarter_test.rb
CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/test_helper'
|
|
2
2
|
|
3
3
|
class QuarterTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
context "Quarter 2009" do
|
5
|
+
context "Quarter 2009,1" do
|
6
6
|
setup {
|
7
7
|
@quarter = Quarter.new(2009,1)
|
8
8
|
}
|
@@ -25,6 +25,18 @@ class QuarterTest < Test::Unit::TestCase
|
|
25
25
|
assert_equal Date.new(2009,3,31), @quarter.last_weekday
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
context "Quarter 2009,1" do
|
30
|
+
setup {
|
31
|
+
@quarter = Quarter.new(2009,4)
|
32
|
+
}
|
33
|
+
should "have 2009-10 as first_month" do
|
34
|
+
assert_equal Month.new(2009,10), @quarter.first_month
|
35
|
+
end
|
36
|
+
should "have 2009-12 as last_month" do
|
37
|
+
assert_equal Month.new(2009,12), @quarter.last_month
|
38
|
+
end
|
39
|
+
end
|
28
40
|
|
29
41
|
context "#new" do
|
30
42
|
should "accept year and quarter as string" do
|