Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/by_star/time_ext.rb

Instance Method Summary collapse

Instance Method Details

#beginning_of_weekendObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/by_star/time_ext.rb', line 2

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

#end_of_weekendObject



15
16
17
18
19
# File 'lib/by_star/time_ext.rb', line 15

def end_of_weekend
  # 3am, Monday.
  # LOL I CHEATED.
  beginning_of_weekend + 3.days - 12.hours
end