module TimeWin::Util
Public Instance Methods
last_month()
click to toggle source
# File lib/time_win/util.rb, line 15 def last_month today = Time.now.to_date y = today.month == 1 ? today.year - 1 : today.year m = today.month == 1 ? 12 : today.month - 1 day_1 = Date.new(y,m,1) Window.new(day_1, day_1 + Date.days_in_month(y, m)) end
last_week()
click to toggle source
# File lib/time_win/util.rb, line 49 def last_week this_week.shift -1.weeks end
next_month()
click to toggle source
# File lib/time_win/util.rb, line 23 def next_month today = Time.now.to_date y = today.month == 12 ? today.year + 1 : today.year m = today.month == 12 ? 1 : today.month + 1 day_1 = Date.new(y,m,1) Window.new(day_1, day_1 + Date.days_in_month(y, m)) end
this_hour()
click to toggle source
# File lib/time_win/util.rb, line 41 def this_hour now = Time.now now_at_0 = now.to_date begining_of_hour = now_at_0.to_time + now.hour.hours begining_of_hour.during(1.hours) end
this_month()
click to toggle source
# File lib/time_win/util.rb, line 9 def this_month today = Time.now.to_date day_1 = Date.new(today.year, today.month) Window.new(day_1, day_1.to_time + Date.days_in_month(today.year, today.month).days) end
this_week()
click to toggle source
# File lib/time_win/util.rb, line 31 def this_week now = Time.now monday = (now - (now.wday - 1).days).to_date.to_time monday.to_time.during(1.weeks) end
this_year()
click to toggle source
# File lib/time_win/util.rb, line 3 def this_year today = Time.now.to_date day_1 = Date.new(today.year, 1, 1) Window.new(day_1, day_1 + Date.days_in_year(today.year)) end
today()
click to toggle source
# File lib/time_win/util.rb, line 37 def today Time.now.to_date.to_time.to(Time.now.to_date + 1) end
tomorrow()
click to toggle source
# File lib/time_win/util.rb, line 57 def tomorrow today.shift 1.days end
yesterday()
click to toggle source
# File lib/time_win/util.rb, line 53 def yesterday today.shift -1.days end