Module: Miti

Defined in:
lib/miti.rb,
lib/cli.rb,
lib/miti/version.rb,
lib/miti/ad_to_bs.rb,
lib/miti/bs_to_ad.rb,
lib/miti/nepali_date.rb,
lib/miti/data/date_data.rb

Overview

Base module for the gem

Defined Under Namespace

Modules: Data Classes: AdToBs, BsToAd, CLI, ConversionUnavailableError, Error, NepaliDate

Constant Summary collapse

VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.to_ad(nepali_date) ⇒ <Date>

This method converts the provided nepali date to english date

Parameters:

  • nepali_date (String)

    , refers to date in string format

Returns:

  • (<Date>)

    , refers to the converted english date from nepali date



32
33
34
35
36
37
# File 'lib/miti.rb', line 32

def to_ad(nepali_date)
  validate_date_range(date: nepali_date, conversion: :to_ad)

  date = parse_nepali_date(nepali_date)
  Miti::BsToAd.new(date).convert
end

.to_bs(english_date) ⇒ <Miti::NepaliDate>

This method converts the provided english date to nepali date

Parameters:

  • english_date (String)

    , refers to date in string format

Returns:



19
20
21
22
23
24
25
26
# File 'lib/miti.rb', line 19

def to_bs(english_date)
  validate_date_range(date: english_date, conversion: :to_bs)

  date = parse_english_date(english_date)
  Miti::AdToBs.new(date).convert
rescue Date::Error
  "Invalid Date"
end