Class: Miti::AdToBs
- Inherits:
-
Object
- Object
- Miti::AdToBs
- Defined in:
- lib/miti/ad_to_bs.rb
Overview
class to handle the algorithm for converting AD to BS
Instance Method Summary collapse
-
#convert ⇒ Miti::NepaliDate
Converts the @english_date to nepali date.
-
#initialize(english_date) ⇒ AdToBs
constructor
Initializes a AdToBs object.
Constructor Details
#initialize(english_date) ⇒ AdToBs
Initializes a AdToBs object
9 10 11 |
# File 'lib/miti/ad_to_bs.rb', line 9 def initialize(english_date) @english_date = english_date end |
Instance Method Details
#convert ⇒ Miti::NepaliDate
Converts the @english_date to nepali date
17 18 19 20 21 22 23 24 |
# File 'lib/miti/ad_to_bs.rb', line 17 def convert year, month, day = nepali_date_for_new_year # Jan 1 can be poush 16, 17 or 18. The gatey obtained has to be subtracted because # days in month is added in days calculation and jan 1 is in mid poush. day_count_from_poush1 = 1 - day nepali_date = corresponding_nepali_date(year, month - 1, day_count_from_poush1) Miti::NepaliDate.new(**nepali_date) end |