npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hnw/date-tibetan

v1.0.2

Published

Tibetan Calendar

Readme

@hnw/date-tibetan

NPM version License GitHub issues GitHub stars

A JavaScript library for Tibetan calendar (Phugpa system), Mongolian calendar, and Bhutanese calendar calculations, including conversions to and from the Gregorian calendar and Julian Day.

The algorithms and formulas used in this program are primarily based on the work "Tibetan calendar mathematics" by Svante Janson.

Reference:

This library covers the Phugpa version of the Tibetan calendar as detailed in the paper and includes variations for Mongolian and Bhutanese calendars, which are derived from similar calendrical principles. Users of this code are encouraged to consult the aforementioned paper for a detailed understanding of the underlying mathematics and astronomical models.

Features

  • Tibetan calendar (Phugpa system) date calculations
  • Mongolian calendar date calculations
  • Bhutanese calendar date calculations
  • Conversion from Tibetan, Mongolian, and Bhutanese calendars to Gregorian calendar
  • Conversion from Gregorian calendar to Tibetan, Mongolian, and Bhutanese calendars
  • Mutual conversion with Julian Day
  • Handling of leap months and leap days
  • Provided in ES Module and CommonJS formats

Installation

npm install @hnw/date-tibetan

Usage

ES Module

import { CalendarTibetan, CalendarMongolian, CalendarBhutanese } from '@hnw/date-tibetan';

// --- Tibetan Calendar Example ---
// Set a Tibetan date: 17th Rabjung cycle, 38th year, 1st month, not a leap month, 15th day, not a leap day
const tibetanDate = new CalendarTibetan(17, 38, 1, false, 15, false);
console.log('Tibetan Date Object:', tibetanDate);
console.log('Tibetan Date (Array):', tibetanDate.get()); // [17, 38, 1, false, 15, false]

// Convert to Gregorian calendar
const gregorianFromTibetan = tibetanDate.toGregorian();
console.log('Gregorian from Tibetan:', gregorianFromTibetan); // Example: { year: 2024, month: 2, day: 24 } (actual values depend on the specific date and calendar rules)

// Convert to JavaScript Date object
const dateFromTibetan = tibetanDate.toDate();
console.log('Date object from Tibetan:', dateFromTibetan);

// Convert to Julian Day Number
const jdnFromTibetan = tibetanDate.toJDN();
console.log('JDN from Tibetan:', jdnFromTibetan);


// Convert from Gregorian to Tibetan
const tibetanFromGregorian = new CalendarTibetan().fromGregorian(2024, 2, 10); // February 10, 2024
console.log('Tibetan from Gregorian (Array):', tibetanFromGregorian.get());

// Convert from JavaScript Date object to Tibetan
const jsDate = new Date(2024, 1, 10); // Month is 0-indexed, so 1 means February
const tibetanFromJsDate = new CalendarTibetan().fromDate(jsDate);
console.log('Tibetan from JS Date (Array):', tibetanFromJsDate.get());

// Convert from Julian Date to Tibetan
const tibetanFromJd = new CalendarTibetan().fromJD(2460350.5); // Example: JD 2460350.5 (corresponds to 2024-02-10 noon UTC)
console.log('Tibetan from JD (Array):', tibetanFromJd.get());


// --- Mongolian Calendar Example ---
const mongolianDate = new CalendarMongolian(17, 38, 1, false, 15, false);
console.log('Mongolian Date (Array):', mongolianDate.get());
const gregorianFromMongolian = mongolianDate.toGregorian();
console.log('Gregorian from Mongolian:', gregorianFromMongolian);

// --- Bhutanese Calendar Example ---
const bhutaneseDate = new CalendarBhutanese(17, 38, 1, false, 15, false);
console.log('Bhutanese Date (Array):', bhutaneseDate.get());
const gregorianFromBhutanese = bhutaneseDate.toGregorian();
console.log('Gregorian from Bhutanese:', gregorianFromBhutanese);

CommonJS

const { CalendarTibetan, CalendarMongolian, CalendarBhutanese } = require('@hnw/date-tibetan');

// --- Tibetan Calendar Example ---
// Set a Tibetan date: 17th Rabjung cycle, 38th year, 1st month, not a leap month, 15th day, not a leap day
const tibetanDate = new CalendarTibetan(17, 38, 1, false, 15, false);
console.log('Tibetan Date Object:', tibetanDate);
console.log('Tibetan Date (Array):', tibetanDate.get()); // [17, 38, 1, false, 15, false]

