Coder Social home page Coder Social logo

nanakshahi-ruby's Introduction

ਨਾਨਕਸ਼ਾਹੀ (Nanakshahi)

ਨਾਨਕਸ਼ਾਹੀ ਇੱਕ ਰੂਬੀ ਪਰੋਗਰਾਮਿੰਗ ਭਾਸ਼ਾ ਚ ਲਿਖਿਆ ਗਿਆ gem ਹੈ ਜੋ ਕਿ ਪਾਲ ਸਿੰਘ ਪੁਰੇਵਾਲ ਦੁਆਰਾ ਲਿਖੇ ਗਏ ਮੂਲ ਨਾਨਕਸ਼ਾਹੀ ਕਲੰਡਰ ਤੇ ਅਧਾਰਿਤ ਹੈ।

ਇਹ ਆਮ/ਗਰਿਗੋਰੀਅਨ ਕਲੰਡਰ ਦੀਆਂ ਤਰੀਕਾਂ ਤੋਂ ਨਾਨਕਸ਼ਾਹੀ ਤੇ ਵਾਪਸ ਬਦਲਣ ਦੇ ਤਰੀਕੇ ਮੁਹੱੲੀਆ ਕਰਵਾਉਂਦਾ ਹੈ। ਤੁਸੀਂ ਇਸ ਨੂੰ ਕਿਸੇ ਵੀ ਰੂਬੀ ਪਰੋਗਰਾਮ ਵਿੱਚ ਨਾਨਕਸ਼ਾਹੀ ਤਰੀਕਾਂ ਵਰਤਣ ਲੲੀ ਵਰਤ ਸਕਦੇ ਹੋ।

Nanakshahi is a ruby gem for Nanakshahi Calendar based on the original work by Pal Singh Purewal.

It provides helper methods to convert a Gregorian or Common Era(CE) date into Nanakshahi date and vice versa. You can use it to enable Nankshahi dates in any of your applications.

Installation

Add this line to your application's Gemfile:

gem 'nanakshahi'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nanakshahi

Usage

To start using Nanakshahi gem

require 'nanakshahi'

Create a Nanakshahi date object

date = Nanakshahi.new # Creates an object with 1 Chet, Nanakshahi
date = Nanakshahi.new(550)
date = Nanakshahi.new(550, 10)
date = Nanakshahi.new(550, 10, 5)

Using common calendar/gregorian date

date = Nanakshahi.from_gregorian(2019,1,8)

Nanakshahi date today

date = Nanakshahi.today

Is it a gurpurab?

Nanakshahi.new(550,1,1).gurpurab?

What Gurpurabs fall on this day?

Nanakshahi.new(550,1,1).gurpurabs

Converting date object to Nanakshahi

Nankshahi gem monkey-patches Date class to provide it to_nanakshahi method

date = Date.new(2019-2-18)
p date.to_nanakshahi

Printing Nanakshahi date

to_s method prints Nanakshahi date either Nanakshahi or Dhundkaal suffix (pre-Guru Nanak). To take care of 0 year correction, like gregorian, it is assumed that 1 Dhundkaal precedes 1 Nanakshahi when printed with suffix.

date = Nanakshahi.new(1400-2-18)
puts date

To Gurmukhi

to_gurmukhi prints the date in Gurmukhi characters, complete with Gurmukhi numerals.

date = Nanakshahi.new(1400-2-18)
puts date.to_gurmukhi

For a complete list of all the methods, check out the documentation.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/punjab/nanakshahi.

License

The gem is available as open source under the terms of the MIT License.

nanakshahi-ruby's People

Contributors

punjab avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.