A JavaScript Library to get Nanakshahi Dates and Gurpurabs
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Use local date instead of UTC for getHolidaysForMonth Nov 19, 2018
.eslintignore Add Nanakshahi Gurpurabs and Festivals JSON Nov 15, 2018
.eslintrc Add eslint Nov 11, 2018
.gitignore Add webpack build support Nov 11, 2018
.npmignore Add eslint Nov 11, 2018
.release-it.json
.travis.yml Fix Travis Build Nov 11, 2018
LICENSE
README.hbs Fix bikrami year calcluations Nov 18, 2018
README.md Fix bikrami year calcluations Nov 18, 2018
example.js Fix bikrami year calcluations Nov 18, 2018
index.js Add getHolidaysForMonth Nov 18, 2018
package-lock.json
package.json Bump release-it from 7.6.3 to 8.0.0 (#5) Nov 20, 2018
webpack.config.js

README.md

nanakshahi-js

A JavaScript Library to get Nanakshahi Dates and Gurpurabs

npm Travis (.org) GitHub license GitHub issues GitHub pull requests jsdelivr

Contents

Usage

The library can be imported into Node as below:

const { getNanakshahiDate, getHolidaysForMonth, getMovableHoliday, getBikramiDate } = require( 'nanakshahi' )

const date = new Date()

getNanakshahiDate( date )
getHolidaysForMonth( 1 )
getMovableHoliday( 'gurunanak' )
getBikramiDate( date )
getGregorianFromBikrami( 1723, 10, 7 )

Additionally, the package is available for web use via unpkg CDN.

<script src="https://unpkg.com/nanakshahi"></script>

Or via jsDelivr

<script src="https://cdn.jsdelivr.net/npm/nanakshahi/dist/index.min.js"></script>

Want a demo?
Try on RunKit

API

getBikramiDate(gregorianDate) ⇒ Object

Converts given Gregorian Date to the corresponding date in the Bikrami Calendar

Returns: Object - Bikrami Solar and Lunar Date

Param Type Description
gregorianDate Object JavaScript Date() Object

Example

getBikramiDate( new Date() )

getGregorianFromBikrami(year, year, tithi, [paksh]) ⇒ Object

Converts Bikrami Lunar Date into the Gregorian Calendar (Accuracy of plus or minus 1 day)

Returns: Object - Gregorian Date

Param Type Default Description
year number Bikrami Year
year number Bikrami Month
tithi number Bikrami Tithi
[paksh] boolean false Lunar Paksh. Default is Sudi, true for Vadi.

Example

getGregorianFromBikrami( 1723, 10, 7 )

getHolidaysForMonth(month) ⇒ Object

Returns all Gurpurabs and Holidays for a Nanakshahi Month

Returns: Object - Holidays for the month with Date and name in English and Punjabi

Param Type Description
month number Nanakshahi Month, 1-12

Example

getHolidaysForMonth( 1 )

getMovableHoliday(holiday, [year]) ⇒ Object

Returns Gregorian Date of Movable Holiday Movable Holidays List:

  • gurunanak Parkash Guru Nanak Dev Ji
  • bandishhorr Bandi Shhorr Divas / Diwali
  • holla Holla Mahalla
  • kabeer Birthday Bhagat Kabeer Ji
  • ravidaas Birthday Bhagat Ravidaas Ji
  • naamdev Birthday Bhagat Naamdev Ji

Returns: Object - Holiday Date with Name in English and Punjabi

Param Type Description
holiday string Holiday which date will be calculated.
[year] number Gregorian year, default is current year.

Example

getMovableHoliday( 'gurunanak' )

getNanakshahiDate(gregorianDate) ⇒ Object

Converts given Gregorian Date to the corresponding date in the Nanakshahi Calendar

Returns: Object - Nanakshahi Date in English and Punjabi

Param Type Description
gregorianDate Object JavaScript Date() Object

Example

getNanakshahiDate( new Date() )

Contributing

We're happy to accept suggestions and pull requests!

To get started, clone this repo and run npm install inside this directory.

This repository follows the Airbnb's Javascript Style Guide, with a few minor modifications. Notably, spaces should be included inside parentheses and brackets (weird, right!). An ESLint file is provided, and your code will automatically be checked on-commit for style. It is recommended to install an ESLint plugin for your editor (VS Code's ESLint plugin works out of the box), so you can receive linter suggestions as you type.

When writing commit messages, please follow the seven rules. Markdown and HTML JSDoc documentation is generated automatically, on commit, however if you'd like to preview any changes to documentation, npm run build-docs will update README.md. README.md should not be edited, instead apply modifications to README.hbs.

The general workflow for contributing:

  • Fork/create a new branch.
  • Write or update existing tests with expected results
  • Implement functions/changes
  • Add JSDoc function documentation and examples.
  • Run tests with npm test and ensure they all pass. Testing is done with the mocha testing framework.
  • Create a pull request with the changes.