Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
nanakshahi
Advanced tools
A JavaScript library to get Nanakshahi dates and Gurpurabs
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.getGurpurabsForDay( date )
n.getGurpurabsForMonth( 1 )
n.findMovableGurpurab( 'gurunanak' )
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>
This library is based on 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 calendar 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.
Date()
ObjectIn this library, the Date object has been given in the local time of the client. This ensures that the Gregorian date calculated by the functions is correct regardless of timezone.
Converts Nanakshahi Date into the Gregorian Calendar
Returns: Object
- Gregorian Date + Nanakshahi Date in English and Punjabi
Param | Type | Description |
---|---|---|
year | number | Nanakshahi Year |
month | number | Nanakshahi Month, 1-12 |
date | number | Nanakshahi Day |
Example
getDateFromNanakshahi( 550, 10, 23 )
Returns all Gurpurabs for a Date
Returns: Array
- Gurpurabs for the day with Date and name in English and Punjabi
Param | Type | Default | Description |
---|---|---|---|
[gregorianDate] | Object | new Date() | JavaScript Date() Object |
Example
getGurpurabsForDay( new Date() )
Returns all Gurpurabs for a Nanakshahi Month
Returns: Object
- Gurpurabs for the month with Date and name in English and Punjabi
Param | Type | Description |
---|---|---|
month | number | Nanakshahi Month, 1-12 |
[year] | number | Nanakshahi Year. Default is current Nanakshahi Year. |
Example
getGurpurabsForMonth( 1 )
Converts given Gregorian Date to the corresponding date in the Nanakshahi Calendar
Returns: Object
- Nanakshahi Date in English and Punjabi
Param | Type | Default | Description |
---|---|---|---|
[gregorianDate] | Object | new Date() | JavaScript Date() Object |
Example
getNanakshahiDate( new Date() )
Returns Gregorian Date of Movable Gurpurab
Returns: Object
- Gurpurab Date with Name in English and Punjabi
Param | Type | Description |
---|---|---|
gurpurab | string | Movable Gurpurabs:gurunanak - Parkash Guru Nanak Dev Jibandichhorr - Bandi Chhorr Divas / Diwaliholla - Holla Mahallakabeer - Birthday Bhagat Kabeer Jiravidaas - Birthday Bhagat Ravidaas Jinaamdev - Birthday Bhagat Naamdev Ji |
[year] | number | Gregorian year, default is current year. |
Example
findMovableGurpurab( 'gurunanak' )
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 calendar functions, which serve as the base for the movable Gurpurab calculations done in this library.
My father, Jasjit Singh, whose curiosity in the Nanakshahi and Bikrami calendar systems inspired me to find answers to his technical questions.
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 Conventional Commits specification.
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:
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/.
FAQs
A JavaScript Library to get Nanakshahi Dates and Gurpurabs
The npm package nanakshahi receives a total of 14 weekly downloads. As such, nanakshahi popularity was classified as not popular.
We found that nanakshahi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.