class NepaliDateConverter::Calendar

Constants

BS_CALENDAR
NEPALI_MONTHS

Public Class Methods

get_day_of_week(idx) click to toggle source

Return english day of week

Example:

get_day_of_week(1) # => Sunday
get_day_of_week(2) # => Monday
# File lib/nepali_date_converter/calendar.rb, line 109
def get_day_of_week(idx)
  Date::DAYNAMES[idx-1]
end
get_english_month(idx) click to toggle source

Return english month name

Example:

get_english_month(1) # => January
get_english_month(12) # => December
# File lib/nepali_date_converter/calendar.rb, line 120
def get_english_month(idx)
  Date::MONTHNAMES[idx]
end
get_nepali_month(idx) click to toggle source

Return nepali month name

Example:

get_nepali_month(1)    # => Baishakh
get_nepali_month(2)    # => Jestha
# File lib/nepali_date_converter/calendar.rb, line 131
def get_nepali_month(idx)
  NepaliDateConverter::Calendar::NEPALI_MONTHS[idx-1]
end
is_leap_year?(year) click to toggle source

Check if given year is leap year

# File lib/nepali_date_converter/calendar.rb, line 157
def is_leap_year?(year)
  # Date.leap?(year)
  if year % 100 == 0
    if year % 400 == 0
      return true
    else
      return false
    end
  else
    if year % 4 == 0
      return true
    else
      return false
    end
  end
end
valid_english_date?(year, month, day) click to toggle source

Check if date range is in english date

is_in_range_eng(1944, 12, 31)  # => true
# File lib/nepali_date_converter/calendar.rb, line 139
def valid_english_date?(year, month, day)
  raise 'Supported only between 1944-2033' unless (1944..2033).include?(year)
  raise 'Invalid month range' unless (1..12).include?(month)
  raise 'Invalid day range' unless (1..31).include?(day)
  true
end
valid_nepali_date?(year, month, day) click to toggle source

check if date range is in nepali date

# File lib/nepali_date_converter/calendar.rb, line 148
def valid_nepali_date?(year, month, day)
  raise 'Supported only between 2000-2089' unless (2000..2089).include?(year)
  raise 'Invalid month range' unless (1..12).include?(month)
  raise 'Invalid day range' unless (1..32).include?(day)
  true
end