1.1.1 • Published 7 months ago

nepali-panchang-utils v1.1.1

Weekly downloads
-
License
MPL-2.0
Repository
-
Last release
7 months ago

nepali-panchang-utils

Its a cool package build to calculate Tithi (Moon), Nakshatra, Karna, Yoga, Raasi (Zodic Sign) and Ayanamsa. It can also be use to predict Masa(Hindu month) and Ritu (season).

Installation 🧱

Via npm:

npm install --save nepali-panchang-utils

Usage 🔌

import { MhahPanchang } from 'nepali-panchang-utils';
// Or if you use CommonJS imports:
// const {MhahPanchang} = require('nepali-panchang-utils')

var obj = new MhahPanchang();

Sample code 📑

const { MhahPanchang } = require('nepali-panchang-utils');

var obj = new MhahPanchang();

// Based current date and time : calculate(date)
var mhahObj = obj.calculate(new Date('2022-02-21T11:34:11.000Z'));
console.log(mhahObj);

// Based regular Hindu Calendar details : calendar(date, latitude, longitude)
let mhahCal = obj.calendar(
  new Date('2022-02-27T05:22:43.984Z'),
  12.972,
  77.594
);
console.log(mhahCal);

Content 📖

Calculate

Here the Panchang calculation is focused on Date and Time taking in consideration the Julian Date, Sun and Moon.

//calculate(date)
//Example
var mhahObj = obj.calculate(new Date('2022-02-21T11:34:11.000Z'));
console.log(mhahObj.Day);

Inputs

ParameterTypeDescription
dateDateDate for which details is needed

Day

Example

console.log(mhahObj.Day);

Output

{ ino: 1, name: 'ସୋମବାର', name_en_UK: 'Monday' }
ParameterTypeDescription
namestringDay in custom language (default: Odia)
name_en_UKstringDay in English (UK)
inonumberIndex no. of Day

Paksha

Example

console.log(mhahObj.Paksha);

Output

{
    ino: 1,
    name: 'କୃଷ୍ଣ',
    name_en_NP: 'Krishna',
    name_en_UK: 'Waning Moon'
}
ParameterTypeDescription
namestringTithi in custom language (default: Odia)
name_en_NPstringTithi in English (India)
name_en_UKstringTithi in English (UK)
inonumberIndex no. of Tithi

Tithi

Example

console.log(mhahObj.Tithi);

Output

{
    name: 'ପଞ୍ଚମୀ',
    name_en_NP: 'Panchami',
    ino: 19,
    start: 2022-02-20T15:35:33.000Z,
    end: 2022-02-21T14:27:50.000Z
}
ParameterTypeDescription
namestringTithi in custom language (default: Odia)
name_en_NPstringTithi in English (India)
inonumberIndex no. of Tithi
startDateStart time of Tithi
endDateend time of Tithi

Nakshatra

Example

console.log(mhahObj.Nakshatra);

Output

{
    name: 'ସ୍ଵାତୀ',
    name_en_NP: 'Swati',
    ino: 14,
    start: 2022-02-21T10:46:30.000Z,
    end: 2022-02-22T10:05:49.000Z
}
ParameterTypeDescription
namestringNakshatra in custom language (default: Odia)
name_en_NPstringNakshatra in English (India)
inonumberIndex no. of Nakshatra
startDateStart time of Nakshatra
endDateend time of Nakshatra

Karna

Example

console.log(mhahObj.Karna);

Output

{
    name: 'ତୈତିଳ',
    name_en_NP: 'Taitula',
    ino: 3,
    start: 2022-02-21T03:03:39.000Z,
    end: 2022-02-21T14:27:50.000Z
}
ParameterTypeDescription
namestringKarna in custom language (default: Odia)
name_en_NPstringKarna in English (India)
inonumberIndex no. of Karna
startDateStart time of Karna
endDateend time of Karna

Yoga

Example

console.log(mhahObj.Yoga);

Output

{
    name: 'ବୃଦ୍ଧି',
    name_en_NP: 'Vridhi',
    ino: 10,
    start: 2022-02-21T07:34:10.000Z,
    end: 2022-02-22T05:20:00.000Z
}
ParameterTypeDescription
namestringYoga in custom language (default: Odia)
name_en_NPstringYoga in English (UK)
inonumberIndex no. of Yoga
startDateStart time of Yoga
endDateend time of Yoga

Ayanamsa

Example

console.log(mhahObj.Ayanamsa);

Output

{ name: `24 9'48"` }

Raasi

Example

console.log(mhahObj.Raasi);

Output

{ name: 'ତୁଳା', ino: 6, name_en_UK: 'Libra' }
ParameterTypeDescription
namestringZodiac sign in custom language (default: Odia)
name_en_UKstringZodiac sign in English (UK)
inonumberIndex no. of Zodiac sign

Julian Date

Example

console.log(mhahObj.Julian);

Output

{ date: 2459632.211111111, day: 2459632 }

Calendar

Here the Panchang calculation is focused on Hindu Calendar.

//calendar(date, latitude, longitude)
// Example
let mhahCal = obj.calendar(
  new Date('2022-02-27T05:22:43.984Z'),
  12.972,
  77.594
);

console.log(mhahCal);

Inputs