// Convert to Gregorian calendar
const gregorianFromTibetan = tibetanDate.toGregorian();
console.log('Gregorian from Tibetan:', gregorianFromTibetan);

// Convert to JavaScript Date object
const dateFromTibetan = tibetanDate.toDate();
console.log('Date object from Tibetan:', dateFromTibetan);

// Convert to Julian Day Number
const jdnFromTibetan = tibetanDate.toJDN();
console.log('JDN from Tibetan:', jdnFromTibetan);


// Convert from Gregorian to Tibetan
const tibetanFromGregorian = new CalendarTibetan().fromGregorian(2024, 2, 10); // February 10, 2024
console.log('Tibetan from Gregorian (Array):', tibetanFromGregorian.get());

// Convert from JavaScript Date object to Tibetan
const jsDate = new Date(2024, 1, 10); // Month is 0-indexed, so 1 means February
const tibetanFromJsDate = new CalendarTibetan().fromDate(jsDate);
console.log('Tibetan from JS Date (Array):', tibetanFromJsDate.get());

// Convert from Julian Date to Tibetan
const tibetanFromJd = new CalendarTibetan().fromJD(2460350.5); // Example: JD 2460350.5 (corresponds to 2024-02-10 noon UTC)
console.log('Tibetan from JD (Array):', tibetanFromJd.get());


// --- Mongolian Calendar Example ---
const mongolianDate = new CalendarMongolian(17, 38, 1, false, 15, false);
console.log('Mongolian Date (Array):', mongolianDate.get());
const gregorianFromMongolian = mongolianDate.toGregorian();
console.log('Gregorian from Mongolian:', gregorianFromMongolian);

// --- Bhutanese Calendar Example ---
const bhutaneseDate = new CalendarBhutanese(17, 38, 1, false, 15, false);
console.log('Bhutanese Date (Array):', bhutaneseDate.get());
const gregorianFromBhutanese = bhutaneseDate.toGregorian();
console.log('Gregorian from Bhutanese:', gregorianFromBhutanese);

API

CalendarTibetan(cycle, year, month, leapMonth, day, leapDay)

CalendarMongolian(cycle, year, month, leapMonth, day, leapDay)

CalendarBhutanese(cycle, year, month, leapMonth, day, leapDay)

Constructors for each calendar system. Arguments can be passed individually, as an array [cycle, year, month, leapMonth, day, leapDay], or as a CalendarTibetan (or respective) instance.

  • cycle (Number): The 60-year Tibetan cycle (Rabjung). The first Rabjung cycle conventionally started in AD 1027. Example: 17 for the 17th Rabjung cycle.
  • year (Number): The year within the cycle (1 to 60).
  • month (Number): The month (1 to 12).
  • leapMonth (Boolean): true if it's a leap month.
  • day (Number): The day (1 to 30).
  • leapDay (Boolean): true if it's a leap day (a repeated day).

set(cycle, year, month, leapMonth, day, leapDay)

Sets a new date for the calendar object. Argument format is the same as the constructor.

  • Returns: this (the calendar object itself).

get()

Returns the currently set date components as an array.

  • Returns: Array<Number|Boolean> - [cycle, year, month, leapMonth, day, leapDay]

fromGregorian(year, month, day)

Sets the calendar object's date from a Gregorian calendar date. The input date is assumed to be for the local civil day.

  • year (Number): Gregorian year.
  • month (Number): Gregorian month (1 to 12).
  • day (Number): Gregorian day.
  • Returns: this (the calendar object itself).

fromDate(date)

Sets the calendar object's date from a JavaScript Date object.

  • date (Date): JavaScript Date object.
  • Returns: this (the calendar object itself).

fromJD(jd)

Sets the calendar object's date from a Julian Date. The Julian Date typically represents a specific moment, often UTC noon for a given date, or can include time.

  • jd (Number): Julian Date.
  • Returns: this (the calendar object itself).

toGregorian()

Converts the calendar object's date to a Gregorian calendar date.

  • Returns: Object - { year: Number, month: Number, day: Number } representing the Gregorian date.

toDate()

Converts the calendar object's date to a JavaScript Date object. The resulting Date object represents the start of the Tibetan day in the local timezone of the JavaScript runtime.

  • Returns: Date

toJDN()

Converts the calendar object's date to a Julian Day Number. This JDN typically represents the integer day count for the start of the local Tibetan calendar day.

  • Returns: Number (Julian Day Number).

Dependencies

  • astronomia: Used for conversions between Gregorian calendar and Julian Day.

License

MIT License - Copyright (c) hnw Please see the LICENSE file for details.