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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rn-nepali-calendar-picker

v0.2.5

Published

Nepali Calendar and Datepicker for React-Native Apps

Readme

rn-nepali-calendar-picker

📅 React Native Nepali Datepicker

rn-nepali-calendar-picker is a React Native library for selecting dates in the Nepali Bikram Sambat (BS) calendar. It provides a date picker component and utilities for BS-AD date conversion.

Using npm:

npm install rn-nepali-calendar-picker

Usage

import { Datepicker, NepaliDate } from 'rn-nepali-calendar-picker';
import { Text, StyleSheet, SafeAreaView, Button } from 'react-native';
import { useState } from 'react';

export default function App() {
  const [nepali_date, setNepaliDate] = useState<NepaliDate>(new NepaliDate());
  const [nepali_dates, setNepaliDates] = useState<NepaliDate[]>([]);

  const [open, setOpen] = useState<boolean>(false);
  const [openMulti, setOpenMulti] = useState<boolean>(false);

  return (
    <SafeAreaView style={styles.screen}>
      <Text>{nepali_date.toFormat('WW,YYYY MMMM DD')}</Text>
      <Text>{nepali_date.ad_date.toDateString()}</Text>
      <Button title="Open Datepicker" onPress={() => setOpen(true)} />
      <Datepicker
        open={open}
        onApply={(date) => setNepaliDate(date)}
        onClose={() => setOpen(false)}
        date={nepali_date}
        mode="single"
        minDate={new NepaliDate()}
      />
      <Text>Multples Dates</Text>
      {nepali_dates?.map((value, index) => (
        <Text key={index}>{value.toString()}</Text>
      ))}
      <Button
        title="Open Multi Datepicker"
        onPress={() => setOpenMulti(true)}
      />
      <Datepicker
        open={openMulti}
        onApply={(dates) => setNepaliDates(dates)}
        onClose={() => setOpenMulti(false)}
        dates={nepali_dates}
        mode="multi"
        minDate={new NepaliDate()}
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  screen: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    paddingVertical: 16,
    gap: 16,
  },
});

⚙️ Props

The <Datepicker /> component accepts the following props:

| Prop Name | Type | Required | Default | Description | | --------- | ------------------------------------------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------ | | open | boolean | ✅ | false | Controls the visibility of the datepicker. Set true to open. | | onApply | (date: NepaliDate\|NepaliDate[]) => void | ✅ | - | Callback function after clicking confirm . This returned Nepali Date Object or array of Nepali Date object based on mode | | onClose | () => void | ✅ | - | Callback function triggered when the datepicker is closed. | | mode | single \| multi \| range | | single | Datepicker mode | | lang | en \| np | | en | lang mode | | date | NepaliDate | | - | Initial selected date in Bikram Sambat (BS) format. | | dates | NepaliDate[] | | [] | Intial selected dates for multi mode | | minDate | NepaliDate | | - | Min Date | | maxDate | NepaliDate | | - | Max Date |

📖 NepaliDate Class

The NepaliDate class helps in creating and managing Nepali (Bikram Sambat) dates. It provides utility methods to convert between BS and AD, format dates, and manipulate them.

import { NepaliDate } from 'rn-nepali-calendar-picker';

const date1 = new NepaliDate(); // Initializes with the current Nepali date
const date2 = new NepaliDate('2080-12-15'); // Initializes using BS date string currently support yyyy-mm-dd only
const date3 = new NepaliDate(2080, 11, 15); // Initializes using year, month, and day

📌 Methods

| Method Name | Return Type | Description | | ------------------------- | ----------------------------------------------- | ------------------------------------------------------------- | | getDay() | number | Returns the day of the week (0 = Sunday, 6 = Saturday). | | getDateObject() | { year: number, month: number, date: number } | Returns an object containing year, month, and day. | | getYear() | number | Returns the BS year. | | setYear(year: number) | void | Sets the BS year. | | getMonth() | number | Returns the BS month (0 = Baisakh, 11 = Chaitra). | | setMonth(month: number) | void | Sets the BS month. | | getDate() | number | Returns the BS date (day of the month). | | setDate(date: number) | void | Sets the BS date. | | toString() | string | Returns the BS date as a formatted string (YYYY-MM-DD). | | toAdString() | string | Returns the corresponding AD date as a string (YYYY-MM-DD). |

USAGE
const nepaliDate = new NepaliDate('2080-12-15');

console.log(nepaliDate.getYear()); // 2080
console.log(nepaliDate.getMonth()); // 11
console.log(nepaliDate.getDate()); // 15
console.log(nepaliDate.toString()); // "2080-12-15"
console.log(nepaliDate.toAdString()); // "2024-03-28"

const jsDate = new Date('2025-02-03');
const convertedNepaliDate = NepaliDate.fromJSDate(jsDate);

console.log(convertedNepaliDate.toString()); // Example: "2081-10-20"

toFormat Method

Formats a Nepali (BS) date into a custom format and supports both English and Nepali languages.

const nepaliDate = new NepaliDate(2080, 11, 15);

console.log(nepaliDate.toFormat());
// Output: "2080-12-15" (default format)

console.log(nepaliDate.toFormat('YYYY MMMM DD', 'en'));
// Output: "2080 Chaitra 15"

console.log(nepaliDate.toFormat('YYYY MMMM DD', 'np'));
// Output: "२०८० चैत्र १५"

📌 Date Format Patterns

| Pattern | Meaning | | ------- | ------------------------------------- | | YYYY | Full BS year (e.g., 2080) | | YY | Last two digits of BS year (e.g., 80) | | MMMM | Full month name (e.g., Baisakh) | | MM | Month number (01-12) | | DD | Day of the month (01-32) | | WW | Full day name (e.g., Sunday) | | W | Short day name (e.g., Sun) |

License

MIT


Made with create-react-native-library