ParameterTypeDescription
dateDateDate for which details is needed
latitudenumberLatitude coordinate of Place
longitudenumberLongitude coordinate of Place

Tithi

Example

console.log(mhahCal.Tithi);

Output

{ name: 'ଦ୍ଵାଦଶୀ', name_en_NP: 'Dvadasi', ino: 26 }
ParameterTypeDescription
namestringTithi in custom language (default: Odia)
name_en_NPstringTithi in English (IN)
inonumberIndex no. of Tithi

Paksha

Example

console.log(mhahCal.Paksha);

Output

{
    ino: 1,
    name: 'କୃଷ୍ଣ',
    name_en_NP: 'Krishna',
    name_en_UK: 'Waning Moon'
}
ParameterTypeDescription
namestringPaksha in custom language (default: Odia)
name_en_NPstringPaksha in English (India)
name_en_UKstringPaksha in English (UK)
inonumberIndex no. of Paksha

Nakshatra

Example

console.log(mhahCal.Nakshatra);

Output

{ name: 'ପୂର୍ବଷାଢା', name_en_NP: 'Purva Ashadha', ino: 19 }
ParameterTypeDescription
namestringNakshatra in custom language (default: Odia)
name_en_NPstringNakshatra in English (India)
inonumberIndex no. of Nakshatra

Yoga

Example

console.log(mhahCal.Yoga);

Output

{ name: 'ବ୍ୟତିପାତ', name_en_NP: 'Vyatipata', ino: 16 }
ParameterTypeDescription
namestringYoga in custom language (default: Odia)
name_en_NPstringYoga in English (UK)
inonumberIndex no. of Yoga

Karna

Example

console.log(mhahCal.Karna);

Output

{ name: 'ବାଳବ', name_en_NP: 'Balava', ino: 1 }
ParameterTypeDescription
namestringKarna in custom language (default: Odia)
name_en_NPstringKarna in English (India)
inonumberIndex no. of Karna

Masa

Example

console.log(mhahCal.Masa);

Output

{
    ino: 10,
    name: 'ଫାଲ୍ଗୁନ',
    name_en_UK: 'Phalguna'
}
ParameterTypeDescription
namestringZodiac sign in custom language (default: Odia)
name_en_UKstringZodiac sign in English (UK)
inonumberIndex no. of Zodiac sign

Raasi

Example

console.log(mhahCal.Raasi);

Output

{ ino: 10, name_en_UK: 'Aquarius', name: 'କୁମ୍ଭ' }
ParameterTypeDescription
namestringZodiac sign in custom language (default: Odia)
name_en_UKstringZodiac sign in English (UK)
inonumberIndex no. of Zodiac sign

Ritu

Example

console.log(mhahCal.Ritu);

Output

{ ino: 5, name: 'ବସନ୍ତ', name_en_UK: 'Winter' }
ParameterTypeDescription
namestringZodiac sign in custom language (default: Odia)
name_en_UKstringZodiac sign in English (UK)
inonumberIndex no. of Ritu

Customize Name

Name variable can be customize with users own value.

setMhahConstant

To set custome variable Example

import { MhahPanchang } from 'nepali-panchang-utils';
let obj = new MhahPanchang();
let customArray = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
obj.setMhahConstant('Day', 'name', customArray);
var mhahObj = obj.calculate(new Date('2022-02-21T11:34:11.000Z'));
console.log(mhahObj.Day.name); // Mon

getMhahConstant

To get custome variable after its set or to see default variable Example

import { MhahPanchang } from 'nepali-panchang-utils';
let obj = new MhahPanchang();
console.log(obj.getMhahConstant('Day', 'name'));

Sun and Moon Timer

import { MhahPanchang } from 'nepali-panchang-utils';
let obj = new MhahPanchang();

// Based Day important timing : calendar(date, latitude, longitude)
let mhahCal = obj.sunTimer(
  new Date('2022-02-26T05:22:43.984Z'),
  12.972,
  77.594
);

solarNoon

Time when sun is in the highest position.

Example

console.log(mhahCal.solarNoon).toEqual(new Date('2022-02-26T07:04:04.744Z'));

nadir

Time when darkest moment of the night, sun is in the lowest position.

Example

console.log(mhahCal.nadir).toEqual(new Date('2022-02-25T19:04:04.744Z'));

sunRise

Top edge of the sun appears on the horizon

Example

console.log(mhahCal.sunRise);

sunSet

Sun disappears below the horizon, evening civil twilight starts

Example

console.log(mhahCal.sunSet);

sunRiseEnd

Bottom edge of the sun touches the horizon

Example

console.log(mhahCal.sunRiseEnd);

sunSetStart

Bottom edge of the sun touches the horizon

Example

console.log(mhahCal.sunSetStart);

dawn

Morning nautical twilight ends, morning civil twilight starts

Example

console.log(mhahCal.dawn);

dusk

Evening nautical twilight starts

Example

console.log(mhahCal.dusk);

nauticalDawn

Morning nautical twilight starts

Example

console.log(mhahCal.nauticalDawn);

nauticalDusk

Evening astronomical twilight starts

Example

console.log(mhahCal.nauticalDusk);

nightEnd

Morning astronomical twilight starts

Example

console.log(mhahCal.nightEnd);

night

Dark enough for astronomical observations

Example

console.log(mhahCal.night);

License ⚖️

MPL