anniversary 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,14 @@ Your age in years, is actually the number of birthdays you have had, or to use a
15
15
 
16
16
  There are complications since some months are shorter than others, so geting this right is a bit tricky. Hence Anniversary
17
17
 
18
+ ## UPDATE
19
+
20
+ Well I said it was tricky. While responding to some comments on my blog article, I realized that monthiversaries (and anniversaries of leap days) should always happen either on the same day in the month (if the month is long enough) or the first of the next month if not. Note that if a month is too short then there will be two monthiversaries in the next month, once on the first, and a second on the actual day.
21
+
22
+ In version 1 of the gem, I had the extra monthiversary in March fall on different days depending on whether or not the age was being calculated for a leap year or not. This new version always places the extra monthiversaries on the first of the next month, see the update to my blog article for the rationale.
23
+
24
+ Because this is a breaking change I've bumped the major version number.
25
+
18
26
  ## Installation
19
27
 
20
28
  gem install anniversary
@@ -22,7 +22,7 @@ class Date
22
22
  days_in_month = 29 if (month == 2) && ((year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0)))
23
23
  if (days_in_month < day)
24
24
  month += 1
25
- day = day - days_in_month
25
+ day = 1
26
26
  end
27
27
  civil(year, month, day)
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module Anniversary
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -12,12 +12,12 @@ describe "::Date" do
12
12
  Date.civil_with_missing_day_correction(2011, 9, 31).should == Date.civil(2011, 10, 1)
13
13
  end
14
14
 
15
- it "should handle a multi-day jump in a leap year" do
16
- Date.civil_with_missing_day_correction(2012, 2, 31).should == Date.civil(2012, 3, 2)
15
+ it "should give March 1, for February '31' in a leap year" do
16
+ Date.civil_with_missing_day_correction(2012, 2, 31).should == Date.civil(2012, 3, 1)
17
17
  end
18
18
 
19
- it "should handle a multi-day jump in a non-leap year" do
20
- Date.civil_with_missing_day_correction(2011, 2, 31).should == Date.civil(2011, 3, 3)
19
+ it "should give March 1, for February '31' in a leap year" do
20
+ Date.civil_with_missing_day_correction(2011, 2, 31).should == Date.civil(2011, 3, 1)
21
21
  end
22
22
  end
23
23
 
@@ -83,11 +83,11 @@ 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, 0, 29]
86
+ Date.civil(2010,3,1).years_months_days_since(Date.civil(2010,1,31)).should == [0, 2, 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, 0, 30]
90
+ Date.civil(2008,3,1).years_months_days_since(Date.civil(2008,1,31)).should == [0, 2, 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
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: 19
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
- - 1
8
- - 0
9
7
  - 2
10
- version: 1.0.2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rick Denatale