Sha256: 20bfc71fc17ad51378d0a6bfbf583d743d9b1509a06df0544d1391b4f20d3c52

Contents?: true

Size: 411 Bytes

Versions: 10

Compression:

Stored size: 411 Bytes

Contents

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
by_star-0.6.3 lib/time_ext.rb
by_star-0.6.2 lib/time_ext.rb
by_star-0.6.1 lib/time_ext.rb
by_star-0.6.0 lib/time_ext.rb
by_star-0.5.2 lib/time_ext.rb
by_star-0.5.1 lib/time_ext.rb
by_star-0.5.0 lib/time_ext.rb
by_star-0.4.0 lib/time_ext.rb
by_star-0.3.1 lib/time_ext.rb
by_star-0.3.0 lib/time_ext.rb