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

@dixxanta08/nepali-date-utils

v1.0.0

Published

A collection of utility functions for Nepali localization, including date conversions (Bikram Sambat ↔ Gregorian), number formatting in Nepali and English, regional data (districts, zones), and general Nepali helpers.

Readme

nepali-utils

A comprehensive collection of utility functions for Nepali localization, focusing on date conversions between Bikram Sambat (BS) and Gregorian (AD), date formatting, and Nepali calendar utilities.

Installation

npm install nepali-utils

Usage

const dateUtils = require("@dixxanta08/nepali-date-utils");

// Example: Convert BS to AD
dateUtils.convertBSToAD("2082-04-16");
// { ad: '2025-06-30', weekdayEn: 'Monday', weekdayNp: 'सोमवार' }

API Reference

1. convertBSToAD(bsDate)

Converts a BS date string to AD date string with weekday info.

  • Parameters:
    • bsDate (string): BS date in 'YYYY-MM-DD' format.
  • Returns: { ad: string, weekdayEn: string, weekdayNp: string }
  • Example:
    convertBSToAD("2082-04-16");
    // { ad: '2025-06-30', weekdayEn: 'Monday', weekdayNp: 'सोमवार' }

2. convertADToBS(adDate)

Converts an AD date string to BS date string with weekday info.

  • Parameters:
    • adDate (string): AD date in 'YYYY-MM-DD' format.
  • Returns: { bs: string, weekdayEn: string, weekdayNp: string }
  • Example:
    convertADToBS("2025-06-30");
    // { bs: '2082-04-16', weekdayEn: 'Monday', weekdayNp: 'सोमवार' }

3. isValidBSDate(bsDate)

Checks if a BS date string is valid.

  • Parameters:
    • bsDate (string): BS date in 'YYYY-MM-DD' format.
  • Returns: boolean
  • Example:
    isValidBSDate("2082-04-16"); // true
    isValidBSDate("2082-13-01"); // false

4. isValidADDate(adDate)

Checks if an AD date string is valid.

  • Parameters:
    • adDate (string): AD date in 'YYYY-MM-DD' format.
  • Returns: boolean
  • Example:
    isValidADDate("2025-06-30"); // true
    isValidADDate("2025-02-30"); // false

5. formatBSDate(bsDate, format = 'YYYY-MM-DD')

Formats a BS date string to a custom format.

  • Parameters:
    • bsDate (string): BS date string 'YYYY-MM-DD'.
    • format (string): Format pattern (default: 'YYYY-MM-DD').
  • Returns: string
  • Example:
    formatBSDate("2082-04-16", "DD/MM/YYYY"); // '16/04/2082'

6. formatADDate(adDate, format = 'YYYY-MM-DD')

Formats an AD date string to a custom format.

  • Parameters:
    • adDate (string): AD date string 'YYYY-MM-DD'.
    • format (string): Format pattern (default: 'YYYY-MM-DD').
  • Returns: string
  • Example:
    formatADDate("2025-06-30", "DD-MM-YYYY"); // '30-06-2025'

7. getWeekday(bsDate, locale = 'np')

Gets the weekday name for a BS date in the specified locale.

  • Parameters:
    • bsDate (string): BS date string 'YYYY-MM-DD'.
    • locale ('np'|'en'): Locale for weekday ('np' for Nepali, 'en' for English).
  • Returns: string
  • Example:
    getWeekday("2082-04-16", "np"); // 'सोमवार'
    getWeekday("2082-04-16", "en"); // 'Monday'

8. getBSMonthName(bsDate, locale = 'np_np')

Gets the month name for a BS date in the specified locale.

  • Parameters:
    • bsDate (string): BS date string 'YYYY-MM-DD'.
    • locale ('np_np'|'en_np'): Locale for month name.
  • Returns: string
  • Example:
    getBSMonthName("2082-04-16", "np_np"); // 'असोज'
    getBSMonthName("2082-04-16", "en_np"); // 'Ashoj'

9. getADMonthName(adDate, locale = 'en_us')

