Module: Recurring

Defined in:
lib/schedule.rb,
lib/date_language.rb

Defined Under Namespace

Classes: DateLanguage, Schedule

Constant Summary collapse

VERSION =
'0.5.1'

Class Method Summary collapse

Class Method Details

.negative_week_in_month(date) ⇒ Object



11
12
13
14
15
# File 'lib/schedule.rb', line 11

def negative_week_in_month date
	end_of_month = (date.month < 12 ? Time.utc(date.year, date.month+1) : Time.utc(date.year + 1)) - 3600
  
  (((end_of_month.day - date.day).to_f / 7.0) + 1).floor * -1
end

.week_in_month(date) ⇒ Object

returns a number starting with 1



7
8
9
# File 'lib/schedule.rb', line 7

def week_in_month date
  (((date.day - 1).to_f / 7.0) + 1).floor
end

.week_of_year(date) ⇒ Object

just a wrapper for strftime



18
19
20
# File 'lib/schedule.rb', line 18

def week_of_year date
	date.strftime('%U').to_i
end