- getDateFromNanakshahi(year, month, date)
- getHolidaysForMonth(month, [year])
- findMovableHoliday(holiday, [year])
- findBikramiFromDate(date, [options])
- findDateFromBikramiLunar(year, month, date, [options])
- findDateFromBikramiSolar(year, month, date, [options])
Install the library via NPM:
npm install nanakshahi
The library can be imported into Node as below:
const n = require('nanakshahi') const date = new Date() n.getNanakshahiDate( date ) n.getDateFromNanakshahi( 550, 10, 23 ) n.getHolidaysForDay( date ) n.getHolidaysForMonth( 1 ) n.findMovableHoliday( 'gurunanak' ) n.findBikramiFromDate( date ) n.findDateFromBikramiLunar( 1723, 10, 7 ) n.findDateFromBikramiSolar( 1723, 9, 23 )
Additionally, the package is available for web use via unpkg CDN.
Or via jsDelivr
This library is based of the Nanakshahi Calendar passed by Sri Akal Takht Sahib in 2003 CE.
All Gurpurabs and Historical dates are reckoned with their Solar Dates. An exception to this are the Movable Lunar dates which are to be reckoned using the Bikrami calender until further Panthic consensus.
The Nanakshahi functions will only calculate dates after Nanakshahi adoption in 2003 CE. Any dates before March 14, 2003 CE (535 NS) will return with an
Out of Range error.
The Bikrami functions in this library were implemented to automatically calculate the Movable dates for the original Nanakshahi Calendar.
The functions are also provided as reference for researchers and historians. No support will be given to anyone attempting to build a calendar from these functions.
The accuracy of the Bikrami calculations match the dates given in Jantri 500 Years by Pal Singh Purewal and this library has been checked personally by Pal Singh Purewal himself.
In this library, the Date object has been given in local time of the client. This ensures that the Gregorian date calculated by the functions are correct regardless of Timezone.
The only exception is when the Date is given in UTC for the Astro Times function, Bikrami Lunar Tithi Start/End times, and Sankranti Moment time.
getDateFromNanakshahi(year, month, date)
Converts Nanakshahi Date into the Gregorian Calendar
Object - Gregorian Date + Nanakshahi Date in English and Punjabi
||Nanakshahi Month, 1-12|
getDateFromNanakshahi( 550, 10, 23 )
Returns all Gurpurabs and Holidays for a Date
Array - Holidays for the day with Date and name in English and Punjabi
getHolidaysForDay( new Date() )
Returns all Gurpurabs and Holidays for a Nanakshahi Month
Object - Holidays for the month with Date and name in English and Punjabi
||Nanakshahi Month, 1-12|
||Nanakshahi Year. Default is current Nanakshahi Year.|
getHolidaysForMonth( 1 )
Converts given Gregorian Date to the corresponding date in the Nanakshahi Calendar
Object - Nanakshahi Date in English and Punjabi
getNanakshahiDate( new Date() )
Returns Gregorian Date of Movable Holiday
Object - Holiday Date with Name in English and Punjabi
||Gregorian year, default is current year.|
findMovableHoliday( 'gurunanak' )
Calculates astronomical times for the Sun and Moon (at Amritsar)
Object - Astronomical values for the Sun and Moon in Universal Time.
calculateAstroTimes( new Date() )
Returns given date to the corresponding date in the Bikrami Calendar
Object - Bikrami (Includes Lunar and Solar Date)
findBikramiFromDate( new Date() )
findDateFromBikramiLunar(year, month, date, [options])
Converts Bikrami Lunar Date into the Gregorian Calendar
Object - Gregorian Date
findDateFromBikramiLunar( 1723, 10, 7 )
findDateFromBikramiSolar(year, month, date, [options])
Converts Bikrami Solar Date into the Gregorian Calendar
Object - Gregorian Date
findDateFromBikramiSolar( 1723, 9, 23 )
I want to thank:
Guru Sahib, who inspires us into Sikhi.
Pal Singh Purewal, who explained various concepts in the Bikrami and Nanakshahi Calendars to me and answered my various technical and historical questions. Spent countless hours verifying the calculations done by me.
E. M. Reingold and N. Dershowitz for their Calendrical Calculations book and their mathematical functions, which serve as the base for the Bikrami calculations done in this library.
My father, Jasjit Singh, whose curiosity in the Nanakshahi and Bikrami calendar systems inspired me find answers to his technical questions.
We're happy to accept suggestions and pull requests!
To get started, clone this repo and run
npm install inside this directory.
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
README.md should not be edited, instead apply modifications to
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.
- Create a pull request with the changes.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, as per version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.