This repo is a fork of https://github.com/lalusaud/nepali_calendar/. Since the original repo wasn't being actively maintained, we took the liberty to add/fix functionalities
A Ruby gem for generating Nepali Calendar (Bikram Sambat Calendar). You can also convert dates between BS and AD. Nepali Calendar is based on the API from codeartsnepal.
Add this line to your application's Gemfile:
gem 'nepali_calendar', git: 'https://github.com/Daanphe/nepali_calendar.git', branch: 'master'
And then execute:
$ bundle
Initialize Calendar Object in controller with:
@cal = NepaliCalendar::Calendar.new
To convert date from AD to BS, copy the following code in the view file:
<%= @cal.ad_to_bs('2015', '09', '10') %>
To create new BS date object:
NepaliCalendar::BsCalendar.new(nil, { year: , month: , day: })
To convert date from BS to AD, copy the following code:
<%= @cal.bs_to_ad('2072', '05', '24') %>
To create new AD date object:
NepaliCalendar::AdCalendar.new(nil, { year: , month: , day: })
To get beginning date of the Nepali Fiscal year
NepaliCalendar::FiscalYear.new(@start_year, @end_year).beginning_of_year
To get end date of the Nepali Fiscal year
NepaliCalendar::FiscalYear.new(@start_year, @end_year).end_of_year
To get Nepali Fiscal year from BS date
NepaliCalendar::FiscalYear.fiscal_year_for_bs_date(date_in_bs)
To get Nepali Fiscal year from AD date object
NepaliCalendar::FiscalYear.fiscal_year_in_bs_for_ad_date(date_in_ad)
To get current Nepali Fiscal year
NepaliCalendar::FiscalYear.current_fiscal_year
- Fork it ( https://github.com/Daanphe/nepali_calendar.git )
- Create your feature branch (
git checkout -b my-new-feature
) - Test in console with
irb -r nepali_calendar -I ./lib
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request