Permalink
Browse files

Add missing time_ext file needed for by_weekend test

  • Loading branch information...
1 parent d4290fb commit 23d7010ac1426e0bc68ffb51d82d538b0a993df3 @radar committed Feb 19, 2012
Showing with 23 additions and 0 deletions.
  1. +2 −0 lib/by_star.rb
  2. +21 −0 lib/by_star/time_ext.rb
View
@@ -1,3 +1,5 @@
+require 'by_star/time_ext'
+
require 'by_star/by_year'
require 'by_star/by_month'
require 'by_star/by_fortnight'
View
@@ -0,0 +1,21 @@
+class Time
+ def beginning_of_weekend
+ friday = case self.wday
+ when 0
+ self.end_of_week.beginning_of_day.advance(:days => -2)
+ when 5
+ self.beginning_of_day
+ else
+ self.beginning_of_week.advance(:days => 4)
+ end
+ # 3pm, Friday.
+ (friday + 15.hours)
+ end
+
+ def end_of_weekend
+ # 3am, Monday.
+ # LOL I CHEATED.
+ beginning_of_weekend + 3.days - 12.hours
+ end
+end
+

0 comments on commit 23d7010

Please sign in to comment.