Permalink
Browse files

Make bi-weekly use 1-15 and 16-end_of_month instead of 1-14 and 15-EOM

Signed-off-by: rick <technoweenie@gmail.com>
  • Loading branch information...
tekkub authored and technoweenie committed Dec 22, 2008
1 parent 5bcc52d commit 8f647f7631e4f195017ea112ee00c78627693e77
Showing with 6 additions and 6 deletions.
  1. +1 −1 lib/can_search/date_range_scope.rb
  2. +5 −5 spec/date_range_scope_spec.rb
@@ -28,7 +28,7 @@ def self.periods() @periods ||= {} end
},
:'bi-weekly' => lambda { |now|
today = now.midnight
- today.day >= 15 ? (today.change(:day => 15)..today.end_of_month) : (today.beginning_of_month..today.change(:day => 15) - 1.second)
+ today.day >= 16 ? (today.change(:day => 16)..today.end_of_month) : (today.beginning_of_month..today.change(:day => 16) - 1.second)
},
:monthly => lambda { |now|
(now.beginning_of_month..now.end_of_month)
@@ -91,15 +91,15 @@ module CanSearch
it "creates weekly range" do
Record.date_range_for(:weekly, Time.utc(2008, 1, 1)).should == (Time.utc(2007, 12, 31)..Time.utc(2008, 1, 7)-1.second)
end
-
+
it "creates bi-weekly range for first half of the month" do
- Record.date_range_for(:'bi-weekly', Time.utc(2008, 1, 5)).should == (Time.utc(2008, 1, 1)..Time.utc(2008, 1, 15)-1.second)
+ Record.date_range_for(:'bi-weekly', Time.utc(2008, 1, 5)).should == (Time.utc(2008, 1, 1)..Time.utc(2008, 1, 16)-1.second)
end
-
+
it "creates bi-weekly range for second half of the month" do
- Record.date_range_for(:'bi-weekly', Time.utc(2008, 1, 16)).should == (Time.utc(2008, 1, 15)..Time.utc(2008, 2, 1)-1.second)
+ Record.date_range_for(:'bi-weekly', Time.utc(2008, 1, 17)).should == (Time.utc(2008, 1, 16)..Time.utc(2008, 2, 1)-1.second)
end
-
+
it "creates monthly range" do
Record.date_range_for(:monthly, Time.utc(2008, 1, 5)).should == (Time.utc(2008, 1, 1)..Time.utc(2008, 2, 1)-1)
end

0 comments on commit 8f647f7

Please sign in to comment.