Skip to content

A Ruby gem for generating Nepali Calendar & converting dates between AD to BS.

License

Notifications You must be signed in to change notification settings

TruemarkDev/nepali_calendar

 
 

Repository files navigation

Nepali Calendar

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

Build Status Gem Version Code Climate Test Coverage

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.

Installation

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

Usage

Rails 6.1.0+

Initialize Calendar Object in controller with:

Calendar

@cal = NepaliCalendar::Calendar.new

BSCalendar

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:  })

ADCalendar

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:  })

FiscalYear

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

Contributing

  1. Fork it ( https://github.com/Daanphe/nepali_calendar.git )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Test in console with irb -r nepali_calendar -I ./lib
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

About

A Ruby gem for generating Nepali Calendar & converting dates between AD to BS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 96.2%
  • HTML 3.8%