Gets the month name for an AD date in the specified locale.

  • Parameters:
    • adDate (string): AD date string 'YYYY-MM-DD'.
    • locale ('en_us'): Locale for month name.
  • Returns: string
  • Example:
    getADMonthName("2025-03-15", "en_us"); // 'March'

10. addDaysBS(bsDate, days)

Adds days to a BS date and returns the resulting BS date string.

  • Parameters:
    • bsDate (string): BS date string 'YYYY-MM-DD'.
    • days (number): Number of days to add (can be negative).
  • Returns: string
  • Example:
    addDaysBS("2082-04-16", 5); // '2082-04-21'
    addDaysBS("2082-04-16", -3); // '2082-04-13'

11. addMonthsBS(bsDate, months)

Adds months to a BS date and returns the resulting BS date string.

  • Parameters:
    • bsDate (string): BS date string 'YYYY-MM-DD'.
    • months (number): Number of months to add (can be negative).
  • Returns: string
  • Example:
    addMonthsBS("2082-04-16", 2); // '2082-06-16'
    addMonthsBS("2082-04-16", -1); // '2082-03-16'

12. differenceInDaysBS(bsDate1, bsDate2)

Gets the difference in days between two BS dates.

  • Parameters:
    • bsDate1 (string): First BS date string 'YYYY-MM-DD'.
    • bsDate2 (string): Second BS date string 'YYYY-MM-DD'.
  • Returns: number (bsDate2 - bsDate1)
  • Example:
    differenceInDaysBS("2082-04-10", "2082-04-16"); // 6
    differenceInDaysBS("2082-04-16", "2082-04-10"); // -6

13. daysInMonthBS(year, month)

Gets the number of days in a given BS month of a year.

  • Parameters:
    • year (number): BS year.
    • month (number): BS month number (1-12).
  • Returns: number
  • Example:
    daysInMonthBS(2082, 4); // 30

14. getCurrentBSDate()

Gets the current date in BS as a string.

  • Returns: string (Current BS date string 'YYYY-MM-DD')
  • Example:
    getCurrentBSDate(); // e.g., '2082-04-16'

15. bsToAdDateObj(bsDate)

Converts a BS date string to a native JS Date object (AD).

  • Parameters:
    • bsDate (string): BS date string 'YYYY-MM-DD'.
  • Returns: Date
  • Example:
    bsToAdDateObj("2082-04-16"); // Date object for 2025-06-30

16. adToBsString(dateObj)

Converts a native JS Date object (AD) to a BS date string.

  • Parameters:
    • dateObj (Date): JavaScript Date object.
  • Returns: string (BS date string 'YYYY-MM-DD')
  • Example:
    adToBsString(new Date("2025-06-30")); // '2082-04-16'

17. getWeekdays(locale = 'np_np')

Gets an array of weekday names in the specified locale.

  • Parameters:
    • locale ('np_np'|'en_us'): Locale.
  • Returns: string[] (Array of weekday names starting from Sunday)
  • Example:
    getWeekdays("np_np"); // ['आइतबार', 'सोमवार', ...]
    getWeekdays("en_us"); // ['Sunday', 'Monday', ...]

18. getMonths(locale = 'np_np')

Gets an array of month names in the specified locale.

  • Parameters:
    • locale ('np_np'|'en_us'): Locale.
  • Returns: string[] (Array of month names)
  • Example:
    getMonths("np_np"); // ['बैशाख', 'जेठ', ...]
    getMonths("en_us"); // ['Baisakh', 'Jestha', ...]

19. getDayOfYearBS(bsDate)

Gets the day of year for a BS date (1-365/366).

  • Parameters:
    • bsDate (string): BS date string 'YYYY-MM-DD'.
  • Returns: number
  • Example:
    getDayOfYearBS("2082-01-01"); // 1
    getDayOfYearBS("2082-04-16"); // 107

Data Sources

  • data/dateMap.json: Mapping between BS and AD dates.
  • src/data/dateMap.json: Mapping between BS and AD dates.
  • src/data/localeData.json: Locale data for months and weekdays.

License

ISC