module SavanEasyDates

Constants

VERSION

Public Instance Methods

date_in_digit(date, exp) click to toggle source
# File lib/savan_easy_dates.rb, line 12
def date_in_digit(date, exp)
      # 01/02/2015
              date = check_if_date(date)
      if exp
              date.strftime("%m"+exp+"%d"+exp+"%Y")
      else
              date.strftime("%m/%d/%Y")
      end
end
day_abbr_date_month_abbr_full_year(date) click to toggle source
# File lib/savan_easy_dates.rb, line 34
def day_abbr_date_month_abbr_full_year(date)
      # Sat, 3 Jan 2015
      date = check_if_date(date)
      date.strftime("%a, %e %b %Y")
end
day_in_name_month_abbr_year_in_two_digit(date, exp) click to toggle source
# File lib/savan_easy_dates.rb, line 6
def day_in_name_month_abbr_year_in_two_digit(date, exp)
              # Friday, Jan 02
              check_if_date(date)
              date.strftime('%A '+ exp +' %b ' + exp + ' %d')
end
day_name_date_month_abbr_full_year(date) click to toggle source
# File lib/savan_easy_dates.rb, line 40
def day_name_date_month_abbr_full_year(date)
      # Saturday, 03 Jan 2015 5:19 PM
              date = check_if_date(date)
      date.strftime("%A, %d %b %Y %l:%M %p")
end
default_date(dateToFormat, *args) click to toggle source
# File lib/savan_easy_dates.rb, line 64
def default_date(dateToFormat, *args)
  dateToFormat = dateToFormat.to_date.strftime("%Y-%b-%d")
  
  # if args.include?("full_month_name")
  #   formatedDate = dateToFormat.strftime("%Y-%B-%d")
  # end
  # if args.include?("full_year")
  #   formatedDate = formatedDate.to_date.strftime("%Y-%B-%d")
  # end

  return dateToFormat
end
find_days_between_two_dates(start_date, end_date, displayDay) click to toggle source
# File lib/savan_easy_dates.rb, line 46
def find_days_between_two_dates(start_date, end_date, displayDay)
  startDate = start_date.to_date
  getEndDateMonth = end_date.to_date.strftime("%m").to_i
  getEndDateYear = end_date.to_date.strftime("%Y").to_i
  endDate = Date.parse "#{end_date}"
  days = []
  days << 0 if displayDay.include?("sunday")
  days << 1 if displayDay.include?("monday")
  days << 2 if displayDay.include?("tuesday")
  days << 3 if displayDay.include?("wednesday")
  days << 4 if displayDay.include?("thursday")
  days << 5 if displayDay.include?("friday")
  days << 6 if displayDay.include?("saturday")
  puts days
  @result = (startDate..endDate).to_a.select {|k| days.include?(k.wday)}
  puts @result
end
month_abbr_date_full_year(date) click to toggle source
# File lib/savan_easy_dates.rb, line 28
def month_abbr_date_full_year(date)
      # Jan 03, 2015
      date = check_if_date(date)
      date.strftime("%b %d, %Y")
end
month_full_year(date) click to toggle source
# File lib/savan_easy_dates.rb, line 22
def month_full_year(date)
      # January 2015
      date = check_if_date(date)
      date.strftime("%B %Y")
end

Private Instance Methods

check_if_date(date) click to toggle source
# File lib/savan_easy_dates.rb, line 79
  def check_if_date(date)
        @date = date.to_date
end