Important
Now calculations doesn't follow time adjustments for nepal timezone. finding first day of month may have 1 day off or 1 day more since julian day and ahar(julian apoach) is in Greenwich Mean Time (UTC). thanks @aj3sh for testing those discrepancies. conversation 🔗
ℹ️ Observations after reviewing possible fixes 20250110:
- The ahar value( julian day count) is based on Ujjain timezone. (ancient UTC of astrology).
- Nepal's time zone has not been consistent and has changed over time. To obtain accurate results for past dates, the exact time zone and location, along with the date of the change, are required. https://en.m.wikipedia.org/wiki/Nepal_Standard_Time .
- It is unclear whether calculations for the Bikram Sambat date in Nepal now uses Kathmandu's latitude and longitude or the Nepal Standard Time Zone's reference location.
Understanding the specific location and time zone used is crucial for accurate results. Changes in time and location can affect day or month transitions, potentially causing misalignment with pre-calculated data.
Bikram-js is an npm package for converting Gregorian dates to Bikram Sambat dates, calculating Tithis, and providing various functionalities related to the Bikram Sambat calendar. This package is useful for developers needing accurate Nepali date conversions and Tithi calculations in their applications.
- Root Folder: Contains the source code for the
bikram-js
npm package. - example Folder: Contains an example implementation of a calendar and date converter to demonstrate the use of the
bikram-js
package.
- Convert Gregorian dates to Bikram Sambat dates and vice versa
- Calculate Tithi (lunar day) for a given Gregorian date and longitude
- Retrieve Nepali month and weekday names
You can install the package via npm:
npm install bikram-js
# Or for development purposes:
npm install bikram-js --save-dev
The Bikram
class provides methods for converting between Gregorian and Bikram Sambat dates and retrieving Nepali month and weekday names.
Here are some examples of how to use the bikram-js
package:
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
bikram.fromGregorian(2024, 1, 1);
console.log(bikram.getYear()); // 2080
console.log(bikram.getMonth()); // 9
console.log(bikram.getDay()); // 16
import { Tithi } from 'bikram-js';
const testTithi = new Tithi();
const tithiResult = testTithi.calculateTithi(2024, 1, 1);
console.log(tithiResult.tithi); // "पञ्चमी"
console.log(tithiResult.paksha); // "कृष्ण"
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
const gregorianDate = bikram.toGregorian(2081, 1, 1);
console.log(gregorianDate.year); // 2024
console.log(gregorianDate.month); // 4
console.log(gregorianDate.day); // 13
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
const totalDays = bikram.daysInMonth(2081, 8);
console.log(totalDays); // 30
const totalDaysFebruary = bikram.daysInMonth(2081, 2);
console.log(totalDaysFebruary); // 32
import { Tithi } from 'bikram-js';
const testTithi = new Tithi();
const tithiResult = testTithi.calculateTithi(2020, 2, 29);
console.log(tithiResult.tithi); // "पञ्चमी"
console.log(tithiResult.paksha); // "शुक्ल"
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
console.log(bikram.getWeekdayName(2024, 12, 5)); // 'बिहीबार'
console.log(bikram.getWeekdayName(2024, 12, 6)); // 'शुक्रबार'
console.log(bikram.getWeekdayName(2024, 12, 7)); // 'शनिबार'
console.log(bikram.getWeekdayName(2024, 12, 8)); // 'आइतबार'
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
const gregorianDate = bikram.toGregorian(2081, 8, 20);
const testDay = bikram.getWeekdayName(gregorianDate.year, gregorianDate.month, gregorianDate.day);
console.log(testDay); // "बिहीबार"
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
console.log(bikram.getWeekdayName(2020, 2, 29)); // 'शनिबार'
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
console.log(bikram.getWeekdayName(2024, 1, 1)); // 'सोमबार'
console.log(bikram.getWeekdayName(2024, 12, 31)); // 'मंगलबार'
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
bikram.fromGregorian(2024, 12, 5);
const testMonthName = bikram.getMonthName(bikram.getMonth());
console.log(testMonthName); // 'मंसिर'
import { Bikram } from 'bikram-js';
const bikram = new Bikram();
try {
bikram.getMonthName(0);
} catch (error) {
console.error(error);
}
try {
bikram.getMonthName(13);
} catch (error) {
console.error(error);
}
Detailed documentation of functions are available in the docs/docs
folder or here
. You can find comprehensive guides and examples on using the bikram-js
library.
To view the documentation:
- Navigate to the
docs/docs
folder. - Open the markdown files to read the documentation.
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.
Contributions are welcome! you can fork this repo, create modifications and send pull request.
The Bikram Sambat and Tithi functionalities are implemented using calculations from a port of the Perl script Pancanga library by M. Fushimi and M. Yano. For detailed information, consult the original documentation:
Special thanks to Samar Dhwoj Acharya (techgaun), Kapil Karki (kapil-31), and the Build For Nepal team for their encouragement.
Khumnath CG ([email protected])
Special thanks to all contributors.