lib/commercial_weeks.rb in commercial_weeks-0.1.0 vs lib/commercial_weeks.rb in commercial_weeks-0.2.0
- old
+ new
@@ -6,10 +6,12 @@
module CommercialWeeks
def self.week_dates(week_num, year)
week_start = Date.commercial(year, week_num, 1)
week_end = Date.commercial(year, week_num, 7)
+ p week_start
+ p week_end
week_end = Date.new(year).end_of_year if week_end.year > week_start.year
[week_start.strftime('%d %b, %Y'), week_end.strftime('%d %b, %Y')].join(' - ')
end
def self.weeks_count(year)
@@ -47,14 +49,9 @@
current_date = Date.today if current_date.blank?
end_date = current_date.next_year.year == current_date.sunday.year ? current_date.end_of_year : current_date.sunday
end_date = end_date.strftime('%d %b, %Y')
start_date = current_date.strftime('%d %b, %Y')
[start_date, end_date].join(' - ')
- end
-
- def self.selected_week(worklog)
- date = @worklog.date.present? ? @worklog.date : start_date_of_week(Date.today)
- current_week date
end
def self.start_date_of_week(date)
date.year == date.monday.year ? date.monday : date.beginning_of_year
end