Sha256: 629360c766a03f59483d6e2b189a8e996718c3c13d5ea773dbca262b9706494d

Contents?: true

Size: 634 Bytes

Versions: 2

Compression:

Stored size: 634 Bytes

Contents

require 'nextday'

def weekdays
  today = Date.today
  
  today += 1 while (today.wday != 1) # step forward until it's monday
  monday = today
  
  # monday, tuesday, wednesday, thursday, friday
  [monday, monday+1, monday+2, monday+3, monday+4]
end

def weekends
  saturdays + sundays
end

def saturdays
  today = Date.today
  
  today += 1 while (today.wday != 6) # step forward until it's saturday
  saturday = today
  
  saturday.step(saturday + 365, 7).to_a
end

def sundays
  today = Date.today
  
  today += 1 while (today.wday != 0) # step forward until it's sunday
  sunday = today
  
  sunday.step(sunday + 365, 7).to_a
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nextday-0.4.0 spec/spec_helper.rb
nextday-0.3.0 spec/spec_helper.rb