anniversary 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,6 +62,7 @@ class Date
62
62
 
63
63
  if last_monthiversary > initial_date
64
64
  months = (last_monthiversary.month - anniversary_this_year.month)
65
+ months -= 1 unless last_monthiversary.day == initial_date.day
65
66
  months += 12 if months < 0
66
67
  else
67
68
  months = 0
@@ -1,3 +1,3 @@
1
1
  module Anniversary
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -83,21 +83,36 @@ describe "::Date" do
83
83
  end
84
84
 
85
85
  it "should handle the case of March 1, January 31 in the same non leap year" do
86
- Date.civil(2010,3,1).years_months_days_since(Date.civil(2010,1,31)).should == [0, 2, 0]
86
+ Date.civil(2010,3,1).years_months_days_since(Date.civil(2010,1,31)).should == [0, 1, 0]
87
87
  end
88
88
 
89
89
  it "should handle the case of March 1, January 31 in the same leap year" do
90
- Date.civil(2008,3,1).years_months_days_since(Date.civil(2008,1,31)).should == [0, 2, 0]
90
+ Date.civil(2008,3,1).years_months_days_since(Date.civil(2008,1,31)).should == [0, 1, 0]
91
91
  end
92
92
 
93
93
  it "should handle the first case brought up by pit capitan's comment on the blog" do
94
- Date.civil(2010,7,4).years_months_days_since(Date.civil(1970,1,31)).should == [40, 6, 3]
94
+ Date.civil(2010,7,4).years_months_days_since(Date.civil(1970,1,31)).should == [40, 5, 3]
95
95
  end
96
96
 
97
97
  it "should handle the second case brought up by pit capitan's comment on the blog" do
98
98
  Date.civil(2010,7,4).years_months_days_since(Date.civil(1970,2,1)).should == [40, 5, 3]
99
99
  end
100
-
100
+
101
+ it "should count months correctly" do
102
+ Date.civil(2010, 1, 31).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 0, 0]
103
+ Date.civil(2010, 3, 1).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 1, 0]
104
+ Date.civil(2010, 3, 31).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 2, 0]
105
+ Date.civil(2010, 5, 1).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 3, 0]
106
+ Date.civil(2010, 5, 31).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 4, 0]
107
+ Date.civil(2010, 7, 1).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 5, 0]
108
+ Date.civil(2010, 7, 31).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 6, 0]
109
+ Date.civil(2010, 8, 31).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 7, 0]
110
+ Date.civil(2010, 10, 1).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 8, 0]
111
+ Date.civil(2010, 10, 31).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 9, 0]
112
+ Date.civil(2010, 12, 1).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 10, 0]
113
+ Date.civil(2010, 12, 31).years_months_days_since(Date.civil(1970, 1, 31)).should == [40, 11, 0]
114
+ end
115
+
101
116
  test_range( ::Date.civil(2000,6,1), ::Date.civil(2010,8,31))
102
117
  test_range( ::Date.civil(2000, 6, 15), ::Date.civil(2010,8,31))
103
118
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anniversary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0
10
- version: 2.0.0
9
+ - 1
10
+ version: 2.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rick Denatale
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-22 00:00:00 -05:00
18
+ date: 2011-01-29 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency