module Interage::DateTimeHelper

Public Instance Methods

business_day?(date) click to toggle source
# File lib/interage/date_time_helper.rb, line 13
def business_day?(date)
  Holidays.on(date, :br).empty? && date.to_date.workday?
end
business_days_from_now(days = 2) click to toggle source
# File lib/interage/date_time_helper.rb, line 5
def business_days_from_now(days = 2)
  date = days.to_i.business_days.from_now.to_date

  return l(date) if business_day?(date)

  business_days_from_now(days + 1)
end
current_day() click to toggle source
# File lib/interage/date_time_helper.rb, line 43
def current_day
  Date.current.day
end
current_day_name() click to toggle source
# File lib/interage/date_time_helper.rb, line 39
def current_day_name
  l(Date.current, format: '%A')
end
current_month() click to toggle source
# File lib/interage/date_time_helper.rb, line 51
def current_month
  Date.current.strftime('%b')
end
current_month_name() click to toggle source
# File lib/interage/date_time_helper.rb, line 31
def current_month_name
  month_name(Date.current)
end
current_month_year() click to toggle source
# File lib/interage/date_time_helper.rb, line 47
def current_month_year
  "#{current_month} / #{current_year}"
end
current_year() click to toggle source
# File lib/interage/date_time_helper.rb, line 55
def current_year
  Date.current.year
end
format_date(date, date_format = :date_time) click to toggle source
# File lib/interage/date_time_helper.rb, line 17
def format_date(date, date_format = :date_time)
  return if date.blank?

  l(date, format: date_format)
end
format_datetime(date, date_format = '%d/%m/%Y %H:%M') click to toggle source
# File lib/interage/date_time_helper.rb, line 27
def format_datetime(date, date_format = '%d/%m/%Y %H:%M')
  format_date(date, date_format)
end
format_time(time) click to toggle source
# File lib/interage/date_time_helper.rb, line 23
def format_time(time)
  time.strftime('%H:%M') if time.present?
end
month_name(date) click to toggle source
# File lib/interage/date_time_helper.rb, line 35
def month_name(date)
  date.to_date.strftime('%b')
end