# Nepali Date Library > Universal, production-ready multi-language ecosystem for working with Nepali (Bikram Sambat / BS) dates. Supports NodeJS/TypeScript, Python, and PHP with unified APIs, zero dependencies, and annually audited calendar data verified up to the active year. ## Official Resources - Website: https://nepali-pkg.date - Date Converter Suite: https://nepali-pkg.date/converter - Nepali Calendar (Patro): https://nepali-pkg.date/calendar - Full Documentation: https://nepali-pkg.date/docs - Complete AI Reference: https://nepali-pkg.date/llms-full.txt - GitHub Organization: https://github.com/SandipGhimire/Nepali-Date ## Package Ecosystem & Installation - **NodeJS / TypeScript**: `npm install nepali-date-library` (npm: https://www.npmjs.com/package/nepali-date-library, GitHub: https://github.com/SandipGhimire/Nepali-Date-Library-NodeJS) - **Python**: `pip install nepali-date-library` (PyPI: https://pypi.org/project/nepali-date-library/, GitHub: https://github.com/SandipGhimire/Nepali-Date-Library-Python) - **PHP**: `composer require sghimire/nepali-date-library` (Packagist: https://packagist.org/packages/sghimire/nepali-date-library, GitHub: https://github.com/SandipGhimire/Nepali-Date-Library-PHP) ## Core Capabilities - **Bidirectional Date Conversion**: Convert Gregorian (AD) to Bikram Sambat (BS) and Bikram Sambat (BS) to Gregorian (AD). - **Calendar Range & Annual Audits**: Spans 1976/01/01 BS to 2100/12/31 BS (approx 1919-04-13 to 2044-04-12 AD). Dates up to the active year are verified against official Government of Nepal gazettes. Every year in Ashwin (Ashoj), mapping tables are updated with official solar ingress corrections upon release of the new calendar. - **Date Manipulation & Arithmetic**: Add or subtract days, months, and years with automatic edge-case handling for variable Nepali month lengths (29 to 32 days). - **Government of Nepal Fiscal Year**: Native support for Nepali fiscal years (Shrawan 1 to Ashadh end), fiscal quarters (Q1: Shrawan-Ashwin, Q2: Kartik-Poush, Q3: Magh-Chaitra, Q4: Baisakh-Ashadh). - **Formatting & Localization**: Flexible date format tokens (`YYYY-MM-DD`, `DD MMMM YYYY`, `dddd`, etc.) rendered in English and Devanagari numerals and script. - **Date Comparison & Queries**: Check `isBefore`, `isAfter`, `isSame`, `isLeapYear`, `startOfMonth`, `endOfMonth`, `startOfYear`, `endOfYear`. ## Common Search Keywords & Queries - **Date Converter**: Nepali date converter, Bikram Sambat date converter, BS to AD converter, AD to BS converter, English date to Nepali date, convert BS to AD, convert AD to BS. - **Nepali Date & Calendar**: Nepali date, Nepali date library, Bikram Sambat, Bikram Sambat calendar, BS date, BS calendar, Nepali calendar online, Nepali patro, Nepali miti, today Nepali date, aajako Nepali date, aajako miti. - **Calculators & Utilities**: Nepali age calculator, Nepali date difference calculator, Nepali date arithmetic, add days to Nepali date, Bikram Sambat leap year. - **Fiscal Year (Aarthik Barsha)**: Nepal Government fiscal year calculator, Shrawan to Ashadh fiscal year, fiscal quarters (Q1, Q2, Q3, Q4). - **SDKs & Package Managers**: `nepali-date-library` on npm (Node.js/TypeScript), `nepali-date-library` on PyPI (Python), `sghimire/nepali-date-library` on Packagist (PHP). ## Quick Start Code Recipes ### NodeJS / TypeScript ```typescript import { NepaliDate } from "nepali-date-library"; // Current Nepali date const today = new NepaliDate(); console.log(today.format("YYYY-MM-DD")); // e.g. 2081-06-29 // Convert AD to BS const bs = NepaliDate.fromAD(new Date("2024-10-15")); console.log(bs.format("DD MMMM YYYY")); // 29 Ashwin 2081 // Date manipulation bs.addDays(30); // Nepal Fiscal Year console.log(bs.getFiscalYear()); // 2081/82 ``` ### Python ```python from nepali_date_library import NepaliDate from datetime import date # Current Nepali date today = NepaliDate() print(today.format("YYYY-MM-DD")) # Convert AD to BS bs = NepaliDate.from_ad(date(2024, 10, 15)) print(bs.format("DD MMMM YYYY")) # Date manipulation bs.add_days(30) # Nepal Fiscal Year print(bs.get_fiscal_year()) # 2081/82 ``` ### PHP ```php use NepaliDateLibrary\NepaliDate; use DateTime; // Current Nepali date $today = new NepaliDate(); echo $today->format("YYYY-MM-DD"); // Convert AD to BS $bs = NepaliDate::fromAD(new DateTime("2024-10-15")); echo $bs->format("DD MMMM YYYY"); // Date manipulation $bs->addDays(30); // Nepal Fiscal Year echo $bs->getFiscalYear(); // 2081/82 ``` ## Key Documentation Sections - [Origination & Philosophy](https://nepali-pkg.date/docs/origination): Historical background of Bikram Sambat and why this library was built. - [Ecosystem Overview](https://nepali-pkg.date/docs/overview): Cross-platform feature parity across Node, Python, and PHP. - [Multi-Language Installation](https://nepali-pkg.date/docs/installation): Package managers and environment setup. - [Code Examples](https://nepali-pkg.date/docs/examples): Real-world workflows, form integrations, and date math. - [NodeJS Documentation](https://nepali-pkg.date/docs/nodejs): Complete TypeScript API reference and guides. - [Python Documentation](https://nepali-pkg.date/docs/python): Pythonic API reference and datetime interoperability. - [PHP Documentation](https://nepali-pkg.date/docs/php): Composer package reference and DateTime compatibility. - [Online Converter](https://nepali-pkg.date/converter): Interactive web tools for instant conversions and age calculation. - [Nepali Calendar (Patro)](https://nepali-pkg.date/calendar): Interactive Bikram Sambat monthly calendar with dual BS/AD dates. ## Complete Method Directory - [Contribution Guide](https://nepali-pkg.date/docs/contribution): Learn how to contribute to the Nepali Date Library ecosystem across Node.js, Python, PHP, and Documentation. - [Examples & Practical Recipes](https://nepali-pkg.date/docs/examples): Real-world patterns and cross-language code recipes for working with Nepali dates. - [Installation](https://nepali-pkg.date/docs/installation): Install Nepali Date Library in your project using your preferred package manager across Node.js, Python, or PHP. - [Overview (NodeJS)](https://nepali-pkg.date/docs/nodejs): [NodeJS] Complete documentation and feature guide for the Nepali Date Library in Node.js and TypeScript applications. Official API reference and code examples for NodeJS / TypeScript. - [new NepaliDate() (NodeJS)](https://nepali-pkg.date/docs/nodejs/class/constructor): [NodeJS] Constructor overloads and initialization options for creating NepaliDate instances in Node.js and TypeScript. Official API reference and code examples for NodeJS / TypeScript. - [Instance Properties (NodeJS)](https://nepali-pkg.date/docs/nodejs/class/properties): [NodeJS] Reference for public instance properties available on every NepaliDate object including year, month, day, and underlying timestamp. Official API reference and code examples for NodeJS / TypeScript. - [MONTH_EN (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/month-en): [NodeJS] Array containing standard romanized English names of all twelve Bikram Sambat calendar months. Official API reference and code examples for NodeJS / TypeScript. - [MONTH_NP (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/month-np): [NodeJS] Array containing official Devanagari Nepali names of all twelve Bikram Sambat calendar months. Official API reference and code examples for NodeJS / TypeScript. - [MONTH_SHORT_EN (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/month-short-en): [NodeJS] Array containing three letter abbreviated English names for all twelve Bikram Sambat months. Official API reference and code examples for NodeJS / TypeScript. - [MONTH_SHORT_NP (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/month-short-np): [NodeJS] Array containing abbreviated Devanagari Nepali names for all twelve Bikram Sambat calendar months. Official API reference and code examples for NodeJS / TypeScript. - [NEPALI_DATE_MAP (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/nepali-date-map): [NodeJS] Historical calendar mapping table storing verified day counts for every Bikram Sambat month between 1976 and 2100 BS. Official API reference and code examples for NodeJS / TypeScript. - [NUMBER_NP (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/number-np): [NodeJS] Array containing Devanagari numeral glyphs for digits zero through nine used for Nepali number localization. Official API reference and code examples for NodeJS / TypeScript. - [WEEK_EN (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/week-en): [NodeJS] Array containing full English names for all seven days of the week starting from Sunday. Official API reference and code examples for NodeJS / TypeScript. - [WEEK_NP (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/week-np): [NodeJS] Array containing full Devanagari Nepali names for all seven days of the week starting from Sunday. Official API reference and code examples for NodeJS / TypeScript. - [WEEK_SHORT_EN (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/week-short-en): [NodeJS] Array containing abbreviated English weekday names ordered from Sunday through Saturday. Official API reference and code examples for NodeJS / TypeScript. - [WEEK_SHORT_NP (NodeJS)](https://nepali-pkg.date/docs/nodejs/constants/week-short-np): [NodeJS] Array containing short Devanagari abbreviations for each day of the week starting from Sunday. Official API reference and code examples for NodeJS / TypeScript. - [Date Converter Guide (NodeJS)](https://nepali-pkg.date/docs/nodejs/date-converter): [NodeJS] Comprehensive guide to converting dates between Gregorian and Bikram Sambat calendar systems using standalone helper functions. Official API reference and code examples for NodeJS / TypeScript. - [ADtoBS() (NodeJS)](https://nepali-pkg.date/docs/nodejs/date-converter/ad-to-bs): [NodeJS] Pure helper function to convert Gregorian calendar date strings into Bikram Sambat date strings. Official API reference and code examples for NodeJS / TypeScript. - [BStoAD() (NodeJS)](https://nepali-pkg.date/docs/nodejs/date-converter/bs-to-ad): [NodeJS] Pure helper function to convert Bikram Sambat date strings into Gregorian calendar date strings. Official API reference and code examples for NodeJS / TypeScript. - [Fiscal Year & Quarters Guide (NodeJS)](https://nepali-pkg.date/docs/nodejs/fiscal-year): [NodeJS] Architecture and calculation rules for Nepal official fiscal year and quarterly trimester accounting cycles. Official API reference and code examples for NodeJS / TypeScript. - [Calendar Quarters (NodeJS)](https://nepali-pkg.date/docs/nodejs/fiscal-year/calendar-quarters): [NodeJS] Explanation of standard Bikram Sambat calendar quarters compared to government fiscal trimesters. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.getCurrentFiscalYear() (NodeJS)](https://nepali-pkg.date/docs/nodejs/fiscal-year/get-current-fiscal-year): [NodeJS] Method to retrieve the formatted fiscal year string for a given NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. - [date.getCurrentFiscalYearQuarter() (NodeJS)](https://nepali-pkg.date/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter): [NodeJS] Method to calculate the active fiscal trimester quarter number for a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. - [date.getCurrentFiscalYearQuarterDates() (NodeJS)](https://nepali-pkg.date/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter-dates): [NodeJS] Method to retrieve exact start and end boundary dates for the active fiscal quarter. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.getFiscalYearQuarter() (NodeJS)](https://nepali-pkg.date/docs/nodejs/fiscal-year/get-fiscal-year-quarter): [NodeJS] Static method to determine the fiscal trimester number for any specified month index. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.getFiscalYearQuarters() (NodeJS)](https://nepali-pkg.date/docs/nodejs/fiscal-year/get-fiscal-year-quarters): [NodeJS] Static utility returning all four fiscal trimesters with their constituent months and date ranges for a given year. Official API reference and code examples for NodeJS / TypeScript. - [Installation & Setup (NodeJS)](https://nepali-pkg.date/docs/nodejs/installation): [NodeJS] Installation and setup guide for the nepali date library in Node.js and TypeScript applications using standard package managers. Official API reference and code examples for NodeJS / TypeScript. - [date.addDays() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/add-days): [NodeJS] Add or subtract a specified number of days to a NepaliDate instance with automatic month and year rollover. Official API reference and code examples for NodeJS / TypeScript. - [date.addMonths() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/add-months): [NodeJS] Add or subtract months to a NepaliDate instance while adjusting for variable month lengths. Official API reference and code examples for NodeJS / TypeScript. - [date.addYears() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/add-years): [NodeJS] Add or subtract years to a NepaliDate instance while preserving month and day values. Official API reference and code examples for NodeJS / TypeScript. - [date.clone() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/clone): [NodeJS] Create an independent deep clone of an existing NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. - [date.daysInMonth() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/days-in-month): [NodeJS] Retrieve the total number of days in the current or specified Bikram Sambat month. Official API reference and code examples for NodeJS / TypeScript. - [date.diff() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/diff): [NodeJS] Calculate the chronological difference between two NepaliDate instances in specific time units. Official API reference and code examples for NodeJS / TypeScript. - [date.endOfDay() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/end-of-day): [NodeJS] Return a new NepaliDate instance set to the final millisecond of the current day. Official API reference and code examples for NodeJS / TypeScript. - [date.endOfMonth() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/end-of-month): [NodeJS] Return a new NepaliDate instance set to the final day of the current Bikram Sambat month. Official API reference and code examples for NodeJS / TypeScript. - [date.endOfWeek() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/end-of-week): [NodeJS] Return a new NepaliDate instance set to the final day of the current week on Saturday. Official API reference and code examples for NodeJS / TypeScript. - [date.endOfYear() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/end-of-year): [NodeJS] Return a new NepaliDate instance set to the final day of the Bikram Sambat year on the last day of Chaitra. Official API reference and code examples for NodeJS / TypeScript. - [date.format() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/format): [NodeJS] Format a NepaliDate instance into a custom string using token patterns for English and Nepali output. Official API reference and code examples for NodeJS / TypeScript. - [date.getCurrentQuarter() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-current-quarter): [NodeJS] Return the standard Bikram Sambat calendar quarter number from one to four for the current date. Official API reference and code examples for NodeJS / TypeScript. - [date.getDate() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-date): [NodeJS] Retrieve the numeric day of the month from a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. - [date.getDay() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-day): [NodeJS] Retrieve the numeric day of the week index from zero for Sunday through six for Saturday. Official API reference and code examples for NodeJS / TypeScript. - [date.getEnglishDate() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-english-date): [NodeJS] Retrieve the equivalent Gregorian date as a native JavaScript Date object. Official API reference and code examples for NodeJS / TypeScript. - [date.getHours() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-hours): [NodeJS] Retrieve the hour component from zero to twenty three for the current date instance. Official API reference and code examples for NodeJS / TypeScript. - [date.getMilliseconds() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-milliseconds): [NodeJS] Retrieve the millisecond component from zero to nine hundred ninety nine. Official API reference and code examples for NodeJS / TypeScript. - [date.getMinutes() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-minutes): [NodeJS] Retrieve the minute component from zero to fifty nine for the current date instance. Official API reference and code examples for NodeJS / TypeScript. - [date.getMonth() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-month): [NodeJS] Retrieve the zero based Bikram Sambat month index from zero for Baisakh to eleven for Chaitra. Official API reference and code examples for NodeJS / TypeScript. - [date.getSeconds() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-seconds): [NodeJS] Retrieve the second component from zero to fifty nine for the current date instance. Official API reference and code examples for NodeJS / TypeScript. - [date.getTime() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-time): [NodeJS] Retrieve the numeric timestamp in milliseconds since the Unix epoch. Official API reference and code examples for NodeJS / TypeScript. - [date.getWeeksInMonth() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-weeks-in-month): [NodeJS] Calculate the number of calendar week rows required to render the current month in a grid. Official API reference and code examples for NodeJS / TypeScript. - [date.getYear() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/get-year): [NodeJS] Retrieve the four digit Bikram Sambat year number from a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. - [date.isAfter() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/is-after): [NodeJS] Check whether the current date occurs chronologically after another specified date. Official API reference and code examples for NodeJS / TypeScript. - [date.isBefore() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/is-before): [NodeJS] Check whether the current date occurs chronologically before another specified date. Official API reference and code examples for NodeJS / TypeScript. - [date.isEqual() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/is-equal): [NodeJS] Check whether two date instances share the exact same calendar date coordinates regardless of time. Official API reference and code examples for NodeJS / TypeScript. - [date.isLeapYear() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/is-leap-year): [NodeJS] Determine whether the current Bikram Sambat calendar year has three hundred sixty six or more days. Official API reference and code examples for NodeJS / TypeScript. - [date.isSame() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/is-same): [NodeJS] Check whether two dates match across a specified granularity such as year, month, or day. Official API reference and code examples for NodeJS / TypeScript. - [date.isValid() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/is-valid): [NodeJS] Validate whether the current NepaliDate instance represents a legitimate calendar date within supported bounds. Official API reference and code examples for NodeJS / TypeScript. - [date.parse() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/parse): [NodeJS] Parse a formatted Bikram Sambat date string and update the current date instance in place. Official API reference and code examples for NodeJS / TypeScript. - [date.set() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/set): [NodeJS] Set year, month, and day coordinates simultaneously on a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. - [date.setDate() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/set-date): [NodeJS] Set the day of the month on a NepaliDate instance and recalculate its timestamp. Official API reference and code examples for NodeJS / TypeScript. - [date.setMonth() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/set-month): [NodeJS] Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping. Official API reference and code examples for NodeJS / TypeScript. - [date.setYear() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/set-year): [NodeJS] Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range. Official API reference and code examples for NodeJS / TypeScript. - [date.startOfDay() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/start-of-day): [NodeJS] Return a new NepaliDate instance set to the first moment of the current day at midnight. Official API reference and code examples for NodeJS / TypeScript. - [date.startOfMonth() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/start-of-month): [NodeJS] Return a new NepaliDate instance set to the first day of the current Bikram Sambat month. Official API reference and code examples for NodeJS / TypeScript. - [date.startOfWeek() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/start-of-week): [NodeJS] Return a new NepaliDate instance set to the first day of the week on Sunday. Official API reference and code examples for NodeJS / TypeScript. - [date.startOfYear() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/start-of-year): [NodeJS] Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh. Official API reference and code examples for NodeJS / TypeScript. - [date.toString() (NodeJS)](https://nepali-pkg.date/docs/nodejs/methods/to-string): [NodeJS] Return the default string representation of a NepaliDate instance in standard year, month, and day format. Official API reference and code examples for NodeJS / TypeScript. - [Quick Start (NodeJS)](https://nepali-pkg.date/docs/nodejs/quick-start): [NodeJS] Practical guide and essential code examples to start working with Bikram Sambat dates in Node.js and TypeScript. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.getCalendarDays() (NodeJS)](https://nepali-pkg.date/docs/nodejs/static/get-calendar-days): [NodeJS] Static utility to generate a complete forty two cell calendar grid matrix for any month and year. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.getDayName() (NodeJS)](https://nepali-pkg.date/docs/nodejs/static/get-day-name): [NodeJS] Static utility to retrieve the localized English or Nepali name for any day of the week index. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.getMonthName() (NodeJS)](https://nepali-pkg.date/docs/nodejs/static/get-month-name): [NodeJS] Static utility to retrieve the localized English or Nepali month name for any month index. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.isValid() (NodeJS)](https://nepali-pkg.date/docs/nodejs/static/is-valid): [NodeJS] Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.maximum() (NodeJS)](https://nepali-pkg.date/docs/nodejs/static/maximum): [NodeJS] Static method returning the maximum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for NodeJS / TypeScript. - [NepaliDate.minimum() (NodeJS)](https://nepali-pkg.date/docs/nodejs/static/minimum): [NodeJS] Static method returning the minimum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for NodeJS / TypeScript. - [What is Nepali Date? (Origination & Calendar)](https://nepali-pkg.date/docs/origination): Deep dive into the origins, history, astronomical foundation, calendar mechanics, and timeline of Bikram Sambat (विक्रम संवत्). - [Project Overview](https://nepali-pkg.date/docs/overview): Comprehensive overview of the Nepali Date Library multi-language ecosystem, live package metrics, architecture, and developer profile. - [Overview (PHP)](https://nepali-pkg.date/docs/php): [PHP] Complete documentation and feature guide for the Nepali Date Library in PHP applications. Official API reference and code examples for PHP. - [new NepaliDate() (PHP)](https://nepali-pkg.date/docs/php/class/constructor): [PHP] Constructor overloads and initialization options for creating NepaliDate instances in PHP. Official API reference and code examples for PHP. - [Instance Properties & Getters (PHP)](https://nepali-pkg.date/docs/php/class/properties): [PHP] Guide to property encapsulation and public getters available on every NepaliDate instance in PHP. Official API reference and code examples for PHP. - [Constants::$MONTH_EN (PHP)](https://nepali-pkg.date/docs/php/constants/month-en): [PHP] Array containing standard romanized English names of all twelve Bikram Sambat calendar months. Official API reference and code examples for PHP. - [Constants::$MONTH_NP (PHP)](https://nepali-pkg.date/docs/php/constants/month-np): [PHP] Array containing official Devanagari Nepali names of all twelve Bikram Sambat calendar months. Official API reference and code examples for PHP. - [Constants::$MONTH_SHORT_EN (PHP)](https://nepali-pkg.date/docs/php/constants/month-short-en): [PHP] Array containing three letter abbreviated English names for all twelve Bikram Sambat months. Official API reference and code examples for PHP. - [Constants::$MONTH_SHORT_NP (PHP)](https://nepali-pkg.date/docs/php/constants/month-short-np): [PHP] Array containing abbreviated Devanagari Nepali names for all twelve Bikram Sambat calendar months. Official API reference and code examples for PHP. - [Constants::$NEPALI_DATE_MAP (PHP)](https://nepali-pkg.date/docs/php/constants/nepali-date-map): [PHP] Historical calendar mapping table storing verified day counts for every Bikram Sambat month between 1976 and 2100 BS. Official API reference and code examples for PHP. - [Constants::$NUMBER_NP (PHP)](https://nepali-pkg.date/docs/php/constants/number-np): [PHP] Array containing Devanagari numeral glyphs for digits zero through nine used for Nepali number localization. Official API reference and code examples for PHP. - [Constants::$WEEK_EN (PHP)](https://nepali-pkg.date/docs/php/constants/week-en): [PHP] Array containing full English names for all seven days of the week starting from Sunday. Official API reference and code examples for PHP. - [Constants::$WEEK_NP (PHP)](https://nepali-pkg.date/docs/php/constants/week-np): [PHP] Array containing full Devanagari Nepali names for all seven days of the week starting from Sunday. Official API reference and code examples for PHP. - [Constants::$WEEK_SHORT_EN (PHP)](https://nepali-pkg.date/docs/php/constants/week-short-en): [PHP] Array containing abbreviated English weekday names ordered from Sunday through Saturday. Official API reference and code examples for PHP. - [Constants::$WEEK_SHORT_NP (PHP)](https://nepali-pkg.date/docs/php/constants/week-short-np): [PHP] Array containing short Devanagari abbreviations for each day of the week starting from Sunday. Official API reference and code examples for PHP. - [Date Converter Guide (PHP)](https://nepali-pkg.date/docs/php/date-converter): [PHP] Comprehensive guide to converting dates between Gregorian and Bikram Sambat calendar systems using standalone helper functions. Official API reference and code examples for PHP. - [ADtoBS() (PHP)](https://nepali-pkg.date/docs/php/date-converter/ad-to-bs): [PHP] Pure helper function to convert Gregorian calendar date strings into Bikram Sambat date strings. Official API reference and code examples for PHP. - [BStoAD() (PHP)](https://nepali-pkg.date/docs/php/date-converter/bs-to-ad): [PHP] Pure helper function to convert Bikram Sambat date strings into Gregorian calendar date strings. Official API reference and code examples for PHP. - [Fiscal Year & Quarters Guide (PHP)](https://nepali-pkg.date/docs/php/fiscal-year): [PHP] Architecture and calculation rules for Nepal official fiscal year and quarterly trimester accounting cycles. Official API reference and code examples for PHP. - [Calendar Quarters (PHP)](https://nepali-pkg.date/docs/php/fiscal-year/calendar-quarters): [PHP] Explanation of standard Bikram Sambat calendar quarters compared to government fiscal trimesters. Official API reference and code examples for PHP. - [NepaliDate::getCurrentFiscalYear() (PHP)](https://nepali-pkg.date/docs/php/fiscal-year/get-current-fiscal-year): [PHP] Method to retrieve the formatted fiscal year string for a given NepaliDate instance. Official API reference and code examples for PHP. - [date->getCurrentFiscalYearQuarter() (PHP)](https://nepali-pkg.date/docs/php/fiscal-year/get-current-fiscal-year-quarter): [PHP] Method to calculate the active fiscal trimester quarter number for a NepaliDate instance. Official API reference and code examples for PHP. - [date->getCurrentFiscalYearQuarterDates() (PHP)](https://nepali-pkg.date/docs/php/fiscal-year/get-current-fiscal-year-quarter-dates): [PHP] Method to retrieve exact start and end boundary dates for the active fiscal quarter. Official API reference and code examples for PHP. - [NepaliDate::getFiscalYearQuarter() (PHP)](https://nepali-pkg.date/docs/php/fiscal-year/get-fiscal-year-quarter): [PHP] Static method to determine the fiscal trimester number for any specified month index. Official API reference and code examples for PHP. - [NepaliDate::getFiscalYearQuarters() (PHP)](https://nepali-pkg.date/docs/php/fiscal-year/get-fiscal-year-quarters): [PHP] Static utility returning all four fiscal trimesters with their constituent months and date ranges for a given year. Official API reference and code examples for PHP. - [Installation & Setup (PHP)](https://nepali-pkg.date/docs/php/installation): [PHP] Installation and setup instructions for nepali date library in PHP applications using Composer. Official API reference and code examples for PHP. - [date->addDays() (PHP)](https://nepali-pkg.date/docs/php/methods/add-days): [PHP] Add or subtract a specified number of days to a NepaliDate instance with automatic month and year rollover. Official API reference and code examples for PHP. - [date->addMonths() (PHP)](https://nepali-pkg.date/docs/php/methods/add-months): [PHP] Add or subtract months to a NepaliDate instance while adjusting for variable month lengths. Official API reference and code examples for PHP. - [date->addYears() (PHP)](https://nepali-pkg.date/docs/php/methods/add-years): [PHP] Add or subtract years to a NepaliDate instance while preserving month and day values. Official API reference and code examples for PHP. - [date->clone() (PHP)](https://nepali-pkg.date/docs/php/methods/clone): [PHP] Create an independent deep clone of an existing NepaliDate instance. Official API reference and code examples for PHP. - [date->daysInMonth() (PHP)](https://nepali-pkg.date/docs/php/methods/days-in-month): [PHP] Retrieve the total number of days in the current or specified Bikram Sambat month. Official API reference and code examples for PHP. - [date->diff() (PHP)](https://nepali-pkg.date/docs/php/methods/diff): [PHP] Calculate the chronological difference between two NepaliDate instances in specific time units. Official API reference and code examples for PHP. - [date->endOfDay() (PHP)](https://nepali-pkg.date/docs/php/methods/end-of-day): [PHP] Return a new NepaliDate instance set to the final millisecond of the current day. Official API reference and code examples for PHP. - [date->endOfMonth() (PHP)](https://nepali-pkg.date/docs/php/methods/end-of-month): [PHP] Return a new NepaliDate instance set to the final day of the current Bikram Sambat month. Official API reference and code examples for PHP. - [date->endOfWeek() (PHP)](https://nepali-pkg.date/docs/php/methods/end-of-week): [PHP] Return a new NepaliDate instance set to the final day of the current week on Saturday. Official API reference and code examples for PHP. - [date->endOfYear() (PHP)](https://nepali-pkg.date/docs/php/methods/end-of-year): [PHP] Return a new NepaliDate instance set to the final day of the Bikram Sambat year on the last day of Chaitra. Official API reference and code examples for PHP. - [date->format() (PHP)](https://nepali-pkg.date/docs/php/methods/format): [PHP] Format a NepaliDate instance into a custom string using token patterns for English and Nepali output. Official API reference and code examples for PHP. - [date->getCurrentQuarter() (PHP)](https://nepali-pkg.date/docs/php/methods/get-current-quarter): [PHP] Return the standard Bikram Sambat calendar quarter number from one to four for the current date. Official API reference and code examples for PHP. - [date->getDate() (PHP)](https://nepali-pkg.date/docs/php/methods/get-date): [PHP] Retrieve the numeric day of the month from a NepaliDate instance. Official API reference and code examples for PHP. - [date->getDay() (PHP)](https://nepali-pkg.date/docs/php/methods/get-day): [PHP] Retrieve the numeric day of the week index from zero for Sunday through six for Saturday. Official API reference and code examples for PHP. - [date->getEnglishDate() (PHP)](https://nepali-pkg.date/docs/php/methods/get-english-date): [PHP] Retrieve the equivalent Gregorian date as a native JavaScript Date object. Official API reference and code examples for PHP. - [date->getHours() (PHP)](https://nepali-pkg.date/docs/php/methods/get-hours): [PHP] Retrieve the hour component from zero to twenty three for the current date instance. Official API reference and code examples for PHP. - [date->getMilliseconds() (PHP)](https://nepali-pkg.date/docs/php/methods/get-milliseconds): [PHP] Retrieve the millisecond component from zero to nine hundred ninety nine. Official API reference and code examples for PHP. - [date->getMinutes() (PHP)](https://nepali-pkg.date/docs/php/methods/get-minutes): [PHP] Retrieve the minute component from zero to fifty nine for the current date instance. Official API reference and code examples for PHP. - [date->getMonth() (PHP)](https://nepali-pkg.date/docs/php/methods/get-month): [PHP] Retrieve the zero based Bikram Sambat month index from zero for Baisakh to eleven for Chaitra. Official API reference and code examples for PHP. - [date->getSeconds() (PHP)](https://nepali-pkg.date/docs/php/methods/get-seconds): [PHP] Retrieve the second component from zero to fifty nine for the current date instance. Official API reference and code examples for PHP. - [date->getTime() (PHP)](https://nepali-pkg.date/docs/php/methods/get-time): [PHP] Retrieve the numeric timestamp in milliseconds since the Unix epoch. Official API reference and code examples for PHP. - [date->getWeeksInMonth() (PHP)](https://nepali-pkg.date/docs/php/methods/get-weeks-in-month): [PHP] Calculate the number of calendar week rows required to render the current month in a grid. Official API reference and code examples for PHP. - [date->getYear() (PHP)](https://nepali-pkg.date/docs/php/methods/get-year): [PHP] Retrieve the four digit Bikram Sambat year number from a NepaliDate instance. Official API reference and code examples for PHP. - [date->isAfter() (PHP)](https://nepali-pkg.date/docs/php/methods/is-after): [PHP] Check whether the current date occurs chronologically after another specified date. Official API reference and code examples for PHP. - [date->isBefore() (PHP)](https://nepali-pkg.date/docs/php/methods/is-before): [PHP] Check whether the current date occurs chronologically before another specified date. Official API reference and code examples for PHP. - [date->isEqual() (PHP)](https://nepali-pkg.date/docs/php/methods/is-equal): [PHP] Check whether two date instances share the exact same calendar date coordinates regardless of time. Official API reference and code examples for PHP. - [date->isLeapYear() (PHP)](https://nepali-pkg.date/docs/php/methods/is-leap-year): [PHP] Determine whether the current Bikram Sambat calendar year has three hundred sixty six or more days. Official API reference and code examples for PHP. - [date->isSame() (PHP)](https://nepali-pkg.date/docs/php/methods/is-same): [PHP] Check whether two dates match across a specified granularity such as year, month, or day. Official API reference and code examples for PHP. - [date->isValidInstance() (PHP)](https://nepali-pkg.date/docs/php/methods/is-valid): [PHP] Validate whether the current NepaliDate instance represents a legitimate calendar date within supported bounds. Official API reference and code examples for PHP. - [date->parse() (PHP)](https://nepali-pkg.date/docs/php/methods/parse): [PHP] Parse a formatted Bikram Sambat date string and update the current date instance in place. Official API reference and code examples for PHP. - [date->set() (PHP)](https://nepali-pkg.date/docs/php/methods/set): [PHP] Set year, month, and day coordinates simultaneously on a NepaliDate instance. Official API reference and code examples for PHP. - [date->setDate() (PHP)](https://nepali-pkg.date/docs/php/methods/set-date): [PHP] Set the day of the month on a NepaliDate instance and recalculate its timestamp. Official API reference and code examples for PHP. - [date->setMonth() (PHP)](https://nepali-pkg.date/docs/php/methods/set-month): [PHP] Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping. Official API reference and code examples for PHP. - [date->setYear() (PHP)](https://nepali-pkg.date/docs/php/methods/set-year): [PHP] Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range. Official API reference and code examples for PHP. - [date->startOfDay() (PHP)](https://nepali-pkg.date/docs/php/methods/start-of-day): [PHP] Return a new NepaliDate instance set to the first moment of the current day at midnight. Official API reference and code examples for PHP. - [date->startOfMonth() (PHP)](https://nepali-pkg.date/docs/php/methods/start-of-month): [PHP] Return a new NepaliDate instance set to the first day of the current Bikram Sambat month. Official API reference and code examples for PHP. - [date->startOfWeek() (PHP)](https://nepali-pkg.date/docs/php/methods/start-of-week): [PHP] Return a new NepaliDate instance set to the first day of the week on Sunday. Official API reference and code examples for PHP. - [date->startOfYear() (PHP)](https://nepali-pkg.date/docs/php/methods/start-of-year): [PHP] Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh. Official API reference and code examples for PHP. - [date->toString() (PHP)](https://nepali-pkg.date/docs/php/methods/to-string): [PHP] Return the default string representation of a NepaliDate instance in standard year, month, and day format. Official API reference and code examples for PHP. - [Quick Start (PHP)](https://nepali-pkg.date/docs/php/quick-start): [PHP] Practical guide and essential code examples to start working with Bikram Sambat dates in PHP. Official API reference and code examples for PHP. - [NepaliDate::getCalendarDays() (PHP)](https://nepali-pkg.date/docs/php/static/get-calendar-days): [PHP] Static utility to generate a complete forty two cell calendar grid matrix for any month and year. Official API reference and code examples for PHP. - [NepaliDate::getDayName() (PHP)](https://nepali-pkg.date/docs/php/static/get-day-name): [PHP] Static utility to retrieve the localized English or Nepali name for any day of the week index. Official API reference and code examples for PHP. - [NepaliDate::getMonthName() (PHP)](https://nepali-pkg.date/docs/php/static/get-month-name): [PHP] Static utility to retrieve the localized English or Nepali month name for any month index. Official API reference and code examples for PHP. - [NepaliDate::isValid() (PHP)](https://nepali-pkg.date/docs/php/static/is-valid): [PHP] Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date. Official API reference and code examples for PHP. - [NepaliDate::maximum() (PHP)](https://nepali-pkg.date/docs/php/static/maximum): [PHP] Static method returning the maximum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for PHP. - [NepaliDate::minimum() (PHP)](https://nepali-pkg.date/docs/php/static/minimum): [PHP] Static method returning the minimum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for PHP. - [Overview (PYTHON)](https://nepali-pkg.date/docs/python): [PYTHON] Complete documentation and feature guide for the Nepali Date Library in Python applications. Official API reference and code examples for Python. - [NepaliDate() (PYTHON)](https://nepali-pkg.date/docs/python/class/constructor): [PYTHON] Constructor overloads and initialization options for creating NepaliDate instances in Python. Official API reference and code examples for Python. - [Instance Properties (PYTHON)](https://nepali-pkg.date/docs/python/class/properties): [PYTHON] Reference for public instance properties available on every NepaliDate object including year, month, day, and underlying timestamp. Official API reference and code examples for Python. - [month_en (PYTHON)](https://nepali-pkg.date/docs/python/constants/month-en): [PYTHON] Array containing standard romanized English names of all twelve Bikram Sambat calendar months. Official API reference and code examples for Python. - [month_np (PYTHON)](https://nepali-pkg.date/docs/python/constants/month-np): [PYTHON] Array containing official Devanagari Nepali names of all twelve Bikram Sambat calendar months. Official API reference and code examples for Python. - [month_short_en (PYTHON)](https://nepali-pkg.date/docs/python/constants/month-short-en): [PYTHON] Array containing three letter abbreviated English names for all twelve Bikram Sambat months. Official API reference and code examples for Python. - [month_short_np (PYTHON)](https://nepali-pkg.date/docs/python/constants/month-short-np): [PYTHON] Array containing abbreviated Devanagari Nepali names for all twelve Bikram Sambat calendar months. Official API reference and code examples for Python. - [nepali_date_map (PYTHON)](https://nepali-pkg.date/docs/python/constants/nepali-date-map): [PYTHON] Historical calendar mapping table storing verified day counts for every Bikram Sambat month between 1976 and 2100 BS. Official API reference and code examples for Python. - [number_np (PYTHON)](https://nepali-pkg.date/docs/python/constants/number-np): [PYTHON] Array containing Devanagari numeral glyphs for digits zero through nine used for Nepali number localization. Official API reference and code examples for Python. - [week_en (PYTHON)](https://nepali-pkg.date/docs/python/constants/week-en): [PYTHON] Array containing full English names for all seven days of the week starting from Sunday. Official API reference and code examples for Python. - [week_np (PYTHON)](https://nepali-pkg.date/docs/python/constants/week-np): [PYTHON] Array containing full Devanagari Nepali names for all seven days of the week starting from Sunday. Official API reference and code examples for Python. - [week_short_en (PYTHON)](https://nepali-pkg.date/docs/python/constants/week-short-en): [PYTHON] Array containing abbreviated English weekday names ordered from Sunday through Saturday. Official API reference and code examples for Python. - [week_short_np (PYTHON)](https://nepali-pkg.date/docs/python/constants/week-short-np): [PYTHON] Array containing short Devanagari abbreviations for each day of the week starting from Sunday. Official API reference and code examples for Python. - [Date Converter Guide (PYTHON)](https://nepali-pkg.date/docs/python/date-converter): [PYTHON] Comprehensive guide to converting dates between Gregorian and Bikram Sambat calendar systems using standalone helper functions. Official API reference and code examples for Python. - [ADtoBS() (PYTHON)](https://nepali-pkg.date/docs/python/date-converter/ad-to-bs): [PYTHON] Pure helper function to convert Gregorian calendar date strings into Bikram Sambat date strings. Official API reference and code examples for Python. - [BStoAD() (PYTHON)](https://nepali-pkg.date/docs/python/date-converter/bs-to-ad): [PYTHON] Pure helper function to convert Bikram Sambat date strings into Gregorian calendar date strings. Official API reference and code examples for Python. - [Fiscal Year & Quarters Guide (PYTHON)](https://nepali-pkg.date/docs/python/fiscal-year): [PYTHON] Architecture and calculation rules for Nepal official fiscal year and quarterly trimester accounting cycles. Official API reference and code examples for Python. - [Calendar Quarters (PYTHON)](https://nepali-pkg.date/docs/python/fiscal-year/calendar-quarters): [PYTHON] Explanation of standard Bikram Sambat calendar quarters compared to government fiscal trimesters. Official API reference and code examples for Python. - [NepaliDate.current_fiscal_year() (PYTHON)](https://nepali-pkg.date/docs/python/fiscal-year/current-fiscal-year): [PYTHON] Method to retrieve the formatted fiscal year string for a given NepaliDate instance. Official API reference and code examples for Python. - [date.fiscal_quarter() (PYTHON)](https://nepali-pkg.date/docs/python/fiscal-year/fiscal-quarter): [PYTHON] Method to calculate the active fiscal trimester quarter number for a NepaliDate instance. Official API reference and code examples for Python. - [date.fiscal_quarter_dates() (PYTHON)](https://nepali-pkg.date/docs/python/fiscal-year/fiscal-quarter-dates): [PYTHON] Method to retrieve exact start and end boundary dates for the active fiscal quarter. Official API reference and code examples for Python. - [NepaliDate.get_fiscal_quarter() (PYTHON)](https://nepali-pkg.date/docs/python/fiscal-year/get-fiscal-quarter): [PYTHON] Static method to determine the fiscal trimester number for any specified month index. Official API reference and code examples for Python. - [NepaliDate.get_fiscal_quarters() (PYTHON)](https://nepali-pkg.date/docs/python/fiscal-year/get-fiscal-quarters): [PYTHON] Static utility returning all four fiscal trimesters with their constituent months and date ranges for a given year. Official API reference and code examples for Python. - [Installation & Setup (PYTHON)](https://nepali-pkg.date/docs/python/installation): [PYTHON] Installation and setup instructions for nepali date library in Python projects using pip, uv, and poetry. Official API reference and code examples for Python. - [date.add_days() (PYTHON)](https://nepali-pkg.date/docs/python/methods/add-days): [PYTHON] Add or subtract a specified number of days to a NepaliDate instance with automatic month and year rollover. Official API reference and code examples for Python. - [date.add_months() (PYTHON)](https://nepali-pkg.date/docs/python/methods/add-months): [PYTHON] Add or subtract months to a NepaliDate instance while adjusting for variable month lengths. Official API reference and code examples for Python. - [date.add_years() (PYTHON)](https://nepali-pkg.date/docs/python/methods/add-years): [PYTHON] Add or subtract years to a NepaliDate instance while preserving month and day values. Official API reference and code examples for Python. - [date.clone() (PYTHON)](https://nepali-pkg.date/docs/python/methods/clone): [PYTHON] Create an independent deep clone of an existing NepaliDate instance. Official API reference and code examples for Python. - [date.current_quarter() (PYTHON)](https://nepali-pkg.date/docs/python/methods/current-quarter): [PYTHON] Return the standard Bikram Sambat calendar quarter number from one to four for the current date. Official API reference and code examples for Python. - [date.days_in_month() (PYTHON)](https://nepali-pkg.date/docs/python/methods/days-in-month): [PYTHON] Retrieve the total number of days in the current or specified Bikram Sambat month. Official API reference and code examples for Python. - [date.diff() (PYTHON)](https://nepali-pkg.date/docs/python/methods/diff): [PYTHON] Calculate the chronological difference between two NepaliDate instances in specific time units. Official API reference and code examples for Python. - [date.end_of_day() (PYTHON)](https://nepali-pkg.date/docs/python/methods/end-of-day): [PYTHON] Return a new NepaliDate instance set to the final millisecond of the current day. Official API reference and code examples for Python. - [date.end_of_month() (PYTHON)](https://nepali-pkg.date/docs/python/methods/end-of-month): [PYTHON] Return a new NepaliDate instance set to the final day of the current Bikram Sambat month. Official API reference and code examples for Python. - [date.end_of_week() (PYTHON)](https://nepali-pkg.date/docs/python/methods/end-of-week): [PYTHON] Return a new NepaliDate instance set to the final day of the current week on Saturday. Official API reference and code examples for Python. - [date.end_of_year() (PYTHON)](https://nepali-pkg.date/docs/python/methods/end-of-year): [PYTHON] Return a new NepaliDate instance set to the final day of the Bikram Sambat year on the last day of Chaitra. Official API reference and code examples for Python. - [date.format() (PYTHON)](https://nepali-pkg.date/docs/python/methods/format): [PYTHON] Format a NepaliDate instance into a custom string using token patterns for English and Nepali output. Official API reference and code examples for Python. - [date.get_date() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-date): [PYTHON] Retrieve the numeric day of the month from a NepaliDate instance. Official API reference and code examples for Python. - [date.get_day() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-day): [PYTHON] Retrieve the numeric day of the week index from zero for Sunday through six for Saturday. Official API reference and code examples for Python. - [date.get_english_date() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-english-date): [PYTHON] Retrieve the equivalent Gregorian date as a native JavaScript Date object. Official API reference and code examples for Python. - [date.get_hours() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-hours): [PYTHON] Retrieve the hour component from zero to twenty three for the current date instance. Official API reference and code examples for Python. - [date.get_milliseconds() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-milliseconds): [PYTHON] Retrieve the millisecond component from zero to nine hundred ninety nine. Official API reference and code examples for Python. - [date.get_minutes() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-minutes): [PYTHON] Retrieve the minute component from zero to fifty nine for the current date instance. Official API reference and code examples for Python. - [date.get_month() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-month): [PYTHON] Retrieve the zero based Bikram Sambat month index from zero for Baisakh to eleven for Chaitra. Official API reference and code examples for Python. - [date.get_seconds() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-seconds): [PYTHON] Retrieve the second component from zero to fifty nine for the current date instance. Official API reference and code examples for Python. - [date.get_time() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-time): [PYTHON] Retrieve the numeric timestamp in milliseconds since the Unix epoch. Official API reference and code examples for Python. - [date.get_weeks_in_month() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-weeks-in-month): [PYTHON] Calculate the number of calendar week rows required to render the current month in a grid. Official API reference and code examples for Python. - [date.get_year() (PYTHON)](https://nepali-pkg.date/docs/python/methods/get-year): [PYTHON] Retrieve the four digit Bikram Sambat year number from a NepaliDate instance. Official API reference and code examples for Python. - [date.is_after() (PYTHON)](https://nepali-pkg.date/docs/python/methods/is-after): [PYTHON] Check whether the current date occurs chronologically after another specified date. Official API reference and code examples for Python. - [date.is_before() (PYTHON)](https://nepali-pkg.date/docs/python/methods/is-before): [PYTHON] Check whether the current date occurs chronologically before another specified date. Official API reference and code examples for Python. - [date.is_equal() (PYTHON)](https://nepali-pkg.date/docs/python/methods/is-equal): [PYTHON] Check whether two date instances share the exact same calendar date coordinates regardless of time. Official API reference and code examples for Python. - [date.is_leap_year() (PYTHON)](https://nepali-pkg.date/docs/python/methods/is-leap-year): [PYTHON] Determine whether the current Bikram Sambat calendar year has three hundred sixty six or more days. Official API reference and code examples for Python. - [date.is_same() (PYTHON)](https://nepali-pkg.date/docs/python/methods/is-same): [PYTHON] Check whether two dates match across a specified granularity such as year, month, or day. Official API reference and code examples for Python. - [date.is_valid_instance() (PYTHON)](https://nepali-pkg.date/docs/python/methods/is-valid): [PYTHON] Validate whether the current NepaliDate instance represents a legitimate calendar date within supported bounds. Official API reference and code examples for Python. - [date.parse() (PYTHON)](https://nepali-pkg.date/docs/python/methods/parse): [PYTHON] Parse a formatted Bikram Sambat date string and update the current date instance in place. Official API reference and code examples for Python. - [date.set() (PYTHON)](https://nepali-pkg.date/docs/python/methods/set): [PYTHON] Set year, month, and day coordinates simultaneously on a NepaliDate instance. Official API reference and code examples for Python. - [date.set_date() (PYTHON)](https://nepali-pkg.date/docs/python/methods/set-date): [PYTHON] Set the day of the month on a NepaliDate instance and recalculate its timestamp. Official API reference and code examples for Python. - [date.set_english_date() (PYTHON)](https://nepali-pkg.date/docs/python/methods/set-english-date): [PYTHON] Update internal Bikram Sambat coordinates from a native Python datetime object. Official API reference and code examples for Python. - [date.set_month() (PYTHON)](https://nepali-pkg.date/docs/python/methods/set-month): [PYTHON] Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping. Official API reference and code examples for Python. - [date.set_year() (PYTHON)](https://nepali-pkg.date/docs/python/methods/set-year): [PYTHON] Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range. Official API reference and code examples for Python. - [date.start_of_day() (PYTHON)](https://nepali-pkg.date/docs/python/methods/start-of-day): [PYTHON] Return a new NepaliDate instance set to the first moment of the current day at midnight. Official API reference and code examples for Python. - [date.start_of_month() (PYTHON)](https://nepali-pkg.date/docs/python/methods/start-of-month): [PYTHON] Return a new NepaliDate instance set to the first day of the current Bikram Sambat month. Official API reference and code examples for Python. - [date.start_of_week() (PYTHON)](https://nepali-pkg.date/docs/python/methods/start-of-week): [PYTHON] Return a new NepaliDate instance set to the first day of the week on Sunday. Official API reference and code examples for Python. - [date.start_of_year() (PYTHON)](https://nepali-pkg.date/docs/python/methods/start-of-year): [PYTHON] Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh. Official API reference and code examples for Python. - [Quick Start (PYTHON)](https://nepali-pkg.date/docs/python/quick-start): [PYTHON] Practical guide and essential code examples to start working with Bikram Sambat dates in Python. Official API reference and code examples for Python. - [NepaliDate.get_calendar_days() (PYTHON)](https://nepali-pkg.date/docs/python/static/get-calendar-days): [PYTHON] Static utility to generate a complete forty two cell calendar grid matrix for any month and year. Official API reference and code examples for Python. - [NepaliDate.get_day_name() (PYTHON)](https://nepali-pkg.date/docs/python/static/get-day-name): [PYTHON] Static utility to retrieve the localized English or Nepali name for any day of the week index. Official API reference and code examples for Python. - [NepaliDate.get_month_name() (PYTHON)](https://nepali-pkg.date/docs/python/static/get-month-name): [PYTHON] Static utility to retrieve the localized English or Nepali month name for any month index. Official API reference and code examples for Python. - [NepaliDate.is_valid() (PYTHON)](https://nepali-pkg.date/docs/python/static/is-valid): [PYTHON] Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date. Official API reference and code examples for Python. - [NepaliDate.maximum() (PYTHON)](https://nepali-pkg.date/docs/python/static/maximum): [PYTHON] Static method returning the maximum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for Python. - [NepaliDate.minimum() (PYTHON)](https://nepali-pkg.date/docs/python/static/minimum): [PYTHON] Static method returning the minimum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for Python. --- # Detailed API Specifications & Reference Manual ## Bikram Sambat Calendar Structure Bikram Sambat is a solar calendar historically used in Nepal and parts of South Asia. It is roughly 56.7 years ahead of the Gregorian (AD) calendar: - Year range: 1976 BS to 2100 BS. - Month names in order: 1. Baisakh (बैशाख) - 30 to 31 days 2. Jestha (जेठ) - 31 to 32 days 3. Ashadh (असार) - 31 to 32 days 4. Shrawan (साउन) - 31 to 32 days 5. Bhadra (भदौ) - 31 to 32 days 6. Ashwin (असोज) - 30 to 31 days 7. Kartik (कार्तिक) - 29 to 30 days 8. Mangsir (मंसिर) - 29 to 30 days 9. Poush (पौष) - 29 to 30 days 10. Magh (माघ) - 29 to 30 days 11. Falgun (फागुन) - 29 to 30 days 12. Chaitra (चैत) - 30 to 31 days ## Nepal Government Fiscal Year (आर्थिक वर्ष) - Starts: Shrawan 1 (approx mid-July AD) - Ends: Ashadh end (approx mid-July next year AD) - Format: "YYYY/YY" (e.g., 2081/82) - Fiscal Quarters: - First Quarter (Q1): Shrawan 1 to Ashwin end - Second Quarter (Q2): Kartik 1 to Poush end - Third Quarter (Q3): Magh 1 to Chaitra end - Fourth Quarter (Q4): Baisakh 1 to Ashadh end ## Formatting Tokens Cheat Sheet - `YYYY`: 4-digit Nepali Year (e.g. 2081) - `YY`: 2-digit Nepali Year (e.g. 81) - `MMMM`: Full Nepali Month Name (e.g. Ashwin / असोज) - `MMM`: Short Nepali Month Name (e.g. Ash / असो) - `MM`: 2-digit Month (01-12) - `M`: 1 or 2-digit Month (1-12) - `DD`: 2-digit Day (01-32) - `D`: 1 or 2-digit Day (1-32) - `dddd`: Full Day Name (e.g. Sunday / आइतबार) - `ddd`: Short Day Name (e.g. Sun / आइत) - `HH`: 2-digit Hours (00-23) - `mm`: 2-digit Minutes (00-59) - `ss`: 2-digit Seconds (00-59) --- # Curated Documentation & Method Guides ## Page: Contribution Guide (/docs/contribution) Description: Learn how to contribute to the Nepali Date Library ecosystem across Node.js, Python, PHP, and Documentation. Thank you for your interest in contributing to the **Nepali Date (Bikram Sambat) Ecosystem**! This open-source project is built and maintained to provide synchronized, robust, zero-dependency calendar tools across JavaScript/TypeScript, Python, and PHP. Whether you are fixing a typo, adding calendar tests, improving performance, or porting new features across languages, your contributions are warmly welcomed. --- ## Ecosystem Repositories The ecosystem consists of four main projects: | Project | Ecosystem | Source Repository | | :--- | :--- | :--- | | **Node.js / TypeScript** | npm, yarn, pnpm, bun | [GitHub Repository](https://github.com/SandipGhimire/Nepali-Date-Library-NodeJS) | | **Python** | PyPI (uv, pip, poetry) | [GitHub Repository](https://github.com/SandipGhimire/Nepali-Date-Library-Python) | | **PHP** | Packagist (Composer) | [GitHub Repository](https://github.com/SandipGhimire/Nepali-Date-Library-PHP) | | **Documentation & Converter** | Next.js 16 / Fumadocs | [GitHub Repository](https://github.com/SandipGhimire/Nepali-Date-Library) | --- ## Core Contribution Principles Before proposing changes, please keep our core architectural principles in mind: 1. **Zero External Runtime Dependencies**: All three language packages (`nepali-date-library`) MUST maintain zero external dependencies at runtime. Do not add runtime packages. 2. **Standardized Cross-Language Semantics**: The API surface across Node.js, Python, and PHP is intentionally synchronized. Method names, formatting tokens (e.g. `YYYY-MM-DD`, `dddd`), fiscal year quarters, and edge case handling should match across all implementations. 3. **Annual Calendar Verification & Range Coverage (1976 – 2100 BS)**: Dates up to the current active calendar year are verified against official Government of Nepal publications (Nepal Panchanga Nirnayak Samiti). Every year around the month of **Ashwin (Ashoj)**, when the official government calendar is released for the upcoming year, the mapping tables are audited and updated with exact solar ingress corrections. Test suites must pass across all supported years (1976/01/01 to 2100/12/31 BS). 4. **Deterministic Timezone Isolation**: Date arithmetic, weekday getters, and day start/end calculations must execute deterministically regardless of the host machine's local timezone. --- ## Development Environment Setup Select your target language below for environment setup and test commands: ### Node.js / TypeScript Setup **Prerequisites**: Node.js `>= 22.0.0`, pnpm `>= 10.0.0` ```bash # Clone repository git clone https://github.com/SandipGhimire/Nepali-Date-Library-NodeJS.git cd Nepali-Date-Library-NodeJS # Install dependencies pnpm install # Build ESM and CJS bundles pnpm run build # Run tests (Vitest) pnpm run test # Run legacy Node compatibility tests (Node 8-17) pnpm run test:compat # Lint and formatting pnpm run lint pnpm run format ``` ### Python Setup **Prerequisites**: Python `>= 3.9`, [uv](https://docs.astral.sh/uv/) (recommended) ```bash # Clone repository git clone https://github.com/SandipGhimire/Nepali-Date-Library-Python.git cd Nepali-Date-Library-Python # Create virtual environment and install dev dependencies uv sync --group dev # Run unit tests and style checks uv run task test # Or run pytest directly uv run pytest # Format code with black uv run black src tests # Static type checking uv run mypy src ``` ### PHP Setup **Prerequisites**: PHP `>= 7.1`, [Composer](https://getcomposer.org/) ```bash # Clone repository git clone https://github.com/SandipGhimire/Nepali-Date-Library-PHP.git cd Nepali-Date-Library-PHP # Install dependencies composer install # Run full PHPUnit test suite composer test ``` ### Documentation Engine Setup **Prerequisites**: Node.js `>= 22.0.0`, pnpm `>= 10.0.0` ```bash # Navigate to Docs directory in main repo cd Docs # Install dependencies pnpm install # Start development server with Turbopack pnpm dev ``` Open [http://localhost:3000](http://localhost:3000) to view local live edits with instant hot reload. --- ## Pull Request Guidelines 1. **Fork & Branch**: Fork the target repository and create a descriptive branch: ```bash git checkout -b feat/devanagari-weekday-tokens ``` 2. **Write Tests**: Accompany every bug fix or feature with clear unit tests verifying the behavior. 3. **Run CI Checks**: Verify that all test suites, linters, and type checkers pass without errors. 4. **Descriptive Commits**: Use conventional commits (e.g., `feat:`, `fix:`, `docs:`, `chore:`). 5. **Submit PR**: Open a Pull Request referencing any related issues with reproduction steps or rationale. --- ## Community & Code of Conduct We are dedicated to providing a welcoming, inclusive, and respectful environment for all contributors. Please treat fellow maintainers and contributors with professionalism, kindness, and constructive feedback. Made with ❤️ by [Sandip Ghimire](https://github.com/SandipGhimire). --- ## Page: Examples & Practical Recipes (/docs/examples) Description: Real-world patterns and cross-language code recipes for working with Nepali dates. Practical, copy-pasteable patterns for common tasks when working with Bikram Sambat dates across **Node.js / TypeScript**, **PHP**, and **Python**. --- ## 1. Storing User-Entered BS Date in Database A recommended architecture pattern is to accept Bikram Sambat dates from user forms, convert them to standard Gregorian (AD) ISO dates for SQL/NoSQL storage, and convert back to BS when rendering. ### Node.js / TypeScript ```typescript import { NepaliDate, BStoAD, ADtoBS } from "nepali-date-library"; // 1. User submits BS date: "2081-06-29" const userBSInput = "2081-06-29"; // 2. Convert to AD for database insertion const adDateString = BStoAD(userBSInput); // "2024-10-15" // db.users.insert({ birth_date: new Date(adDateString) }) // 3. When reading from database, convert back to BS const dbAdDate = "2024-10-15"; const displayBSDate = ADtoBS(dbAdDate); // "2081-06-29" ``` ### PHP ```php use NepaliDateLibrary\NepaliDate; use function NepaliDateLibrary\BStoAD; use function NepaliDateLibrary\ADtoBS; $userBSInput = '2081-06-29'; // Convert to AD for database (MySQL DATE column) $adDate = BStoAD($userBSInput); // '2024-10-15' // Convert back to BS for presentation $displayBS = ADtoBS($adDate); // '2081-06-29' ``` ### Python ```python from nepali_date_library import BStoAD, ADtoBS user_bs = "2081-06-29" # Convert to Gregorian for Django / SQLAlchemy model ad_str = BStoAD(user_bs) # "2024-10-15" # Convert back to BS display_bs = ADtoBS(ad_str) # "2081-06-29" ``` --- ## 2. Calculating Age from a Bikram Sambat Date of Birth Calculate precise age breakdown (Years, Months, Days) from a BS date of birth: ### Node.js / TypeScript ```typescript import { NepaliDate } from "nepali-date-library"; function calculateAge(dobBS: string) { const birth = new NepaliDate(dobBS); const today = new NepaliDate(); // Today in BS let years = today.getYear() - birth.getYear(); let months = today.getMonth() - birth.getMonth(); let days = today.getDate() - birth.getDate(); if (days < 0) { months -= 1; days += 30; // approximate month adjustment } if (months < 0) { years -= 1; months += 12; } return { years, months, days }; } console.log(calculateAge("2064-03-23")); // { years: 17, months: 3, days: 6 } ``` --- ## 3. Nepali Fiscal Year & Quarterly Reporting The Nepali fiscal year runs from **1 Shrawan (Month 4)** to **Ashadh end (Month 3)**. ### PHP (Laravel / Accounting) ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-06-29'); // Get Fiscal Year string echo $date->getFiscalYear(); // "2081/82" // Get Quarter (1 to 4) echo $date->getQuarter(); // 1 (Shrawan - Ashoj) // Get Start and End dates of Q2 (Kartik to Poush) $q2 = NepaliDate::getQuarter(2, 2081); echo "Q2 Start: " . $q2['start']->format('YYYY-MM-DD'); // 2081-07-01 echo "Q2 End: " . $q2['end']->format('YYYY-MM-DD'); // 2081-09-29 ``` ### Node.js / TypeScript ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-06-29"); console.log(`Fiscal Year: ${date.getFiscalYear()}`); // "2081/82" console.log(`Fiscal Quarter: Q${date.getQuarter()}`); // "Q1" ``` --- ## 4. Date Arithmetic & Expiry Tracking Add or subtract days, months, and years with built-in month-length clamping: ### Python ```python from nepali_date_library import NepaliDate subscription = NepaliDate("2081-01-31") # Add 1 month (safely clamps to Jestha end without month overflow) subscription.add_months(1) print("Next renewal:", subscription.format("YYYY-MM-DD")) # Add 15 days subscription.add_days(15) print("Grace period:", subscription.format("YYYY-MM-DD")) ``` ### Node.js / TypeScript ```typescript import { NepaliDate } from "nepali-date-library"; const contract = new NepaliDate("2081-01-15"); // 90-day review period contract.addDays(90); console.log(contract.format("DDDD, MMMM D, YYYY")); ``` --- ## 5. Devanagari Localization & Formatting Render authentic Nepali dates with native script and Devanagari numerals: ### Node.js / TypeScript ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-07-15"); // English formatting console.log(date.format("YYYY MMMM DD, DDDD")); // "2081 Kartik 15, Friday" // Devanagari Nepali script formatting console.log(date.format("yyyy mmmm dd, dddd")); // "२०८१ कार्तिक १५, शुक्रबार" ``` --- ## Page: Installation (/docs/installation) Description: Install Nepali Date Library in your project using your preferred package manager across Node.js, Python, or PHP. Install the **Nepali Date Library** across your stack. Select your package manager below for quick copy-paste commands. --- ## Node.js / TypeScript Install `nepali-date-library` via pnpm, npm, yarn, or bun: ```bash pnpm add nepali-date-library ``` ```bash npm install nepali-date-library ``` ```bash yarn add nepali-date-library ``` ```bash bun add nepali-date-library ``` ### Verify Installation ```typescript import { NepaliDate } from "nepali-date-library"; const today = new NepaliDate(); console.log(today.format("YYYY-MM-DD")); ``` --- ## Python Install `nepali-date-library` via pip, uv, or poetry: ```bash pip install nepali-date-library ``` ```bash uv add nepali-date-library ``` ```bash poetry add nepali-date-library ``` ### Verify Installation ```python from nepali_date import NepaliDate today = NepaliDate.today() print(today.format("%Y-%m-%d")) ``` --- ## PHP Install `sghimire/nepali-date-library` via Composer: ```bash composer require sghimire/nepali-date-library ``` ### Verify Installation ```php format('Y-m-d'); ``` --- ## Ecosystem Registries | Environment | Package Name | Registry | | :--- | :--- | :--- | | **Node.js / TypeScript** | `nepali-date-library` | [npmjs.com/package/nepali-date-library](https://www.npmjs.com/package/nepali-date-library) | | **Python** | `nepali-date-library` | [pypi.org/project/nepali-date-library](https://pypi.org/project/nepali-date-library/) | | **PHP** | `sghimire/nepali-date-library` | [packagist.org/packages/sghimire/nepali-date-library](https://packagist.org/packages/sghimire/nepali-date-library) | --- ## Page: Overview (NodeJS) (/docs/nodejs) Description: [NodeJS] Complete documentation and feature guide for the Nepali Date Library in Node.js and TypeScript applications. Official API reference and code examples for NodeJS / TypeScript. The Nepali Date Library for Node.js provides a high performance toolkit with zero external dependencies for Bikram Sambat calendar operations. It handles bidirectional conversion between Bikram Sambat and Gregorian calendars, date arithmetic, custom string formatting, fiscal year calculations, and calendar grid generation for modern web applications and backend systems. --- ## Installation Install via your preferred package manager: ```bash pnpm add nepali-date-library ``` ```bash npm install nepali-date-library ``` ```bash yarn add nepali-date-library ``` ```bash bun add nepali-date-library ``` --- ## Quick Start ```typescript import { NepaliDate, ADtoBS, BStoAD } from "nepali-date-library"; // 1. Current Nepali date const today = new NepaliDate(); console.log(today.format("YYYY-MM-DD")); // e.g. "2081-06-29" // 2. Parse a BS date const event = new NepaliDate("2081-07-15"); console.log(event.format("DDDD, MMMM D, YYYY")); // "Friday, Kartik 15, 2081" // 3. Convert to JavaScript Date (Gregorian AD) const adDate = event.toJsDate(); console.log(adDate.toISOString()); // "2024-10-31T18:15:00.000Z" // 4. Standalone conversion helpers const bs = ADtoBS("2024-11-15"); // "2081-07-30" const ad = BStoAD("2081-07-30"); // "2024-11-15" ``` --- ## Core Capabilities - **Strict TypeScript Types**: Fully typed with comprehensive IntelliSense and autocomplete. - **Zero Runtime Dependencies**: Ultra-lightweight footprint suitable for Node.js, React, Next.js, and edge workers. - **Bidirectional Conversion**: Accurate conversion between Gregorian (AD) and Bikram Sambat (BS) from 1976 to 2100 BS. - **Date Arithmetic**: Add and subtract days, months, and years with accurate month-day boundary clamping. - **Fiscal Year Engine**: Built-in calculation for Nepali fiscal years (Shrawan to Ashadh) and financial quarters. - **Devanagari Localization**: Native formatting with Nepali numerals (`२०८१`), month names (`कार्तिक`), and weekdays (`शुक्रबार`). --- ## Package Details | Specification | Resource & Link | | :--- | :--- | | **Package Name** | `nepali-date-library` | | **npm Registry** | [npmjs.com/package/nepali-date-library](https://www.npmjs.com/package/nepali-date-library) | | **GitHub Repository** | [SandipGhimire/Nepali-Date-Library-NodeJS](https://github.com/SandipGhimire/Nepali-Date-Library-NodeJS) | | **Download Metrics** | [View Stats on npmjs.com](https://www.npmjs.com/package/nepali-date-library) | | **Runtime Support** | Node.js 18+, Bun 1.0+, Deno, Modern Browsers | | **License** | MIT | --- ## Page: new NepaliDate() (NodeJS) (/docs/nodejs/class/constructor) Description: [NodeJS] Constructor overloads and initialization options for creating NepaliDate instances in Node.js and TypeScript. Official API reference and code examples for NodeJS / TypeScript. The `NepaliDate` constructor creates instances representing specific points in time mapped to the Bikram Sambat calendar system. You can construct an instance representing the current moment, provide separate year, month, and day integers, supply a standard date string, or pass a native JavaScript Date object. Bikram Sambat months are indexed starting from 0 for Baisakh through 11 for Chaitra. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` ```javascript const { NepaliDate } = require("nepali-date-library"); ``` --- ## Signatures ```typescript // 1. Current Date & Time new NepaliDate(): NepaliDate; // 2. From Gregorian Date Object new NepaliDate(date: Date): NepaliDate; // 3. From Formatted Date String new NepaliDate(dateString: string): NepaliDate; // 4. From Coordinates (Year, Month, Day) new NepaliDate(year: number, month: number, day: number): NepaliDate; // 5. From Unix Epoch Milliseconds new NepaliDate(timestamp: number): NepaliDate; // 6. From Existing Instance (Cloning) new NepaliDate(date: NepaliDate): NepaliDate; ``` --- ## Overload Details & Parameters ### 1. No Arguments Constructs an instance set to the current system date and time. ```typescript const now = new NepaliDate(); ``` ### 2. From JavaScript Date (`Date`) Converts a native JavaScript `Date` to its corresponding Bikram Sambat date. ```typescript const jsDate = new Date(); const date = new NepaliDate(jsDate); ``` ### 3. From String (`string`) Parses a date string formatted as `YYYY-MM-DD`, `YYYY/MM/DD`, or `YYYY.MM.DD`. ```typescript const date1 = new NepaliDate("2081-07-15"); const date2 = new NepaliDate("2081/07/15"); const date3 = new NepaliDate("2081.07.15"); ``` ### 4. From Coordinates (`year, month, day`) * `year`: 4-digit Bikram Sambat year (e.g. `2081`). * `month`: **0-indexed** month (`0` for Baisakh to `11` for Chaitra). * `day`: Day of month (`1` to `32`). ```typescript // 2081 Kartik 15 (Month 6 is Kartik) const date = new NepaliDate(2081, 6, 15); ``` ### 5. From Timestamp (`number`) Initializes the date from an epoch millisecond integer. ```typescript const date = new NepaliDate(1730332800000); ``` --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid argument syntax` | Thrown if parameters fail type checks or incomplete arguments are passed. | | `Invalid date` | Thrown if string parsing encounters non-numeric components. | | `Nepal year out of range` | Thrown if year is earlier than `1976` BS or later than `2100` BS. | | `Invalid nepali month must be between 1 - 12` | Thrown if string month component is outside `1`–`12`. | | `Invalid nepali date must be between 1 - in ` | Thrown if the day exceeds the days count for that specific month and year. | --- ## Examples ### Complete Constructor Variations ```typescript import { NepaliDate } from "nepali-date-library"; // Current instant const current = new NepaliDate(); // String parsing const parsed = new NepaliDate("2080-01-01"); // Numeric coordinates (Month 0 = Baisakh) const newYear = new NepaliDate(2082, 0, 1); // From Gregorian Date const fromAd = new NepaliDate(new Date("2024-10-31")); // Copy constructor const copy = new NepaliDate(parsed); ``` --- ## Related * [`NepaliDate.isValid()`](/docs/nodejs/static/is-valid): Validate coordinates prior to instantiation. * [`date.clone()`](/docs/nodejs/methods/clone): Clone an instance via method call. * [`date.parse()`](/docs/nodejs/methods/parse): Mutate an existing instance from a string. --- ## Page: Instance Properties (NodeJS) (/docs/nodejs/class/properties) Description: [NodeJS] Reference for public instance properties available on every NepaliDate object including year, month, day, and underlying timestamp. Official API reference and code examples for NodeJS / TypeScript. Every `NepaliDate` instance provides direct read access to its core calendar coordinates through public properties. These include the four digit Bikram Sambat year, the month number indexed from 0 to 11, the day of the month from 1 to 32, and the underlying UTC timestamp stored as a native JavaScript Date object. These properties reflect the current state of the date instance after any modifications or arithmetic operations. --- ## Property Reference | Property | Type | Description | Range | | :--- | :--- | :--- | :--- | | `year` | `number` | The Bikram Sambat year. | `1976` – `2100` | | `month` | `number` | The **0-indexed** Bikram Sambat month. | `0` (Baisakh) – `11` (Chaitra) | | `day` | `number` | The day of the month. | `1` – `32` | | `timestamp` | `Date` | The corresponding native JavaScript `Date` object in UTC. | Equivalent Gregorian timestamp | --- ## Examples ### Reading Properties Directly ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-07-15"); console.log(date.year); // 2081 console.log(date.month); // 6 (0-indexed: 6 corresponds to Kartik) console.log(date.day); // 15 console.log(date.timestamp); // 2024-10-31T00:00:00.000Z ``` ### Direct Property vs. Method Access While properties are public for inspection, it is recommended to use dedicated methods for formatting and mutation: ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-07-15"); // Using methods for formatted values console.log(date.getDate()); // 15 console.log(date.getMonth() + 1); // 7 (1-indexed display) // Using methods to mutate coordinates safely date.setDate(16); // Safely validates days in month and recalculates timestamp ``` --- ## Related * [`new NepaliDate()`](/docs/nodejs/class/constructor): Instantiating a `NepaliDate` object. * [`date.getEnglishDate()`](/docs/nodejs/methods/get-english-date): Retrieve the native JavaScript `Date`. --- ## Page: MONTH_EN (NodeJS) (/docs/nodejs/constants/month-en) Description: [NodeJS] Array containing standard romanized English names of all twelve Bikram Sambat calendar months. Official API reference and code examples for NodeJS / TypeScript. The `MONTH_EN` constant is an immutable array containing the official romanized English names of the twelve Bikram Sambat months. The array is indexed starting from 0 for Baisakh up to index 11 for Chaitra, making it convenient for looking up month names corresponding to numeric month values returned by date methods. --- ## Import ```typescript import { MONTH_EN } from "nepali-date-library"; ``` --- ## Value ```typescript export const MONTH_EN = [ "Baisakh", "Jestha", "Asar", "Shrawan", "Bhadra", "Aswin", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra", ]; ``` --- ## Index Mapping | Index | Month Name | Gregorian Equivalent (Approximate) | | :---: | :--- | :--- | | `0` | `"Baisakh"` | Mid-April to Mid-May | | `1` | `"Jestha"` | Mid-May to Mid-June | | `2` | `"Asar"` | Mid-June to Mid-July | | `3` | `"Shrawan"` | Mid-July to Mid-August | | `4` | `"Bhadra"` | Mid-August to Mid-September | | `5` | `"Aswin"` | Mid-September to Mid-October | | `6` | `"Kartik"` | Mid-October to Mid-November | | `7` | `"Mangsir"` | Mid-November to Mid-December | | `8` | `"Poush"` | Mid-December to Mid-January | | `9` | `"Magh"` | Mid-January to Mid-February | | `10` | `"Falgun"` | Mid-February to Mid-March | | `11` | `"Chaitra"` | Mid-March to Mid-April | --- ## Examples ### Accessing Month Names by Index ```typescript import { MONTH_EN, NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-15"); console.log(MONTH_EN[date.getMonth()]); // "Baisakh" ``` --- ## Related * [`MONTH_SHORT_EN`](/docs/nodejs/constants/month-short-en): Abbreviated English month names. * [`MONTH_NP`](/docs/nodejs/constants/month-np): Devanagari Nepali month names. * [`NepaliDate.getMonthName()`](/docs/nodejs/static/get-month-name): Static helper with formatting options. --- ## Page: MONTH_NP (NodeJS) (/docs/nodejs/constants/month-np) Description: [NodeJS] Array containing official Devanagari Nepali names of all twelve Bikram Sambat calendar months. Official API reference and code examples for NodeJS / TypeScript. The `MONTH_NP` constant is an immutable array containing the standard Nepali names in Devanagari script for the twelve Bikram Sambat months. Each index maps directly to the zero based month number, starting at index 0 for Baisakh through index 11 for Chaitra, enabling accurate localization in user interfaces and printed documents. --- ## Import ```typescript import { MONTH_NP } from "nepali-date-library"; ``` --- ## Value ```typescript export const MONTH_NP = [ "बैशाख", "जेठ", "असार", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मंसिर", "पौष", "माघ", "फाल्गुण", "चैत्र", ]; ``` --- ## Index Mapping | Index | Devanagari Name | Romanized | | :---: | :--- | :--- | | `0` | `"बैशाख"` | Baisakh | | `1` | `"जेठ"` | Jestha | | `2` | `"असार"` | Asar | | `3` | `"श्रावण"` | Shrawan | | `4` | `"भाद्र"` | Bhadra | | `5` | `"आश्विन"` | Aswin | | `6` | `"कार्तिक"` | Kartik | | `7` | `"मंसिर"` | Mangsir | | `8` | `"पौष"` | Poush | | `9` | `"माघ"` | Magh | | `10` | `"फाल्गुण"` | Falgun | | `11` | `"चैत्र"` | Chaitra | --- ## Examples ### Accessing Month Names by Index ```typescript import { MONTH_NP, NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-04-01"); console.log(MONTH_NP[date.getMonth()]); // "श्रावण" ``` --- ## Related * [`MONTH_SHORT_NP`](/docs/nodejs/constants/month-short-np): Abbreviated Devanagari month names. * [`MONTH_EN`](/docs/nodejs/constants/month-en): English romanized month names. * [`NepaliDate.getMonthName()`](/docs/nodejs/static/get-month-name): Static helper with formatting options. --- ## Page: MONTH_SHORT_EN (NodeJS) (/docs/nodejs/constants/month-short-en) Description: [NodeJS] Array containing three letter abbreviated English names for all twelve Bikram Sambat months. Official API reference and code examples for NodeJS / TypeScript. The `MONTH_SHORT_EN` constant provides three letter abbreviated English labels for each of the twelve Bikram Sambat months. It follows the zero based index convention from index 0 for Bai up to index 11 for Cha, making it ideal for compact calendar widgets, mobile screens, and table headers. --- ## Import ```typescript import { MONTH_SHORT_EN } from "nepali-date-library"; ``` --- ## Value ```typescript export const MONTH_SHORT_EN = [ "Bai", "Jes", "Asa", "Shr", "Bhd", "Asw", "Kar", "Man", "Pou", "Mag", "Fal", "Cha", ]; ``` --- ## Index Mapping | Index | Abbreviation | Full Name | | :---: | :--- | :--- | | `0` | `"Bai"` | Baisakh | | `1` | `"Jes"` | Jestha | | `2` | `"Asa"` | Asar | | `3` | `"Shr"` | Shrawan | | `4` | `"Bhd"` | Bhadra | | `5` | `"Asw"` | Aswin | | `6` | `"Kar"` | Kartik | | `7` | `"Man"` | Mangsir | | `8` | `"Pou"` | Poush | | `9` | `"Mag"` | Magh | | `10` | `"Fal"` | Falgun | | `11` | `"Cha"` | Chaitra | --- ## Examples ### Generating Compact Month Badges ```typescript import { MONTH_SHORT_EN, NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-15"); console.log(MONTH_SHORT_EN[date.getMonth()]); // "Bai" ``` --- ## Related * [`MONTH_EN`](/docs/nodejs/constants/month-en): Full English month names. * [`MONTH_SHORT_NP`](/docs/nodejs/constants/month-short-np): Abbreviated Nepali month names. * [`date.format()`](/docs/nodejs/methods/format): Formatting with the `MMM` token. --- ## Page: MONTH_SHORT_NP (NodeJS) (/docs/nodejs/constants/month-short-np) Description: [NodeJS] Array containing abbreviated Devanagari Nepali names for all twelve Bikram Sambat calendar months. Official API reference and code examples for NodeJS / TypeScript. The `MONTH_SHORT_NP` constant supplies short Devanagari abbreviations for each Bikram Sambat month. Starting with index 0 for Baisakh and ending with index 11 for Chaitra, these abbreviated labels are designed for space constrained displays such as date pickers, dashboard summaries, and mobile layouts. --- ## Import ```typescript import { MONTH_SHORT_NP } from "nepali-date-library"; ``` --- ## Value ```typescript export const MONTH_SHORT_NP = [ "बै", "जे", "अ", "श्रा", "भा", "आ", "का", "मं", "पौ", "मा", "फा", "चै", ]; ``` --- ## Index Mapping | Index | Short Name | Full Name | | :---: | :--- | :--- | | `0` | `"बै"` | बैशाख (Baisakh) | | `1` | `"जे"` | जेठ (Jestha) | | `2` | `"अ"` | असार (Asar) | | `3` | `"श्रा"` | श्रावण (Shrawan) | | `4` | `"भा"` | भाद्र (Bhadra) | | `5` | `"आ"` | आश्विन (Aswin) | | `6` | `"का"` | कार्तिक (Kartik) | | `7` | `"मं"` | मंसिर (Mangsir) | | `8` | `"पौ"` | पौष (Poush) | | `9` | `"मा"` | माघ (Magh) | | `10` | `"फा"` | फाल्गुण (Falgun) | | `11` | `"चै"` | चैत्र (Chaitra) | --- ## Examples ### Generating Compact Month Badges ```typescript import { MONTH_SHORT_NP, NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-15"); console.log(MONTH_SHORT_NP[date.getMonth()]); // "बै" ``` --- ## Related * [`MONTH_NP`](/docs/nodejs/constants/month-np): Full Devanagari month names. * [`MONTH_SHORT_EN`](/docs/nodejs/constants/month-short-en): Abbreviated English month names. * [`date.format()`](/docs/nodejs/methods/format): Formatting with the `mmm` token. --- ## Page: NEPALI_DATE_MAP (NodeJS) (/docs/nodejs/constants/nepali-date-map) Description: [NodeJS] Historical calendar mapping table storing verified day counts for every Bikram Sambat month between 1976 and 2100 BS. Official API reference and code examples for NodeJS / TypeScript. The `NEPALI_DATE_MAP` data structure contains the calendar matrix for the Bikram Sambat system spanning years 1976 through 2100 BS. Because Bikram Sambat months have variable day counts determined by astronomical solar calculations rather than fixed rules, this mapping table provides the definitive source of truth for conversions, day calculations, and month lengths. > [!NOTE] > Dates up to the active calendar year are verified against official publications from the **Nepal Panchanga Nirnayak Samiti** (नेपाल पञ्चाङ्ग निर्णायक समिति). Every year around the month of **Ashwin (Ashoj)**, when the official government calendar is gazetted for the subsequent year, this mapping table is audited and updated with exact solar ingress corrections. --- ## Import ```typescript import { NEPALI_DATE_MAP } from "nepali-date-library"; ``` --- ## Type Definition ```typescript export const NEPALI_DATE_MAP: { year: number; days: number[]; totalDays: number; daysTillNow: number; }[]; ``` --- ## Object Schema Each entry in the array represents one Bikram Sambat year and adheres to the following structure: | Field | Type | Description | | :--- | :--- | :--- | | `year` | `number` | The Bikram Sambat year (e.g. `2081`). | | `days` | `number[]` | An array of 12 integers representing the day count of each month from Baisakh (`index 0`) to Chaitra (`index 11`). | | `totalDays` | `number` | Total number of days in that Bikram Sambat year (typically `365` or `366`). | | `daysTillNow` | `number` | Cumulative count of days elapsed from calendar epoch up to the end of this year. | --- ## Range and Epoch * **Start Year**: `1976` BS (Gregorian equivalent: April 13, 1919) * **End Year**: `2100` BS * **Total Entries**: 125 historical and future astronomical calendar tables. --- ## Examples ### Accessing Year Metadata ```typescript import { NEPALI_DATE_MAP } from "nepali-date-library"; // Find data for year 2081 BS const year2081 = NEPALI_DATE_MAP.find((item) => item.year === 2081); console.log(year2081?.year); // 2081 console.log(year2081?.days); // [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30] console.log(year2081?.totalDays); // 365 ``` ### Inspecting Specific Month Length ```typescript import { NEPALI_DATE_MAP } from "nepali-date-library"; // 2081 Baisakh (index 0) has 31 days const baisakhDays = NEPALI_DATE_MAP[2081 - 1976].days[0]; console.log(`2081 Baisakh has ${baisakhDays} days.`); ``` --- ## Related * [`NepaliDate.minimum()`](/docs/nodejs/static/minimum): Lower calendar limit. * [`NepaliDate.maximum()`](/docs/nodejs/static/maximum): Upper calendar limit. * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Query days in a month. --- ## Page: NUMBER_NP (NodeJS) (/docs/nodejs/constants/number-np) Description: [NodeJS] Array containing Devanagari numeral glyphs for digits zero through nine used for Nepali number localization. Official API reference and code examples for NodeJS / TypeScript. The `NUMBER_NP` constant is an array containing the ten Devanagari numeral characters representing digits 0 through 9 in Nepali script. It provides a direct lookup table for formatting numbers, years, dates, and currency values into native Devanagari script for Nepali language interfaces. --- ## Import ```typescript import { NUMBER_NP } from "nepali-date-library"; ``` --- ## Value ```typescript export const NUMBER_NP = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"]; ``` --- ## Index Mapping | Index | Character | Unicode Codepoint | | :---: | :---: | :--- | | `0` | `"०"` | `U+0966` | | `1` | `"१"` | `U+0967` | | `2` | `"२"` | `U+0968` | | `3` | `"३"` | `U+0969` | | `4` | `"४"` | `U+096A` | | `5` | `"५"` | `U+096B` | | `6` | `"६"` | `U+096C` | | `7` | `"७"` | `U+096D` | | `8` | `"८"` | `U+096E` | | `9` | `"९"` | `U+096F` | --- ## Examples ### Converting Arabic Digits to Devanagari ```typescript import { NUMBER_NP } from "nepali-date-library"; function toNepaliDigits(num: number | string): string { return String(num) .split("") .map((ch) => { const code = ch.charCodeAt(0) - 48; return code >= 0 && code <= 9 ? NUMBER_NP[code] : ch; }) .join(""); } console.log(toNepaliDigits(2081)); // "२०८१" console.log(toNepaliDigits("2081-01-25")); // "२०८१-०१-२५" ``` --- ## Related * [`date.format()`](/docs/nodejs/methods/format): Format dates with lowercase tokens (`yyyy`, `mm`, `dd`). --- ## Page: WEEK_EN (NodeJS) (/docs/nodejs/constants/week-en) Description: [NodeJS] Array containing full English names for all seven days of the week starting from Sunday. Official API reference and code examples for NodeJS / TypeScript. The `WEEK_EN` constant is an array containing the full English weekday names ordered from Sunday at index 0 through Saturday at index 6. This ordering matches the standard JavaScript day index convention returned by the getDay method, allowing seamless weekday lookups in English interfaces. --- ## Import ```typescript import { WEEK_EN } from "nepali-date-library"; ``` --- ## Value ```typescript export const WEEK_EN = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", ]; ``` --- ## Index Mapping | Index | Day Name | | :---: | :--- | | `0` | `"Sunday"` | | `1` | `"Monday"` | | `2` | `"Tuesday"` | | `3` | `"Wednesday"` | | `4` | `"Thursday"` | | `5` | `"Friday"` | | `6` | `"Saturday"` | --- ## Examples ### Getting Current Weekday Name ```typescript import { WEEK_EN, NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-25"); console.log(WEEK_EN[date.getDay()]); // "Thursday" ``` --- ## Related * [`WEEK_SHORT_EN`](/docs/nodejs/constants/week-short-en): Abbreviated English weekday names. * [`WEEK_NP`](/docs/nodejs/constants/week-np): Devanagari Nepali weekday names. * [`NepaliDate.getDayName()`](/docs/nodejs/static/get-day-name): Static helper with locale options. --- ## Page: WEEK_NP (NodeJS) (/docs/nodejs/constants/week-np) Description: [NodeJS] Array containing full Devanagari Nepali names for all seven days of the week starting from Sunday. Official API reference and code examples for NodeJS / TypeScript. The `WEEK_NP` constant provides the full Devanagari Nepali names for the seven days of the week, beginning with Aaitabar at index 0 and concluding with Shanibar at index 6. It enables complete localization for calendar headings, date labels, and event scheduling in Nepali language applications. --- ## Import ```typescript import { WEEK_NP } from "nepali-date-library"; ``` --- ## Value ```typescript export const WEEK_NP = [ "आइतबार", "सोमबार", "मंगलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार", ]; ``` --- ## Index Mapping | Index | Devanagari Weekday | English Equivalent | | :---: | :--- | :--- | | `0` | `"आइतबार"` | Sunday | | `1` | `"सोमबार"` | Monday | | `2` | `"मंगलबार"` | Tuesday | | `3` | `"बुधबार"` | Wednesday | | `4` | `"बिहिबार"` | Thursday | | `5` | `"शुक्रबार"` | Friday | | `6` | `"शनिबार"` | Saturday | --- ## Examples ### Getting Current Weekday Name in Nepali ```typescript import { WEEK_NP, NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-25"); console.log(WEEK_NP[date.getDay()]); // "बिहिबार" ``` --- ## Related * [`WEEK_SHORT_NP`](/docs/nodejs/constants/week-short-np): Abbreviated Devanagari weekday names. * [`WEEK_EN`](/docs/nodejs/constants/week-en): Full English weekday names. * [`NepaliDate.getDayName()`](/docs/nodejs/static/get-day-name): Static helper with locale options. --- ## Page: WEEK_SHORT_EN (NodeJS) (/docs/nodejs/constants/week-short-en) Description: [NodeJS] Array containing abbreviated English weekday names ordered from Sunday through Saturday. Official API reference and code examples for NodeJS / TypeScript. The `WEEK_SHORT_EN` constant contains short three letter English abbreviations for each day of the week, starting with Sun at index 0 and ending with Sat at index 6. These concise labels are widely used in monthly calendar headers, compact date selectors, and agenda views. --- ## Import ```typescript import { WEEK_SHORT_EN } from "nepali-date-library"; ``` --- ## Value ```typescript export const WEEK_SHORT_EN = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ]; ``` --- ## Index Mapping | Index | Abbreviation | Full Name | | :---: | :--- | :--- | | `0` | `"Sun"` | Sunday | | `1` | `"Mon"` | Monday | | `2` | `"Tue"` | Tuesday | | `3` | `"Wed"` | Wednesday | | `4` | `"Thu"` | Thursday | | `5` | `"Fri"` | Friday | | `6` | `"Sat"` | Saturday | --- ## Examples ### Building Calendar Column Headers ```typescript import { WEEK_SHORT_EN } from "nepali-date-library"; // Generate week header row for UI calendar console.log(WEEK_SHORT_EN.join(" | ")); // "Sun | Mon | Tue | Wed | Thu | Fri | Sat" ``` --- ## Related * [`WEEK_EN`](/docs/nodejs/constants/week-en): Full English weekday names. * [`WEEK_SHORT_NP`](/docs/nodejs/constants/week-short-np): Abbreviated Nepali weekday names. * [`date.format()`](/docs/nodejs/methods/format): Formatting with the `DDD` token. --- ## Page: WEEK_SHORT_NP (NodeJS) (/docs/nodejs/constants/week-short-np) Description: [NodeJS] Array containing short Devanagari abbreviations for each day of the week starting from Sunday. Official API reference and code examples for NodeJS / TypeScript. The `WEEK_SHORT_NP` constant supplies short Devanagari abbreviations for each day of the week, beginning with index 0 for Aaitabar and ending with index 6 for Shanibar. These compact symbols are ideal for calendar grid headers and mobile date selectors where horizontal width is limited. --- ## Import ```typescript import { WEEK_SHORT_NP } from "nepali-date-library"; ``` --- ## Value ```typescript export const WEEK_SHORT_NP = [ "आइत", "सोम", "मंगल", "बुध", "बिहि", "शुक्र", "शनि", ]; ``` --- ## Index Mapping | Index | Short Name | Full Name | English Equivalent | | :---: | :--- | :--- | :--- | | `0` | `"आइत"` | आइतबार | Sunday | | `1` | `"सोम"` | सोमबार | Monday | | `2` | `"मंगल"` | मंगलबार | Tuesday | | `3` | `"बुध"` | बुधबार | Wednesday | | `4` | `"बिहि"` | बिहिबार | Thursday | | `5` | `"शुक्र"` | शुक्रबार | Friday | | `6` | `"शनि"` | शनिबार | Saturday | --- ## Examples ### Building Calendar Column Headers in Devanagari ```typescript import { WEEK_SHORT_NP } from "nepali-date-library"; // Generate week header row for UI calendar console.log(WEEK_SHORT_NP.join(" | ")); // "आइत | सोम | मंगल | बुध | बिहि | शुक्र | शनि" ``` --- ## Related * [`WEEK_NP`](/docs/nodejs/constants/week-np): Full Devanagari weekday names. * [`WEEK_SHORT_EN`](/docs/nodejs/constants/week-short-en): Abbreviated English weekday names. * [`date.format()`](/docs/nodejs/methods/format): Formatting with the `ddd` token. --- ## Page: Date Converter Guide (NodeJS) (/docs/nodejs/date-converter) Description: [NodeJS] Comprehensive guide to converting dates between Gregorian and Bikram Sambat calendar systems using standalone helper functions. Official API reference and code examples for NodeJS / TypeScript. The date converter utilities provide pure standalone functions for converting date strings directly between the Gregorian calendar and the Bikram Sambat calendar. These functions operate without creating full class instances, making them suitable for high throughput batch processing, database migrations, and backend service integration. --- ## When to Use Helper Functions vs. the `NepaliDate` Class | Requirement | Use `ADtoBS` / `BStoAD` | Use `NepaliDate` Class | | :--- | :---: | :---: | | Simple string-to-string conversion | Yes | Optional | | Database serialization / ETL pipelines | Yes | Optional | | Date arithmetic (`addDays`, `diff`) | No | Yes | | Custom token formatting (`MMMM`, `dddd`) | No | Yes | | Calendar boundary calculations (`startOfMonth`) | No | Yes | | Fiscal year & quarter calculations | No | Yes | --- ## Timezone Drift Prevention One of the most frequent bugs when converting dates in distributed environments is **single-day shifting caused by local server timezones**. For example, parsing `"2024-11-01"` using `new Date("2024-11-01")` in a system running in UTC-5 (Eastern Time) produces `2024-10-31 19:00:00`, which erroneously converts to the previous Nepali date. `ADtoBS` and `BStoAD` internally enforce **strict UTC parsing** via `Date.UTC`: - `"2024-11-01"` is always resolved at `2024-11-01T00:00:00.000Z`. - Conversions produce identical results regardless of whether your code runs in Tokyo (UTC+9), Kathmandu (UTC+5:45), London (UTC+0), or San Francisco (UTC-8). --- ## Input Format Standard Both conversion functions enforce the ISO-8601 standard date format: ```text YYYY-MM-DD ``` - Years must be 4 digits. - Months must be 2 zero-padded digits (`01` to `12`). - Days must be 2 zero-padded digits (`01` to `32`). Passing strings with non-standard delimiters or single digits (e.g. `2081-7-5` or `2081/07/05`) will throw an explicit format error. --- ## Error Handling & `DateConversionError` All conversion errors throw a descriptive exception or an instance of `DateConversionError` containing the underlying cause: ```typescript import { ADtoBS } from "nepali-date-library"; try { const bsDate = ADtoBS("invalid-date-string"); } catch (error) { if (error instanceof Error) { console.error(error.message); // "Invalid date format. Expected format: YYYY-MM-DD" } } ``` --- ## Next Steps Explore the individual function references: - [`ADtoBS()`](/docs/nodejs/date-converter/ad-to-bs): Convert Gregorian AD strings to Bikram Sambat BS. - [`BStoAD()`](/docs/nodejs/date-converter/bs-to-ad): Convert Bikram Sambat BS strings to Gregorian AD. --- ## Page: ADtoBS() (NodeJS) (/docs/nodejs/date-converter/ad-to-bs) Description: [NodeJS] Pure helper function to convert Gregorian calendar date strings into Bikram Sambat date strings. Official API reference and code examples for NodeJS / TypeScript. The `ADtoBS` function performs direct mathematical conversion of a Gregorian date string into its corresponding Bikram Sambat date string. It accepts standard date formats and returns the converted Nepali date, handling month day variations and leap year calculations automatically without external dependencies. --- ## Import ```typescript import { ADtoBS } from "nepali-date-library"; ``` ```javascript const { ADtoBS } = require("nepali-date-library"); ``` --- ## Signature ```typescript function ADtoBS(adDate: string): string; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `adDate` | `string` | Yes | Gregorian date string formatted strictly as `YYYY-MM-DD`. | --- ## Return Value * **Type**: `string` * **Format**: `YYYY-MM-DD` representing the corresponding Bikram Sambat date. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid date format. Expected format: YYYY-MM-DD` | Thrown if `adDate` fails the format regex `^\d{4}-\d{2}-\d{2}$`. | | `Invalid date input ''` | Thrown if date values produce `NaN` (e.g. `2024-02-31`). | | `DateConversionError: Failed to convert AD to BS` | Thrown if the date falls outside the verified ephemeris boundary (1919-04-13 to 2044-04-12 AD). | --- ## Examples ### Basic Conversion ```typescript import { ADtoBS } from "nepali-date-library"; const bsDate = ADtoBS("2024-10-31"); console.log(bsDate); // "2081-07-15" ``` ### Batch Array Processing ```typescript import { ADtoBS } from "nepali-date-library"; const records = [ { id: 1, createdAt: "2024-01-01" }, { id: 2, createdAt: "2024-04-13" }, { id: 3, createdAt: "2024-10-31" }, ]; const mappedRecords = records.map((record) => ({ ...record, createdAtBS: ADtoBS(record.createdAt), })); console.log(mappedRecords[0].createdAtBS); // "2080-09-16" ``` ### Error Handling ```typescript import { ADtoBS } from "nepali-date-library"; function safeADtoBS(dateString: string): string | null { try { return ADtoBS(dateString); } catch { return null; } } console.log(safeADtoBS("2024-10-31")); // "2081-07-15" console.log(safeADtoBS("invalid")); // null ``` --- ## Related * [`BStoAD()`](/docs/nodejs/date-converter/bs-to-ad): Reciprocal conversion from BS to AD. * [`new NepaliDate(date)`](/docs/nodejs/class/constructor): Converting a JavaScript Date object into a full `NepaliDate` instance. --- ## Page: BStoAD() (NodeJS) (/docs/nodejs/date-converter/bs-to-ad) Description: [NodeJS] Pure helper function to convert Bikram Sambat date strings into Gregorian calendar date strings. Official API reference and code examples for NodeJS / TypeScript. The `BStoAD` function converts a Bikram Sambat date string into its equivalent Gregorian calendar date string. It validates the input Nepali date against verified historical calendar maps and returns a formatted Gregorian date string suitable for storage in standard SQL databases or transmission over web APIs. --- ## Import ```typescript import { BStoAD } from "nepali-date-library"; ``` ```javascript const { BStoAD } = require("nepali-date-library"); ``` --- ## Signature ```typescript function BStoAD(bsDate: string): string; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `bsDate` | `string` | Yes | Bikram Sambat date string formatted strictly as `YYYY-MM-DD`. | --- ## Return Value * **Type**: `string` * **Format**: `YYYY-MM-DD` representing the corresponding Gregorian date in UTC. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid date format. Expected format: YYYY-MM-DD` | Thrown if `bsDate` fails the format regex `^\d{4}-\d{2}-\d{2}$`. | | `Nepal year out of range` | Thrown if year is earlier than `1976` BS or later than `2100` BS. | | `Invalid nepali month must be between 1 - 12` | Thrown if month component is not within `1` to `12`. | | `Invalid nepali date must be between 1 - in ` | Thrown if the day exceeds the verified days for that specific month and year. | | `DateConversionError: Failed to convert BS to AD` | Wrapped error for conversion failures. | --- ## Examples ### Basic Conversion ```typescript import { BStoAD } from "nepali-date-library"; const adDate = BStoAD("2081-07-15"); console.log(adDate); // "2024-10-31" ``` ### Converting Month with 32 Days Bikram Sambat summer months can contain 32 days. `BStoAD` validates the exact ephemeris for that year: ```typescript import { BStoAD } from "nepali-date-library"; // Jestha 32, 2081 const adDate = BStoAD("2081-02-32"); console.log(adDate); // "2024-06-14" ``` ### Database Persistence Pattern Convert user-entered Bikram Sambat dates to standard ISO-8601 strings prior to storing in SQL or NoSQL databases: ```typescript import { BStoAD } from "nepali-date-library"; interface UserRegistrationInput { fullName: string; birthDateBS: string; // e.g. "2055-04-12" } function prepareUserForStorage(input: UserRegistrationInput) { return { fullName: input.fullName, birthDateBS: input.birthDateBS, birthDateAD: BStoAD(input.birthDateBS), // "1998-07-27" }; } ``` --- ## Related * [`ADtoBS()`](/docs/nodejs/date-converter/ad-to-bs): Reciprocal conversion from AD to BS. * [`date.getEnglishDate()`](/docs/nodejs/methods/get-english-date): Method on `NepaliDate` instance returning a JavaScript `Date`. --- ## Page: Fiscal Year & Quarters Guide (NodeJS) (/docs/nodejs/fiscal-year) Description: [NodeJS] Architecture and calculation rules for Nepal official fiscal year and quarterly trimester accounting cycles. Official API reference and code examples for NodeJS / TypeScript. In Nepal the official fiscal year begins on 1 Shrawan and ends on the final day of Ashadh in the following calendar year. The nepali date library includes specialized functions to compute fiscal years, identify trimester quarters, and determine quarter start and end boundary dates for financial, tax, and accounting systems. --- ## Fiscal Year Structure Because the fiscal year starts in the fourth month of Bikram Sambat (Shrawan), every fiscal cycle spans two calendar years: * **Format**: Standardized as `YYYY/YY` (e.g. `2081/82 BS`). * **Start Date**: `1 Shrawan` (Month index `3`, Day `1`). * **End Date**: `Last day of Ashadh` (Month index `2`, Day `31` or `32` of the succeeding calendar year). --- ## Fiscal Quarters (Trimesters) The financial year is divided into four 3-month quarters: | Quarter | Span (Bikram Sambat Months) | Typical Gregorian Span | Accounting Significance | | :--- | :--- | :--- | :--- | | **Q1** | 1 Shrawan – Last day of Ashwin | Mid-July to Mid-October | First trimester; Dashain festival preparations | | **Q2** | 1 Kartik – Last day of Poush | Mid-October to Mid-January | Second trimester; mid-term budget review | | **Q3** | 1 Magh – Last day of Chaitra | Mid-January to Mid-April | Third trimester; third-quarter corporate advance tax | | **Q4** | 1 Baisakh – Last day of Ashadh | Mid-April to Mid-July | Final trimester; annual financial closing & tax filing | > [!NOTE] > Notice that **Q4** takes place in the succeeding Bikram Sambat calendar year (Baisakh, Jestha, Ashadh). The library automatically increments the calendar year when calculating Q4 boundaries. --- ## Fiscal Quarters vs. Calendar Quarters `nepali-date-library` provides separate APIs for both systems: * **Fiscal Quarters**: Used for taxation, corporate accounting, and financial reporting. Runs **Shrawan to Ashadh**. * **Calendar Quarters**: Used for calendar quarters, seasonal reporting, and academic trimesters. Runs **Baisakh to Chaitra**. --- ## Section API Methods Explore each dedicated function reference: * [`NepaliDate.getCurrentFiscalYear()`](/docs/nodejs/fiscal-year/get-current-fiscal-year): Returns active fiscal year integer. * [`date.getCurrentFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter): Returns quarter number (`1 | 2 | 3 | 4`) for a date. * [`date.getCurrentFiscalYearQuarterDates()`](/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter-dates): Returns `{ start, end }` dates for current quarter. * [`NepaliDate.getFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarter): Calculates boundaries for any arbitrary quarter and year. * [`NepaliDate.getFiscalYearQuarters()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarters): Returns all four fiscal quarters in a single call. * [`Calendar Quarters`](/docs/nodejs/fiscal-year/calendar-quarters): Standard calendar quarters (`getQuarter` & `getQuarters`). --- ## Page: Calendar Quarters (NodeJS) (/docs/nodejs/fiscal-year/calendar-quarters) Description: [NodeJS] Explanation of standard Bikram Sambat calendar quarters compared to government fiscal trimesters. Official API reference and code examples for NodeJS / TypeScript. Standard calendar quarters divide the Bikram Sambat calendar year into four equal three month periods starting from 1 Baisakh. This guide clarifies the structural difference between standard calendar quarters and Nepal government fiscal year trimesters, which commence three months later on 1 Shrawan. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` ```javascript const { NepaliDate } = require("nepali-date-library"); ``` --- ## Signatures ```typescript static getQuarter( quarter: number, year?: number ): { start: NepaliDate; end: NepaliDate }; static getQuarters( year?: number ): { Q1: { start: NepaliDate; end: NepaliDate }; Q2: { start: NepaliDate; end: NepaliDate }; Q3: { start: NepaliDate; end: NepaliDate }; Q4: { start: NepaliDate; end: NepaliDate }; }; ``` --- ## Calendar Quarter Alignment | Quarter | Months (Bikram Sambat) | Span | | :--- | :--- | :--- | | **Q1** | Baisakh, Jestha, Ashadh | 1 Baisakh – Last day of Ashadh | | **Q2** | Shrawan, Bhadra, Ashwin | 1 Shrawan – Last day of Ashwin | | **Q3** | Kartik, Mangsir, Poush | 1 Kartik – Last day of Poush | | **Q4** | Magh, Falgun, Chaitra | 1 Magh – Last day of Chaitra | --- ## Examples ### Getting a Single Calendar Quarter ```typescript import { NepaliDate } from "nepali-date-library"; // Q1 of calendar year 2081 (Baisakh to Ashadh) const q1 = NepaliDate.getQuarter(1, 2081); console.log(q1.start.format("YYYY-MM-DD")); // "2081-01-01" console.log(q1.end.format("YYYY-MM-DD")); // "2081-03-31" ``` ### Getting All Four Calendar Quarters ```typescript import { NepaliDate } from "nepali-date-library"; // Default year is current year const quarters = NepaliDate.getQuarters(2081); console.log("Q1:", quarters.Q1.start.format("YYYY-MM-DD"), "to", quarters.Q1.end.format("YYYY-MM-DD")); console.log("Q2:", quarters.Q2.start.format("YYYY-MM-DD"), "to", quarters.Q2.end.format("YYYY-MM-DD")); console.log("Q3:", quarters.Q3.start.format("YYYY-MM-DD"), "to", quarters.Q3.end.format("YYYY-MM-DD")); console.log("Q4:", quarters.Q4.start.format("YYYY-MM-DD"), "to", quarters.Q4.end.format("YYYY-MM-DD")); ``` --- ## Related * [`NepaliDate.getFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarter): For official tax and accounting trimesters starting in Shrawan. * [`NepaliDate.getFiscalYearQuarters()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarters): All four fiscal quarters. --- ## Page: NepaliDate.getCurrentFiscalYear() (NodeJS) (/docs/nodejs/fiscal-year/get-current-fiscal-year) Description: [NodeJS] Method to retrieve the formatted fiscal year string for a given NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. The `getCurrentFiscalYear` method determines which official Nepalese fiscal year contains the current date instance. It returns a standardized fiscal year string such as 2081/82 based on whether the date falls before or after the 1 Shrawan fiscal transition boundary. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` ```javascript const { NepaliDate } = require("nepali-date-library"); ``` --- ## Signature ```typescript static getCurrentFiscalYear(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Description**: The 4-digit Bikram Sambat year representing the beginning of the active fiscal cycle. --- ## Behavioral Logic The method determines the current date and evaluates the month: * If current month is **Baisakh, Jestha, or Ashadh** (months 0, 1, or 2), the fiscal cycle began in the previous calendar year. Returns `currentYear - 1`. * If current month is **Shrawan through Chaitra** (months 3 through 11), the fiscal cycle began in the current calendar year. Returns `currentYear`. --- ## Examples ### Getting Current Fiscal Year Integer ```typescript import { NepaliDate } from "nepali-date-library"; // If today is 2081 Kartik 15: const fy = NepaliDate.getCurrentFiscalYear(); console.log(fy); // 2081 ``` ### Generating Formatted Fiscal Strings ```typescript import { NepaliDate } from "nepali-date-library"; function getFormattedFiscalYear(): string { const fy = NepaliDate.getCurrentFiscalYear(); const nextShort = String(fy + 1).slice(-2); return `${fy}/${nextShort}`; // e.g. "2081/82" } console.log(getFormattedFiscalYear()); // "2081/82" ``` ### Invoice Number Prefixing ```typescript import { NepaliDate } from "nepali-date-library"; function generateInvoiceNumber(sequence: number): string { const fy = NepaliDate.getCurrentFiscalYear(); const fyTag = `${String(fy).slice(-2)}${String(fy + 1).slice(-2)}`; // "8182" const paddedSeq = String(sequence).padStart(5, "0"); return `INV-${fyTag}-${paddedSeq}`; } console.log(generateInvoiceNumber(42)); // "INV-8182-00042" ``` --- ## Related * [`NepaliDate.getFiscalYearQuarters()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarters): Retrieve all quarter boundaries for this fiscal year. * [`date.getCurrentFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter): Get the quarter number for a specific date. --- ## Page: date.getCurrentFiscalYearQuarter() (NodeJS) (/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter) Description: [NodeJS] Method to calculate the active fiscal trimester quarter number for a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. The `getCurrentFiscalYearQuarter` method returns an integer from 1 to 4 representing the active fiscal trimester of the current date. Because Nepal fiscal calendar starts in Shrawan, quarter 1 covers Shrawan through Ashwin, quarter 2 spans Kartik through Poush, quarter 3 covers Magh through Chaitra, and quarter 4 spans Baisakh through Ashadh. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` ```javascript const { NepaliDate } = require("nepali-date-library"); ``` --- ## Signature ```typescript getCurrentFiscalYearQuarter(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Values**: `1 | 2 | 3 | 4` | Month (Bikram Sambat) | Month Index | Returned Quarter | | :--- | :---: | :---: | | Shrawan, Bhadra, Ashwin | `3`, `4`, `5` | `1` (Q1) | | Kartik, Mangsir, Poush | `6`, `7`, `8` | `2` (Q2) | | Magh, Falgun, Chaitra | `9`, `10`, `11` | `3` (Q3) | | Baisakh, Jestha, Ashadh | `0`, `1`, `2` | `4` (Q4) | --- ## Examples ### Determining Quarter of a Given Date ```typescript import { NepaliDate } from "nepali-date-library"; const dashainDate = new NepaliDate("2081-07-15"); // Kartik console.log(dashainDate.getCurrentFiscalYearQuarter()); // 2 (Q2) const endOfYearDate = new NepaliDate("2081-03-25"); // Ashadh console.log(endOfYearDate.getCurrentFiscalYearQuarter()); // 4 (Q4) ``` ### Financial Audit Filter ```typescript import { NepaliDate } from "nepali-date-library"; interface JournalEntry { description: string; date: NepaliDate; amount: number; } function filterByFiscalQuarter(entries: JournalEntry[], targetQuarter: number) { return entries.filter( (entry) => entry.date.getCurrentFiscalYearQuarter() === targetQuarter ); } ``` --- ## Related * [`date.getCurrentFiscalYearQuarterDates()`](/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter-dates): Retrieve the exact start and end dates for the active quarter. * [`NepaliDate.getFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarter): Static helper for any arbitrary quarter and year. --- ## Page: date.getCurrentFiscalYearQuarterDates() (NodeJS) (/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter-dates) Description: [NodeJS] Method to retrieve exact start and end boundary dates for the active fiscal quarter. Official API reference and code examples for NodeJS / TypeScript. The `getCurrentFiscalYearQuarterDates` method computes the exact starting date and ending date for the fiscal quarter containing the current date instance. It returns an object containing boundary dates as new NepaliDate objects, which is helpful for quarterly financial reporting, audit periods, and tax filing windows. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` ```javascript const { NepaliDate } = require("nepali-date-library"); ``` --- ## Signature ```typescript getCurrentFiscalYearQuarterDates(): { start: NepaliDate; end: NepaliDate }; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `{ start: NepaliDate; end: NepaliDate }` * **Structure**: * `start`: `NepaliDate` instance pointing to the first day of the quarter at `00:00:00.000`. * `end`: `NepaliDate` instance pointing to the final day of the quarter at `23:59:59.999`. --- ## Examples ### Getting Current Quarter Boundaries ```typescript import { NepaliDate } from "nepali-date-library"; // Assuming today is 2081 Kartik 15 (Q2): const today = new NepaliDate(); const { start, end } = today.getCurrentFiscalYearQuarterDates(); console.log(start.format("YYYY-MM-DD")); // "2081-07-01" (1 Kartik) console.log(end.format("YYYY-MM-DD")); // "2081-09-30" (Last day of Poush) ``` ### Database Query Boundary Filter ```typescript import { NepaliDate } from "nepali-date-library"; function getActiveQuarterFilter() { const now = new NepaliDate(); const { start, end } = now.getCurrentFiscalYearQuarterDates(); return { startGregorian: start.getEnglishDate(), endGregorian: end.getEnglishDate(), quarterIndex: now.getCurrentFiscalYearQuarter(), }; } ``` --- ## Related * [`NepaliDate.getFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarter): Static helper accepting an explicit quarter index. * [`NepaliDate.getFiscalYearQuarters()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarters): Retrieve all 4 quarters in one object. --- ## Page: NepaliDate.getFiscalYearQuarter() (NodeJS) (/docs/nodejs/fiscal-year/get-fiscal-year-quarter) Description: [NodeJS] Static method to determine the fiscal trimester number for any specified month index. Official API reference and code examples for NodeJS / TypeScript. The static `getFiscalYearQuarter` method determines the fiscal trimester number corresponding to a given Bikram Sambat month index from 0 to 11. It allows quick lookups without needing to instantiate a full NepaliDate object, making it useful in financial aggregation pipelines and reporting utilities. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` ```javascript const { NepaliDate } = require("nepali-date-library"); ``` --- ## Signature ```typescript static getFiscalYearQuarter( quarter: number, fiscalYear?: number ): { start: NepaliDate; end: NepaliDate }; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :--- | :--- | | `quarter` | `number` | Yes | - | Fiscal quarter index (`1`, `2`, `3`, or `4`). | | `fiscalYear` | `number` | No | Current FY | Base Bikram Sambat year of the fiscal cycle. | --- ## Return Value * **Type**: `{ start: NepaliDate; end: NepaliDate }` * **Properties**: * `start`: `NepaliDate` initialized to day 1 of the quarter's opening month. * `end`: `NepaliDate` initialized to the final day of the quarter's closing month at `23:59:59.999`. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Quarter must be an integer between 1 and 4` | Thrown if `quarter` is not an integer or is outside `1` to `4`. | --- ## Examples ### Querying Specific Quarter for Current Fiscal Year ```typescript import { NepaliDate } from "nepali-date-library"; // Get Q1 of the current fiscal year const q1 = NepaliDate.getFiscalYearQuarter(1); console.log(q1.start.format("YYYY-MM-DD")); // "2081-04-01" (1 Shrawan) console.log(q1.end.format("YYYY-MM-DD")); // "2081-06-30" (End of Ashwin) ``` ### Querying Cross-Year Quarter (Q4) ```typescript import { NepaliDate } from "nepali-date-library"; // Q4 of FY 2080/81 takes place in calendar year 2081 const q4 = NepaliDate.getFiscalYearQuarter(4, 2080); console.log(q4.start.format("YYYY-MM-DD")); // "2081-01-01" (1 Baisakh 2081) console.log(q4.end.format("YYYY-MM-DD")); // "2081-03-31" (End of Ashadh 2081) ``` --- ## Related * [`NepaliDate.getFiscalYearQuarters()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarters): Returns all four quarters in one call. * [`NepaliDate.getCurrentFiscalYear()`](/docs/nodejs/fiscal-year/get-current-fiscal-year): Returns current fiscal year integer. --- ## Page: NepaliDate.getFiscalYearQuarters() (NodeJS) (/docs/nodejs/fiscal-year/get-fiscal-year-quarters) Description: [NodeJS] Static utility returning all four fiscal trimesters with their constituent months and date ranges for a given year. Official API reference and code examples for NodeJS / TypeScript. The static `getFiscalYearQuarters` method returns a complete structural breakdown of all four fiscal trimesters for a specified Bikram Sambat year. Each quarter entry includes its trimester index, English and Nepali month names, and corresponding calendar boundary information. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` ```javascript const { NepaliDate } = require("nepali-date-library"); ``` --- ## Signature ```typescript static getFiscalYearQuarters(fiscalYear?: number): { Q1: { start: NepaliDate; end: NepaliDate }; Q2: { start: NepaliDate; end: NepaliDate }; Q3: { start: NepaliDate; end: NepaliDate }; Q4: { start: NepaliDate; end: NepaliDate }; }; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :--- | :--- | | `fiscalYear` | `number` | No | Current FY | Base Bikram Sambat year of the fiscal cycle (e.g. `2081`). | --- ## Return Value * **Type**: An object with keys `Q1`, `Q2`, `Q3`, and `Q4`. * **Structure**: * `Q1`: 1 Shrawan – Last day of Ashwin * `Q2`: 1 Kartik – Last day of Poush * `Q3`: 1 Magh – Last day of Chaitra * `Q4`: 1 Baisakh – Last day of Ashadh (in succeeding calendar year) --- ## Examples ### Getting Current Fiscal Year Quarters ```typescript import { NepaliDate } from "nepali-date-library"; const quarters = NepaliDate.getFiscalYearQuarters(); console.log("Q1 Start:", quarters.Q1.start.format("YYYY-MM-DD")); // 2081-04-01 console.log("Q1 End: ", quarters.Q1.end.format("YYYY-MM-DD")); // 2081-06-30 console.log("Q2 Start:", quarters.Q2.start.format("YYYY-MM-DD")); // 2081-07-01 console.log("Q2 End: ", quarters.Q2.end.format("YYYY-MM-DD")); // 2081-09-30 console.log("Q3 Start:", quarters.Q3.start.format("YYYY-MM-DD")); // 2081-10-01 console.log("Q3 End: ", quarters.Q3.end.format("YYYY-MM-DD")); // 2081-12-30 console.log("Q4 Start:", quarters.Q4.start.format("YYYY-MM-DD")); // 2082-01-01 console.log("Q4 End: ", quarters.Q4.end.format("YYYY-MM-DD")); // 2082-03-31 ``` ### Iterating for Financial Charts ```typescript import { NepaliDate } from "nepali-date-library"; const quarters = NepaliDate.getFiscalYearQuarters(2080); const quarterList = Object.entries(quarters).map(([quarterName, dates]) => ({ quarter: quarterName, startDateBS: dates.start.format("YYYY-MM-DD"), endDateBS: dates.end.format("YYYY-MM-DD"), startDateAD: dates.start.getEnglishDate().toISOString().split("T")[0], endDateAD: dates.end.getEnglishDate().toISOString().split("T")[0], })); console.log(quarterList); ``` --- ## Related * [`NepaliDate.getFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-fiscal-year-quarter): Retrieve a single quarter. * [`Calendar Quarters`](/docs/nodejs/fiscal-year/calendar-quarters): Standard calendar quarters aligned with Baisakh. --- ## Page: Installation & Setup (NodeJS) (/docs/nodejs/installation) Description: [NodeJS] Installation and setup guide for the nepali date library in Node.js and TypeScript applications using standard package managers. Official API reference and code examples for NodeJS / TypeScript. The nepali date library is distributed as a lightweight npm package compatible with modern JavaScript runtimes including Node.js, Bun, and Deno. It provides native TypeScript type definitions out of the box with zero runtime dependencies, making setup fast across all standard package managers. --- ## Package Installation ```bash pnpm add nepali-date-library ``` ```bash npm install nepali-date-library ``` ```bash yarn add nepali-date-library ``` ```bash bun add nepali-date-library ``` --- ## Import Syntax The package supports both ECMAScript Modules (ESM) and CommonJS (CJS) natively. ### ECMAScript Modules (TypeScript / Modern JS) ```typescript import { NepaliDate, ADtoBS, BStoAD } from "nepali-date-library"; // or default import import NepaliDate from "nepali-date-library"; ``` ### CommonJS ```javascript const { NepaliDate, ADtoBS, BStoAD } = require("nepali-date-library"); // or default require const NepaliDate = require("nepali-date-library"); ``` --- ## TypeScript Configuration `nepali-date-library` is written in TypeScript and ships with bundled type definitions (`.d.ts`). No additional `@types/` packages are required. Recommended `tsconfig.json` compiler options: ```json { "compilerOptions": { "target": "ES2020", "module": "NodeNext", "moduleResolution": "NodeNext", "strict": true, "esModuleInterop": true } } ``` --- ## Zero Dependencies The package has **0 runtime external dependencies**. It contains all astronomical calendar mappings, formatting tokens, and date arithmetic routines internally, guaranteeing small bundle size and zero transitive vulnerability risks. --- ## Page: date.addDays() (NodeJS) (/docs/nodejs/methods/add-days) Description: [NodeJS] Add or subtract a specified number of days to a NepaliDate instance with automatic month and year rollover. Official API reference and code examples for NodeJS / TypeScript. The `addDays` method modifies the current `NepaliDate` instance by adding or subtracting a given integer number of days. It automatically handles variable Bikram Sambat month day counts, transitions across month boundaries, and advances or decrements the year when needed. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript addDays(days: number): NepaliDate; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `days` | `number` | Yes | Integer number of days to add (positive) or subtract (negative). | --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` instance with the specified days added or subtracted. The original instance is not modified. --- ## Examples ### Adding Days Across Month Boundaries ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 25 (Baisakh 2081 has 31 days) const date = new NepaliDate("2081-01-25"); const next = date.addDays(10); console.log(next.format("YYYY-MM-DD")); // "2081-02-04" (4 Jestha) ``` ### Subtracting Days Across Year Boundaries ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 02 const date = new NepaliDate("2081-01-02"); const prev = date.addDays(-5); console.log(prev.format("YYYY-MM-DD")); // "2080-12-28" (28 Chaitra 2080) ``` ### Method Chaining ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-01") .addDays(15) .addDays(5); console.log(date.format("YYYY-MM-DD")); // "2081-01-21" ``` --- ## Related * [`date.addMonths()`](/docs/nodejs/methods/add-months): Add or subtract whole months. * [`date.diff()`](/docs/nodejs/methods/diff): Calculate the difference between two dates in days. --- ## Page: date.addMonths() (NodeJS) (/docs/nodejs/methods/add-months) Description: [NodeJS] Add or subtract months to a NepaliDate instance while adjusting for variable month lengths. Official API reference and code examples for NodeJS / TypeScript. The `addMonths` method advances or rewinds the current `NepaliDate` instance by a specified number of months. If the current day of the month exceeds the total days available in the destination month, the method automatically clamps the day to the final valid day of that month to ensure calendar consistency. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript addMonths(months: number): NepaliDate; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `months` | `number` | Yes | Number of months to add (positive) or subtract (negative). | --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` instance with the added or subtracted months. The original instance is not modified. --- ## Exceptions Throws an `Error` if the resulting year falls outside the supported Bikram Sambat calendar range (1976 BS to 2100 BS): ```typescript "Resulting date is out of supported range" ``` --- ## Examples ### Adding Months Within the Same Year ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 15 (month index 0) const date = new NepaliDate(2081, 0, 15); const future = date.addMonths(3); console.log(future.format("YYYY-MM-DD")); // "2081-04-15" (Shrawan) ``` ### Day Clamping on Shorter Months When transitioning into a month with fewer days, the day component automatically adjusts to the maximum valid day of that target month: ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 31 (Baisakh has 31 days) const date = new NepaliDate(2081, 0, 31); // Jestha 2081 has 32 days -> day remains 31 const jestha = date.addMonths(1); console.log(jestha.format("YYYY-MM-DD")); // "2081-02-31" // Kartik 2081 has 30 days -> day is clamped to 30 const kartik = date.addMonths(6); console.log(kartik.format("YYYY-MM-DD")); // "2081-07-30" ``` ### Subtracting Months Across Year Boundaries ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 10 const date = new NepaliDate(2081, 0, 10); const past = date.addMonths(-2); console.log(past.format("YYYY-MM-DD")); // "2080-11-10" (Falgun 2080) ``` --- ## Related * [`date.addDays()`](/docs/nodejs/methods/add-days): Add or subtract whole days. * [`date.addYears()`](/docs/nodejs/methods/add-years): Add or subtract whole years. * [`date.diff()`](/docs/nodejs/methods/diff): Calculate differences between two dates. --- ## Page: date.addYears() (NodeJS) (/docs/nodejs/methods/add-years) Description: [NodeJS] Add or subtract years to a NepaliDate instance while preserving month and day values. Official API reference and code examples for NodeJS / TypeScript. The `addYears` method adds or subtracts a specified number of years to the current `NepaliDate` instance. It recalculates the underlying timestamp while retaining the month and day coordinates, adjusting the day number if the target year has fewer days in that specific month. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript addYears(years: number): NepaliDate; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `years` | `number` | Yes | Number of years to add (positive) or subtract (negative). | --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` instance with the added or subtracted years. The original instance is not modified. --- ## Exceptions Throws an `Error` if the resulting year falls outside the supported Bikram Sambat calendar range (1976 BS to 2100 BS): ```typescript "Resulting date is out of supported range" ``` --- ## Examples ### Adding and Subtracting Years ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-05-15"); const future = date.addYears(5); console.log(future.format("YYYY-MM-DD")); // "2086-05-15" const past = date.addYears(-10); console.log(past.format("YYYY-MM-DD")); // "2071-05-15" ``` ### Day Clamping on Variable Month Lengths Because month lengths in the Bikram Sambat astronomical calendar vary across years, `addYears()` automatically clamps the day component if the destination year has fewer days in that month: ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 31 (Baisakh 2081 has 31 days) const date = new NepaliDate(2081, 0, 31); // If Baisakh in a target year has only 30 days, day clamps to 30 const nextYear = date.addYears(1); console.log(nextYear.getDate()); // Clamped to valid range ``` --- ## Related * [`date.addDays()`](/docs/nodejs/methods/add-days): Add or subtract whole days. * [`date.addMonths()`](/docs/nodejs/methods/add-months): Add or subtract whole months. * [`date.diff()`](/docs/nodejs/methods/diff): Calculate differences between two dates. --- ## Page: date.clone() (NodeJS) (/docs/nodejs/methods/clone) Description: [NodeJS] Create an independent deep clone of an existing NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. The `clone` method creates and returns an independent duplicate of the current `NepaliDate` instance. Because several library arithmetic and mutation methods alter instances in place, creating a clone allows you to perform calculations without modifying the original date object. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript clone(): NepaliDate; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `NepaliDate` * Returns a new independent `NepaliDate` instance initialized with the exact state of the current instance. --- ## Examples ### Creating an Independent Duplicate ```typescript import { NepaliDate } from "nepali-date-library"; const original = new NepaliDate("2081-01-15"); const duplicate = original.clone(); // Mutating duplicate does not impact original duplicate.setDate(20); console.log(original.format("YYYY-MM-DD")); // "2081-01-15" console.log(duplicate.format("YYYY-MM-DD")); // "2081-01-20" ``` --- ## Related * [`new NepaliDate()`](/docs/nodejs/class/constructor): Class constructor supporting copy-construction from another instance. * [`date.format()`](/docs/nodejs/methods/format): Format instance to string. --- ## Page: date.daysInMonth() (NodeJS) (/docs/nodejs/methods/days-in-month) Description: [NodeJS] Retrieve the total number of days in the current or specified Bikram Sambat month. Official API reference and code examples for NodeJS / TypeScript. The `daysInMonth` method returns the total number of days present in the active month of the current `NepaliDate` instance, or for an explicitly provided year and month combination. Because Bikram Sambat month durations vary from 29 to 32 days depending on astronomical solar calculations, this method provides accurate month lengths. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript daysInMonth(year?: number, month?: number): number; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `year` | `number` | No | `this.year` | Bikram Sambat year (e.g. `2081`). | | `month` | `number` | No | `this.month` | Zero-indexed month (`0-11`, where `0` is Baisakh and `11` is Chaitra). | --- ## Return Value * **Type**: `number` * The number of days in the specified month (typically between 29 and 32 days). --- ## Exceptions Throws an `Error` if `month` is explicitly provided and is less than 0 or greater than 11: ```typescript "Invalid month index, must be between 0-11" ``` --- ## Examples ### Querying the Current Instance Month ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh const date = new NepaliDate(2081, 0, 15); console.log(date.daysInMonth()); // 31 ``` ### Querying an Arbitrary Year and Month ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); // Querying Jestha 2081 (month index 1) const jesthaDays = date.daysInMonth(2081, 1); console.log(jesthaDays); // 32 // Querying Chaitra 2080 (month index 11) const chaitraDays = date.daysInMonth(2080, 11); console.log(chaitraDays); // 30 ``` --- ## Related * [`date.getWeeksInMonth()`](/docs/nodejs/methods/get-weeks-in-month): Compute number of calendar week rows. * [`NepaliDate.getCalendarDays()`](/docs/nodejs/static/get-calendar-days): Generate month grid with padding. --- ## Page: date.diff() (NodeJS) (/docs/nodejs/methods/diff) Description: [NodeJS] Calculate the chronological difference between two NepaliDate instances in specific time units. Official API reference and code examples for NodeJS / TypeScript. The `diff` method calculates the elapsed time duration between the current `NepaliDate` instance and another date object. It can return the difference in days, months, years, hours, minutes, seconds, or milliseconds, making it suitable for calculating age, tenure, or interval durations. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript diff(date: NepaliDate, unit: "year" | "month" | "day"): number; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | The target `NepaliDate` instance to compare against. | | `unit` | `"year" \| "month" \| "day"` | Yes | The unit of measurement for the difference calculation. | --- ## Return Value * **Type**: `number` * The numeric difference between the two dates (`this - date`). * Positive if the current date is after `date`. * Negative if the current date is before `date`. * Zero if they are identical in the evaluated unit. --- ## Calculation Rules * **`"day"`**: Computed using Unix timestamps: `Math.floor((this.getTime() - date.getTime()) / 86400000)`. * **`"month"`**: Computed using calendar month indices: `(this.year - date.year) * 12 + (this.month - date.month)`. * **`"year"`**: Computed by year difference: `this.year - date.year`. --- ## Exceptions Throws an `Error` if an invalid unit string is supplied: ```typescript "Invalid unit for diff calculation" ``` --- ## Examples ### Difference in Days ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-01-20"); const date2 = new NepaliDate("2081-01-05"); console.log(date1.diff(date2, "day")); // 15 console.log(date2.diff(date1, "day")); // -15 ``` ### Difference in Months ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-06-15"); const date2 = new NepaliDate("2080-04-15"); console.log(date1.diff(date2, "month")); // 14 ``` ### Difference in Years ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2085-01-01"); const date2 = new NepaliDate("2081-01-01"); console.log(date1.diff(date2, "year")); // 4 ``` --- ## Related * [`date.isBefore()`](/docs/nodejs/methods/is-before): Check if a date precedes another. * [`date.isAfter()`](/docs/nodejs/methods/is-after): Check if a date succeeds another. * [`date.isEqual()`](/docs/nodejs/methods/is-equal): Check if two dates are equal. --- ## Page: date.endOfDay() (NodeJS) (/docs/nodejs/methods/end-of-day) Description: [NodeJS] Return a new NepaliDate instance set to the final millisecond of the current day. Official API reference and code examples for NodeJS / TypeScript. The `endOfDay` method returns a new `NepaliDate` instance with time coordinates set to the final moment of the day at 23 hours, 59 minutes, 59 seconds, and 999 milliseconds. This is commonly used when setting upper boundaries for database queries, event schedules, and daily audit filters. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript endOfDay(): NepaliDate; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `NepaliDate` * Returns a new cloned `NepaliDate` instance set to `23:59:59.999` on the same calendar day. The original instance is not modified. --- ## Examples ### Generating End-of-Day Timestamp ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-05-15"); const end = date.endOfDay(); console.log(end.getHours()); // 23 console.log(end.getMinutes()); // 59 console.log(end.getSeconds()); // 59 console.log(end.getMilliseconds()); // 999 ``` ### Inclusive Day Range Filtering ```typescript import { NepaliDate } from "nepali-date-library"; // Set upper bound for date filters const reportDate = new NepaliDate("2081-01-31").endOfDay(); console.log(reportDate.getTime()); // Unix timestamp in milliseconds ``` --- ## Related * [`date.startOfDay()`](/docs/nodejs/methods/start-of-day): Return start of the day (`00:00:00.000`). * [`date.endOfMonth()`](/docs/nodejs/methods/end-of-month): Return final millisecond of the month. * [`date.endOfYear()`](/docs/nodejs/methods/end-of-year): Return final millisecond of the year. --- ## Page: date.endOfMonth() (NodeJS) (/docs/nodejs/methods/end-of-month) Description: [NodeJS] Return a new NepaliDate instance set to the final day of the current Bikram Sambat month. Official API reference and code examples for NodeJS / TypeScript. The `endOfMonth` method returns a new `NepaliDate` instance positioned on the last valid calendar day of the active month. It automatically checks the calendar map to determine whether the month ends on day 29, 30, 31, or 32, which is useful for monthly reporting and billing cycles. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript endOfMonth(): NepaliDate; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` set to the last calendar day of the month at `23:59:59.999`. The original instance is not modified. --- ## Examples ### Determining Last Day of the Month ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh (which has 31 days) const date = new NepaliDate(2081, 0, 10); const lastDay = date.endOfMonth(); console.log(lastDay.getDate()); // 31 console.log(lastDay.format("YYYY-MM-DD")); // "2081-01-31" console.log(lastDay.getHours()); // 23 console.log(lastDay.getMinutes()); // 59 ``` ### Variable Month Ends Across Years ```typescript import { NepaliDate } from "nepali-date-library"; // 2080 Chaitra has 30 days const chaitra2080 = new NepaliDate(2080, 11, 1).endOfMonth(); console.log(chaitra2080.getDate()); // 30 // 2081 Chaitra has 30 days const chaitra2081 = new NepaliDate(2081, 11, 1).endOfMonth(); console.log(chaitra2081.getDate()); // 30 ``` --- ## Related * [`date.startOfMonth()`](/docs/nodejs/methods/start-of-month): Return the first day of the current month. * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Query total days in the month. * [`date.endOfYear()`](/docs/nodejs/methods/end-of-year): Return the last day of the year. --- ## Page: date.endOfWeek() (NodeJS) (/docs/nodejs/methods/end-of-week) Description: [NodeJS] Return a new NepaliDate instance set to the final day of the current week on Saturday. Official API reference and code examples for NodeJS / TypeScript. The `endOfWeek` method produces a new `NepaliDate` instance representing the last day of the week containing the current date. In standard Nepali calendar practice, Saturday is regarded as the final day of the weekly cycle. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript endOfWeek(startOfWeek?: number): NepaliDate; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `startOfWeek` | `number` | No | `0` | Day of week index (`0-6`) that defines when the week begins. By default, `0` (Sunday) is the start, making Saturday (6) the end. | --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` instance set to the end of the final day of the week (`23:59:59.999`). The original instance is not modified. --- ## Exceptions Throws an `Error` if `startOfWeek` is not an integer between `0` and `6`: ```typescript "startOfWeek must be an integer between 0 and 6" ``` --- ## Examples ### Default Week End (Saturday 23:59:59) ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-02-16"); const weekEnd = date.endOfWeek(); console.log(weekEnd.getDay()); // 6 (Saturday) console.log(weekEnd.getHours()); // 23 console.log(weekEnd.getMinutes()); // 59 ``` ### Custom Week Ending on Sunday ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-02-16"); // Week starts on Monday (1), meaning it ends on Sunday (0) const weekEnd = date.endOfWeek(1); console.log(weekEnd.getDay()); // 0 (Sunday) ``` --- ## Related * [`date.startOfWeek()`](/docs/nodejs/methods/start-of-week): Return the beginning of the week. * [`date.endOfDay()`](/docs/nodejs/methods/end-of-day): Return end of the day. * [`date.getDay()`](/docs/nodejs/methods/get-day): Get current day of week index (`0-6`). --- ## Page: date.endOfYear() (NodeJS) (/docs/nodejs/methods/end-of-year) Description: [NodeJS] Return a new NepaliDate instance set to the final day of the Bikram Sambat year on the last day of Chaitra. Official API reference and code examples for NodeJS / TypeScript. The `endOfYear` method returns a new `NepaliDate` instance set to the closing day of the current Bikram Sambat calendar year. This corresponds to the final day of Chaitra, which is commonly needed for annual reconciliations and fiscal year preparations. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript endOfYear(): NepaliDate; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` set to the last day of Chaitra for the given year at `23:59:59.999`. The original instance is not modified. --- ## Examples ### Getting the Final Day of the Calendar Year ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-03-15"); const yearEnd = date.endOfYear(); console.log(yearEnd.format("YYYY-MM-DD")); // "2081-12-30" console.log(yearEnd.getMonth()); // 11 (Chaitra) console.log(yearEnd.getHours()); // 23 console.log(yearEnd.getMinutes()); // 59 console.log(yearEnd.getSeconds()); // 59 ``` ### Full Calendar Year Span ```typescript import { NepaliDate } from "nepali-date-library"; const year = 2081; const start = new NepaliDate(year, 0, 1).startOfDay(); const end = new NepaliDate(year, 0, 1).endOfYear(); console.log(`Year ${year} spans from ${start.format("YYYY-MM-DD")} to ${end.format("YYYY-MM-DD")}`); ``` --- ## Related * [`date.startOfYear()`](/docs/nodejs/methods/start-of-year): Return the first day of the Bikram Sambat year. * [`date.endOfMonth()`](/docs/nodejs/methods/end-of-month): Return the final day of the current month. * [`date.isLeapYear()`](/docs/nodejs/methods/is-leap-year): Check if the year has 366 days. --- ## Page: date.format() (NodeJS) (/docs/nodejs/methods/format) Description: [NodeJS] Format a NepaliDate instance into a custom string using token patterns for English and Nepali output. Official API reference and code examples for NodeJS / TypeScript. The `format` method transforms a `NepaliDate` instance into a formatted string according to a pattern of token specifiers. It supports tokens for year, month, day, weekday, hours, minutes, and seconds, with full support for localized English names as well as Devanagari script numerals and words. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript format(formatStr: string): string; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `formatStr` | `string` | Yes | Formatting template string containing pattern tokens. | --- ## Return Value * **Type**: `string` * The formatted date string with all tokens substituted. --- ## Token Reference Uppercase characters produce English representations, while lowercase characters produce Devanagari (Nepali) representations. ### Year Tokens | Token | Output | Description | Example (2081 BS) | | :--- | :--- | :--- | :--- | | `YYYY` | English 4-digit year | Full Gregorian-style digit year | `"2081"` | | `YYY` | English 3-digit year | Last 3 digits | `"081"` | | `YY` | English 2-digit year | Last 2 digits | `"81"` | | `yyyy` | Nepali 4-digit year | Devanagari numerals | `"२०८१"` | | `yyy` | Nepali 3-digit year | Last 3 digits in Devanagari | `"०८१"` | | `yy` | Nepali 2-digit year | Last 2 digits in Devanagari | `"८१"` | ### Month Tokens | Token | Output | Description | Example (Baisakh) | | :--- | :--- | :--- | :--- | | `M` | English 1-digit | Month number (`1-12`) | `"1"` | | `MM` | English 2-digit | Zero-padded month number (`01-12`) | `"01"` | | `MMM` | English 3-letter | Abbreviated month name | `"Bai"` | | `MMMM` | English Full | Complete romanized month name | `"Baisakh"` | | `m` | Nepali 1-digit | Devanagari month number (`१-१२`) | `"१"` | | `mm` | Nepali 2-digit | Zero-padded Devanagari month number | `"०१"` | | `mmm` | Nepali Short | Abbreviated Devanagari month name | `"बै"` | | `mmmm` | Nepali Full | Complete Devanagari month name | `"बैशाख"` | ### Day and Weekday Tokens | Token | Output | Description | Example (Day 5, Sunday) | | :--- | :--- | :--- | :--- | | `D` | English 1-digit | Day of the month (`1-32`) | `"5"` | | `DD` | English 2-digit | Zero-padded day of the month (`01-32`) | `"05"` | | `DDD` | English Short | Abbreviated weekday name | `"Sun"` | | `DDDD` | English Full | Complete weekday name | `"Sunday"` | | `d` | Nepali 1-digit | Devanagari day of the month (`१-३२`) | `"५"` | | `dd` | Nepali 2-digit | Zero-padded Devanagari day of the month | `"०५"` | | `ddd` | Nepali Short | Abbreviated Devanagari weekday | `"आइत"` | | `dddd` | Nepali Full | Complete Devanagari weekday | `"आइतबार"` | --- ## Escaping Literal Characters To include literal characters that conflict with format tokens (such as `M`, `D`, `Y`, `m`, `d`, `y`), wrap the text inside double quotes (`"`): ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-25"); const formatted = date.format('"Date:" YYYY-MM-DD'); console.log(formatted); // 'Date: 2081-01-25' ``` --- ## Examples ### Standard ISO-Style Formatting ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-05"); console.log(date.format("YYYY-MM-DD")); // "2081-01-05" console.log(date.format("YYYY/MM/DD")); // "2081/01/05" ``` ### Full English Date with Weekday ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-25"); console.log(date.format("DDDD, MMMM DD, YYYY")); // "Thursday, Baisakh 25, 2081" ``` ### Native Nepali Devanagari Formatting ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-25"); console.log(date.format("dddd, mmmm dd, yyyy")); // "बिहिबार, बैशाख २५, २०८१" console.log(date.format("yyyy-mm-dd")); // "२०८१-०१-२५" ``` --- ## Related * [`date.toString()`](/docs/nodejs/methods/to-string): Default `YYYY/MM/DD` string representation. * [`MONTH_EN`](/docs/nodejs/constants/month-en): Array of English month names. * [`MONTH_NP`](/docs/nodejs/constants/month-np): Array of Nepali month names. --- ## Page: date.getCurrentQuarter() (NodeJS) (/docs/nodejs/methods/get-current-quarter) Description: [NodeJS] Return the standard Bikram Sambat calendar quarter number from one to four for the current date. Official API reference and code examples for NodeJS / TypeScript. The `getCurrentQuarter` method returns an integer from 1 to 4 designating the standard calendar quarter containing the current date. Calendar quarters divide the Bikram Sambat year into four sequential segments starting from 1 Baisakh, which differs from government fiscal trimesters that commence in Shrawan. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getCurrentQuarter(): number; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `number` * The calendar quarter integer (`1`, `2`, `3`, or `4`): * `1`: Baisakh, Jestha, Asar (Months `0-2`) * `2`: Shrawan, Bhadra, Aswin (Months `3-5`) * `3`: Kartik, Mangsir, Poush (Months `6-8`) * `4`: Magh, Falgun, Chaitra (Months `9-11`) --- ## Note on Fiscal Quarters Calendar quarters follow the Baisakh-to-Chaitra annual cycle. If you require Government of Nepal / IRD fiscal quarters (which begin in Shrawan), use [`date.getCurrentFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter) instead. --- ## Examples ### Determining Current Calendar Quarter ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 15 (month index 0) const date1 = new NepaliDate(2081, 0, 15); console.log(date1.getCurrentQuarter()); // 1 // 2081 Shrawan 1 (month index 3) const date2 = new NepaliDate(2081, 3, 1); console.log(date2.getCurrentQuarter()); // 2 // 2081 Kartik 10 (month index 6) const date3 = new NepaliDate(2081, 6, 10); console.log(date3.getCurrentQuarter()); // 3 // 2081 Magh 20 (month index 9) const date4 = new NepaliDate(2081, 9, 20); console.log(date4.getCurrentQuarter()); // 4 ``` --- ## Related * [`NepaliDate.getQuarter()`](/docs/nodejs/fiscal-year/calendar-quarters): Get start and end dates for a specific calendar quarter. * [`date.getCurrentFiscalYearQuarter()`](/docs/nodejs/fiscal-year/get-current-fiscal-year-quarter): Get the Nepali fiscal quarter (`1-4`). --- ## Page: date.getDate() (NodeJS) (/docs/nodejs/methods/get-date) Description: [NodeJS] Retrieve the numeric day of the month from a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. The `getDate` method returns the day of the month as an integer from 1 to 32 for the current `NepaliDate` instance. Unlike Gregorian months which have at most 31 days, Bikram Sambat calendar months can extend up to 32 days depending on the year and month. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getDate(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `1` to `32` (depending on the month and year). --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-07-15"); console.log(date.getDate()); // 15 ``` --- ## Related * [`date.setDate()`](/docs/nodejs/methods/set-date): Mutate the day of the month. * [`date.getDay()`](/docs/nodejs/methods/get-day): Retrieve the day of the week (0–6). * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Query total days in this month. --- ## Page: date.getDay() (NodeJS) (/docs/nodejs/methods/get-day) Description: [NodeJS] Retrieve the numeric day of the week index from zero for Sunday through six for Saturday. Official API reference and code examples for NodeJS / TypeScript. The `getDay` method returns an integer representing the day of the week for the current `NepaliDate` instance. The return value ranges from 0 for Sunday to 6 for Saturday, aligning with standard JavaScript date conventions. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getDay(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `0` to `6` | Index | Weekday (English) | Weekday (Devanagari) | | :---: | :--- | :--- | | `0` | Sunday | आइतबार | | `1` | Monday | सोमबार | | `2` | Tuesday | मङ्गलबार | | `3` | Wednesday | बुधबार | | `4` | Thursday | बिहिबार | | `5` | Friday | शुक्रबार | | `6` | Saturday | शनिबार | --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Kartik 15 fell on a Friday const date = new NepaliDate("2081-07-15"); console.log(date.getDay()); // 5 ``` --- ## Related * [`NepaliDate.getDayName()`](/docs/nodejs/static/get-day-name): Retrieve the weekday string name. * [`date.getDate()`](/docs/nodejs/methods/get-date): Retrieve the day of the month (1–32). --- ## Page: date.getEnglishDate() (NodeJS) (/docs/nodejs/methods/get-english-date) Description: [NodeJS] Retrieve the equivalent Gregorian date as a native JavaScript Date object. Official API reference and code examples for NodeJS / TypeScript. The `getEnglishDate` method returns the native JavaScript Date object corresponding to the current `NepaliDate` instance. This allows seamless integration with third party libraries, databases, and standard browser APIs that expect a native Gregorian Date object. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getEnglishDate(): Date; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `Date` * **Description**: A standard JavaScript `Date` instance calibrated in UTC. --- ## Examples ### Converting to Native JavaScript Date ```typescript import { NepaliDate } from "nepali-date-library"; const nepaliDate = new NepaliDate("2081-07-15"); const jsDate = nepaliDate.getEnglishDate(); console.log(jsDate instanceof Date); // true console.log(jsDate.toISOString()); // "2024-10-31T00:00:00.000Z" console.log(jsDate.getUTCFullYear()); // 2024 console.log(jsDate.getUTCMonth()); // 9 (October, 0-indexed) console.log(jsDate.getUTCDate()); // 31 ``` ### Passing to Third-Party Date Utilities ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-01"); const englishDate = date.getEnglishDate(); // Interoperable with Intl.DateTimeFormat or external libraries const formatted = new Intl.DateTimeFormat("en-US", { dateStyle: "full", timeZone: "UTC", }).format(englishDate); console.log(formatted); // "Saturday, April 13, 2024" ``` --- ## Related * [`BStoAD()`](/docs/nodejs/date-converter/bs-to-ad): Standalone helper returning a formatted string instead of a `Date` object. * [`new NepaliDate(date)`](/docs/nodejs/class/constructor): Constructing a `NepaliDate` from a JavaScript `Date`. --- ## Page: date.getHours() (NodeJS) (/docs/nodejs/methods/get-hours) Description: [NodeJS] Retrieve the hour component from zero to twenty three for the current date instance. Official API reference and code examples for NodeJS / TypeScript. The `getHours` method returns the hour of the day as an integer between 0 and 23 for the current `NepaliDate` instance. It reflects local time coordinates stored within the instance timestamp. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getHours(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `0` to `23` --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); console.log(date.getHours()); // e.g. 14 ``` --- ## Related * [`date.getMinutes()`](/docs/nodejs/methods/get-minutes): Retrieve the minute component. * [`date.getSeconds()`](/docs/nodejs/methods/get-seconds): Retrieve the second component. --- ## Page: date.getMilliseconds() (NodeJS) (/docs/nodejs/methods/get-milliseconds) Description: [NodeJS] Retrieve the millisecond component from zero to nine hundred ninety nine. Official API reference and code examples for NodeJS / TypeScript. The `getMilliseconds` method returns the millisecond fraction of the current second as an integer from 0 to 999. It provides high resolution timing details for precision logging and event timestamping. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getMilliseconds(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `0` to `999` --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); console.log(date.getMilliseconds()); // e.g. 512 ``` --- ## Related * [`date.getSeconds()`](/docs/nodejs/methods/get-seconds): Retrieve the second component. * [`date.getTime()`](/docs/nodejs/methods/get-time): Retrieve the full epoch timestamp. --- ## Page: date.getMinutes() (NodeJS) (/docs/nodejs/methods/get-minutes) Description: [NodeJS] Retrieve the minute component from zero to fifty nine for the current date instance. Official API reference and code examples for NodeJS / TypeScript. The `getMinutes` method returns the minute value as an integer from 0 to 59 for the current `NepaliDate` instance. It is derived from the underlying timestamp representing the recorded time of the date object. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getMinutes(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `0` to `59` --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); console.log(date.getMinutes()); // e.g. 35 ``` --- ## Related * [`date.getHours()`](/docs/nodejs/methods/get-hours): Retrieve the hour component. * [`date.getSeconds()`](/docs/nodejs/methods/get-seconds): Retrieve the second component. --- ## Page: date.getMonth() (NodeJS) (/docs/nodejs/methods/get-month) Description: [NodeJS] Retrieve the zero based Bikram Sambat month index from zero for Baisakh to eleven for Chaitra. Official API reference and code examples for NodeJS / TypeScript. The `getMonth` method returns the month of the year as an integer between 0 and 11 for the current `NepaliDate` instance. The library adheres to the JavaScript zero based indexing standard where 0 represents Baisakh, 1 represents Jestha, and 11 represents Chaitra. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getMonth(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `0` to `11` | Index | Month (English) | Month (Devanagari) | | :---: | :--- | :--- | | `0` | Baisakh | बैशाख | | `1` | Jestha | जेठ | | `2` | Ashadh / Asar | असार | | `3` | Shrawan | श्रावण | | `4` | Bhadra | भाद्र | | `5` | Ashwin / Aswin | आश्विन | | `6` | Kartik | कार्तिक | | `7` | Mangsir | मंसिर | | `8` | Poush | पौष | | `9` | Magh | माघ | | `10` | Falgun | फाल्गुण | | `11` | Chaitra | चैत्र | --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Kartik 15 const date = new NepaliDate("2081-07-15"); console.log(date.getMonth()); // 6 (0-indexed) console.log(date.getMonth() + 1); // 7 (1-indexed for display) ``` --- ## Related * [`date.setMonth()`](/docs/nodejs/methods/set-month): Mutate the month component. * [`NepaliDate.getMonthName()`](/docs/nodejs/static/get-month-name): Get the localized string name for a month index. --- ## Page: date.getSeconds() (NodeJS) (/docs/nodejs/methods/get-seconds) Description: [NodeJS] Retrieve the second component from zero to fifty nine for the current date instance. Official API reference and code examples for NodeJS / TypeScript. The `getSeconds` method returns the second value as an integer from 0 to 59 for the current `NepaliDate` instance. It enables precise second level timing and formatting. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getSeconds(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `0` to `59` --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); console.log(date.getSeconds()); // e.g. 42 ``` --- ## Related * [`date.getMinutes()`](/docs/nodejs/methods/get-minutes): Retrieve the minute component. * [`date.getMilliseconds()`](/docs/nodejs/methods/get-milliseconds): Retrieve the millisecond component. --- ## Page: date.getTime() (NodeJS) (/docs/nodejs/methods/get-time) Description: [NodeJS] Retrieve the numeric timestamp in milliseconds since the Unix epoch. Official API reference and code examples for NodeJS / TypeScript. The `getTime` method returns the number of milliseconds elapsed since the Unix epoch of January 1, 1970 UTC. This integer value matches the return value of native JavaScript Date getTime and allows direct numerical comparison between date instances. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getTime(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Description**: Integer representing milliseconds since January 1, 1970 UTC. --- ## Examples ### Getting Unix Epoch Timestamp ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-07-15"); console.log(date.getTime()); // 1730332800000 ``` ### Direct Mathematical Timestamp Comparison ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-01-01"); const date2 = new NepaliDate("2081-02-01"); const diffMs = date2.getTime() - date1.getTime(); const diffDays = diffMs / (1000 * 60 * 60 * 24); console.log(diffDays); // 31 ``` --- ## Related * [`date.getEnglishDate()`](/docs/nodejs/methods/get-english-date): Retrieve the native JavaScript `Date` object. * [`new NepaliDate(timestamp)`](/docs/nodejs/class/constructor): Recreate a `NepaliDate` from an epoch timestamp. --- ## Page: date.getWeeksInMonth() (NodeJS) (/docs/nodejs/methods/get-weeks-in-month) Description: [NodeJS] Calculate the number of calendar week rows required to render the current month in a grid. Official API reference and code examples for NodeJS / TypeScript. The `getWeeksInMonth` method computes the total number of seven day week rows required to display the entire month in a standard calendar grid. Depending on which weekday the month starts on and how many days it contains, the returned count is usually five or six rows. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getWeeksInMonth(): number; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `number` * The number of calendar week rows needed (typically `5` or `6`). --- ## Formula The calculation evaluates the weekday offset of the 1st of the month added to the month's total days, divided by 7: ```typescript Math.ceil((firstDayOfWeek + totalDays) / 7) ``` --- ## Examples ### Sizing UI Calendar Views ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-15"); const rowCount = date.getWeeksInMonth(); console.log(`Calendar requires ${rowCount} week rows.`); ``` --- ## Related * [`NepaliDate.getCalendarDays()`](/docs/nodejs/static/get-calendar-days): Generate calendar matrix with leading and trailing days. * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Total number of days in the month. --- ## Page: date.getYear() (NodeJS) (/docs/nodejs/methods/get-year) Description: [NodeJS] Retrieve the four digit Bikram Sambat year number from a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. The `getYear` method returns the full four digit Bikram Sambat year as an integer for the current `NepaliDate` instance. Unlike legacy JavaScript Date getYear which returns years minus 1900, this method returns the complete calendar year such as 2081 within the supported range of 1976 through 2100 BS. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript getYear(): number; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `number` * **Range**: `1976` to `2100` * **Description**: Full 4-digit Bikram Sambat year integer. --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-07-15"); console.log(date.getYear()); // 2081 ``` --- ## Related * [`date.setYear()`](/docs/nodejs/methods/set-year): Mutate the year component. * [`date.getMonth()`](/docs/nodejs/methods/get-month): Retrieve the month component. --- ## Page: date.isAfter() (NodeJS) (/docs/nodejs/methods/is-after) Description: [NodeJS] Check whether the current date occurs chronologically after another specified date. Official API reference and code examples for NodeJS / TypeScript. The `isAfter` method evaluates whether the current `NepaliDate` instance occurs chronologically later than another date or timestamp. It compares exact millisecond values to determine chronological order accurately. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript isAfter(date: NepaliDate): boolean; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Target `NepaliDate` instance to compare against. | --- ## Return Value * **Type**: `boolean` * Returns `true` if the current date and time succeeds the provided `date` in absolute time; otherwise returns `false`. --- ## Precision Comparison is evaluated down to the exact millisecond using the underlying Unix timestamp: ```typescript this.timestamp.getTime() > date.timestamp.getTime() ``` --- ## Examples ### Chronological Comparison ```typescript import { NepaliDate } from "nepali-date-library"; const releaseDate = new NepaliDate("2081-05-01"); const currentDate = new NepaliDate("2081-06-10"); console.log(currentDate.isAfter(releaseDate)); // true console.log(releaseDate.isAfter(currentDate)); // false ``` ### Checking Expiration or Deadlines ```typescript import { NepaliDate } from "nepali-date-library"; const deadline = new NepaliDate("2081-02-30").endOfDay(); const submission = new NepaliDate(); if (submission.isAfter(deadline)) { console.log("Submission window has closed."); } ``` --- ## Related * [`date.isBefore()`](/docs/nodejs/methods/is-before): Check if a date precedes another. * [`date.isEqual()`](/docs/nodejs/methods/is-equal): Check if calendar dates are identical. * [`date.isSame()`](/docs/nodejs/methods/is-same): Check equality by specific unit. --- ## Page: date.isBefore() (NodeJS) (/docs/nodejs/methods/is-before) Description: [NodeJS] Check whether the current date occurs chronologically before another specified date. Official API reference and code examples for NodeJS / TypeScript. The `isBefore` method evaluates whether the current `NepaliDate` instance occurs earlier in time than another provided date. It takes into account both date and time components down to millisecond accuracy. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript isBefore(date: NepaliDate): boolean; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Target `NepaliDate` instance to compare against. | --- ## Return Value * **Type**: `boolean` * Returns `true` if the current date and time precedes the provided `date` in absolute time; otherwise returns `false`. --- ## Precision Comparison is evaluated down to the exact millisecond using the underlying Unix timestamp: ```typescript this.timestamp.getTime() < date.timestamp.getTime() ``` --- ## Examples ### Chronological Comparison ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-01-15"); const date2 = new NepaliDate("2081-01-20"); console.log(date1.isBefore(date2)); // true console.log(date2.isBefore(date1)); // false ``` ### Time-Level Comparison ```typescript import { NepaliDate } from "nepali-date-library"; const morning = new NepaliDate("2081-01-15").startOfDay(); const evening = new NepaliDate("2081-01-15").endOfDay(); console.log(morning.isBefore(evening)); // true ``` --- ## Related * [`date.isAfter()`](/docs/nodejs/methods/is-after): Check if a date succeeds another. * [`date.isEqual()`](/docs/nodejs/methods/is-equal): Check if calendar dates are identical. * [`date.isSame()`](/docs/nodejs/methods/is-same): Check equality by specific unit (year, month, day). --- ## Page: date.isEqual() (NodeJS) (/docs/nodejs/methods/is-equal) Description: [NodeJS] Check whether two date instances share the exact same calendar date coordinates regardless of time. Official API reference and code examples for NodeJS / TypeScript. The `isEqual` method checks whether the current `NepaliDate` instance shares the exact same Bikram Sambat year, month, and day coordinates as another date object, ignoring any differences in hours, minutes, seconds, or milliseconds. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript isEqual(date: NepaliDate): boolean; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Target `NepaliDate` instance to compare against. | --- ## Return Value * **Type**: `boolean` * Returns `true` if `year`, `month`, and `day` are identical; otherwise returns `false`. --- ## Behavior Note Unlike `isBefore()` and `isAfter()`, which compare millisecond-level timestamps, `isEqual()` evaluates calendar dates only: ```typescript this.year === date.year && this.month === date.month && this.day === date.day ``` Two instances created at different times of the same day will return `true`. --- ## Examples ### Comparing Calendar Dates ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-01-15"); const date2 = new NepaliDate(2081, 0, 15); console.log(date1.isEqual(date2)); // true ``` ### Time Component Independence ```typescript import { NepaliDate } from "nepali-date-library"; const morning = new NepaliDate("2081-01-15").startOfDay(); const evening = new NepaliDate("2081-01-15").endOfDay(); console.log(morning.isEqual(evening)); // true ``` --- ## Related * [`date.isSame()`](/docs/nodejs/methods/is-same): Compare dates by specific calendar unit (`year`, `month`, or `day`). * [`date.isBefore()`](/docs/nodejs/methods/is-before): Millisecond-level chronological check. * [`date.isAfter()`](/docs/nodejs/methods/is-after): Millisecond-level chronological check. --- ## Page: date.isLeapYear() (NodeJS) (/docs/nodejs/methods/is-leap-year) Description: [NodeJS] Determine whether the current Bikram Sambat calendar year has three hundred sixty six or more days. Official API reference and code examples for NodeJS / TypeScript. The `isLeapYear` method checks whether the active Bikram Sambat year contains 366 or more days based on official solar calendar tables. Because Bikram Sambat year lengths depend on astronomical calculations rather than fixed leap year cycles, this method checks the actual cumulative day count for the year. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript isLeapYear(): boolean; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `boolean` * Returns `true` if the total days in the current Bikram Sambat year is greater than or equal to 366; otherwise returns `false`. --- ## Background Unlike the Gregorian calendar which inserts a leap day every 4 years on February 29, the Bikram Sambat calendar is a sidereal solar calendar where each month's duration is determined by the exact astrological entry (Sankranti) of the Sun into each zodiac constellation. Consequently, the total number of days in a Bikram Sambat year fluctuates between 365 and 366 days based on astronomical observation data. --- ## Examples ### Checking if a Year is a Leap Year ```typescript import { NepaliDate } from "nepali-date-library"; const date2081 = new NepaliDate("2081-01-01"); console.log(date2081.isLeapYear()); const date2080 = new NepaliDate("2080-01-01"); console.log(date2080.isLeapYear()); ``` --- ## Related * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Query days in a specific month. * [`date.getYear()`](/docs/nodejs/methods/get-year): Retrieve current year. --- ## Page: date.isSame() (NodeJS) (/docs/nodejs/methods/is-same) Description: [NodeJS] Check whether two dates match across a specified granularity such as year, month, or day. Official API reference and code examples for NodeJS / TypeScript. The `isSame` method compares the current `NepaliDate` instance with another date at a specified level of granularity, such as year, month, day, hour, or minute. It returns true if both dates match within that specific unit, simplifying range checks and calendar filters. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript isSame(date: NepaliDate, unit: "year" | "month" | "day"): boolean; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Target `NepaliDate` instance to compare against. | | `unit` | `"year" \| "month" \| "day"` | Yes | Unit of granularity for comparison. | --- ## Return Value * **Type**: `boolean` * Returns `true` if both dates are identical within the specified unit boundary; otherwise returns `false`. --- ## Comparison Rules * **`"year"`**: Evaluates `this.year === date.year`. * **`"month"`**: Evaluates `this.year === date.year && this.month === date.month`. * **`"day"`**: Evaluates `this.isEqual(date)` (matching year, month, and day). --- ## Exceptions Throws an `Error` if an invalid unit string is supplied: ```typescript "Invalid unit for comparison" ``` --- ## Examples ### Comparing Same Month ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-03-05"); const date2 = new NepaliDate("2081-03-25"); const date3 = new NepaliDate("2080-03-05"); console.log(date1.isSame(date2, "month")); // true (both Ashadh 2081) console.log(date1.isSame(date3, "month")); // false (different years) ``` ### Comparing Same Year ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-01-01"); const date2 = new NepaliDate("2081-12-30"); console.log(date1.isSame(date2, "year")); // true ``` ### Comparing Same Day ```typescript import { NepaliDate } from "nepali-date-library"; const date1 = new NepaliDate("2081-01-15"); const date2 = new NepaliDate("2081-01-15"); console.log(date1.isSame(date2, "day")); // true ``` --- ## Related * [`date.isEqual()`](/docs/nodejs/methods/is-equal): Strict calendar day equality. * [`date.diff()`](/docs/nodejs/methods/diff): Measure quantitative difference between dates. --- ## Page: date.isValid() (NodeJS) (/docs/nodejs/methods/is-valid) Description: [NodeJS] Validate whether the current NepaliDate instance represents a legitimate calendar date within supported bounds. Official API reference and code examples for NodeJS / TypeScript. The `isValid` instance method checks whether the current `NepaliDate` instance contains valid calendar values and falls within the supported range of 1976 through 2100 BS. It verifies that year, month, and day coordinates correspond to an authentic historical date. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript isValid(): boolean; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `boolean` * Returns `true` if the instance's year, month, and day are valid within the Bikram Sambat calendar data (1976 BS to 2100 BS); otherwise returns `false`. --- ## Examples ### Validating Instance Dates ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-15"); console.log(date.isValid()); // true ``` ### Checking Post-Mutation Validity ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-01"); console.log(date.isValid()); // true ``` --- ## Related * [`NepaliDate.isValid()`](/docs/nodejs/static/is-valid): Static validation helper taking numeric year, month, and day. * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Total days in the month. --- ## Page: date.parse() (NodeJS) (/docs/nodejs/methods/parse) Description: [NodeJS] Parse a formatted Bikram Sambat date string and update the current date instance in place. Official API reference and code examples for NodeJS / TypeScript. The `parse` method parses a Bikram Sambat date string and updates the coordinates of the current `NepaliDate` instance in place. It supports various delimiter styles including slashes, dots, and hyphens, recalculating the underlying timestamp upon successful parsing. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript parse(dateString: string): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `dateString` | `string` | Yes | Date string formatted as `YYYY-MM-DD`, `YYYY/MM/DD`, or `YYYY.MM.DD`. | --- ## Return Value * **Type**: `void` * Mutates the current `NepaliDate` instance in place. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid date` | Thrown if string segments are non-numeric. | | `Nepal year out of range` | Thrown if the parsed year is outside 1976 to 2100 BS. | | `Invalid nepali month must be between 1 - 12` | Thrown if month is outside `1` to `12`. | | `Invalid nepali date must be between 1 - in ` | Thrown if day exceeds the month's verified length. | --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); // Mutate instance from string date.parse("2081-07-15"); console.log(date.format("YYYY-MM-DD")); // "2081-07-15" // Delimiters with slash or period are supported date.parse("2082/01/01"); console.log(date.format("YYYY-MM-DD")); // "2082-01-01" ``` --- ## Related * [`new NepaliDate(string)`](/docs/nodejs/class/constructor): Construct a new instance directly from a string. * [`date.set()`](/docs/nodejs/methods/set): Set coordinates using numeric values. --- ## Page: date.set() (NodeJS) (/docs/nodejs/methods/set) Description: [NodeJS] Set year, month, and day coordinates simultaneously on a NepaliDate instance. Official API reference and code examples for NodeJS / TypeScript. The `set` method updates the Bikram Sambat year, zero based month index, and day values of the current `NepaliDate` instance in a single atomic call. It validates the combined coordinates against the calendar map and recalculates the internal timestamp. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript set(year: number, month: number, date: number): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `number` | Yes | 4-digit Bikram Sambat year (`1976` to `2100`). | | `month` | `number` | Yes | **0-indexed** month integer (`0` for Baisakh to `11` for Chaitra). | | `date` | `number` | Yes | Day of the month (`1` to `32`). | --- ## Return Value * **Type**: `void` * Mutates the current `NepaliDate` instance in place. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Nepal year out of range` | Thrown if `year` is earlier than 1976 BS or later than 2100 BS. | | `Invalid nepali month must be between 1 - 12` | Thrown if `month` is outside `0` to `11`. | | `Invalid nepali date must be between 1 - in ` | Thrown if `date` exceeds the days count for the target month and year. | --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); // Mutate to 2081 Kartik 15 (month index 6) date.set(2081, 6, 15); console.log(date.format("YYYY-MM-DD")); // "2081-07-15" console.log(date.getEnglishDate().toISOString()); // "2024-10-31T00:00:00.000Z" ``` --- ## Related * [`date.setYear()`](/docs/nodejs/methods/set-year): Mutate only the year component. * [`date.setMonth()`](/docs/nodejs/methods/set-month): Mutate only the month component. * [`date.setDate()`](/docs/nodejs/methods/set-date): Mutate only the day component. --- ## Page: date.setDate() (NodeJS) (/docs/nodejs/methods/set-date) Description: [NodeJS] Set the day of the month on a NepaliDate instance and recalculate its timestamp. Official API reference and code examples for NodeJS / TypeScript. The `setDate` method updates the day of the month for the current `NepaliDate` instance and recalculates its underlying Gregorian timestamp. It validates the new day against the maximum number of days available in the active month. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript setDate(day: number): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `day` | `number` | Yes | Day of the month (`1` to `32`, validated against current month's length). | --- ## Return Value * **Type**: `void` * Mutates the current `NepaliDate` instance in place. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid nepali date must be between 1 - in ` | Thrown if `day` is less than `1` or greater than the maximum days in the current month for this year. | --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-01"); date.setDate(25); console.log(date.format("YYYY-MM-DD")); // "2081-01-25" ``` --- ## Related * [`date.getDate()`](/docs/nodejs/methods/get-date): Retrieve the day of the month. * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Query the maximum allowed day count for this month. --- ## Page: date.setMonth() (NodeJS) (/docs/nodejs/methods/set-month) Description: [NodeJS] Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping. Official API reference and code examples for NodeJS / TypeScript. The `setMonth` method updates the Bikram Sambat month for the current `NepaliDate` instance using a zero based month index from 0 for Baisakh to 11 for Chaitra. If the current day exceeds the total days in the destination month, the day is automatically clamped to the final valid day of that month. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript setMonth(month: number): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `month` | `number` | Yes | **0-indexed** month integer (`0` for Baisakh to `11` for Chaitra). | --- ## Return Value * **Type**: `void` * Mutates the current `NepaliDate` instance in place. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid nepali month must be between 1 - 12` | Thrown if `month` is outside `0` to `11`. | --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 15 (month index 0) const date = new NepaliDate("2081-01-15"); // Shift to Shrawan (month index 3) date.setMonth(3); console.log(date.format("YYYY-MM-DD")); // "2081-04-15" ``` --- ## Related * [`date.getMonth()`](/docs/nodejs/methods/get-month): Retrieve the current month index. * [`date.setDate()`](/docs/nodejs/methods/set-date): Mutate the day component. --- ## Page: date.setYear() (NodeJS) (/docs/nodejs/methods/set-year) Description: [NodeJS] Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range. Official API reference and code examples for NodeJS / TypeScript. The `setYear` method updates the four digit Bikram Sambat year on the current `NepaliDate` instance and adjusts the timestamp accordingly. The target year must fall within the supported range between 1976 and 2100 BS. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript setYear(year: number): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `number` | Yes | 4-digit Bikram Sambat year (`1976` to `2100`). | --- ## Return Value * **Type**: `void` * Mutates the current `NepaliDate` instance in place. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Nepal year out of range` | Thrown if `year` is earlier than 1976 BS or later than 2100 BS. | --- ## Example ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2080-01-01"); date.setYear(2082); console.log(date.format("YYYY-MM-DD")); // "2082-01-01" ``` --- ## Related * [`date.getYear()`](/docs/nodejs/methods/get-year): Retrieve the current year. * [`date.set()`](/docs/nodejs/methods/set): Set year, month, and day together. --- ## Page: date.startOfDay() (NodeJS) (/docs/nodejs/methods/start-of-day) Description: [NodeJS] Return a new NepaliDate instance set to the first moment of the current day at midnight. Official API reference and code examples for NodeJS / TypeScript. The `startOfDay` method returns a new `NepaliDate` instance with time coordinates set to midnight at 00 hours, 00 minutes, 00 seconds, and 000 milliseconds. This is useful for date normalization and time neutral comparisons. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript startOfDay(): NepaliDate; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `NepaliDate` * Returns a new cloned `NepaliDate` instance set to `00:00:00.000` on the same calendar day. The original instance is not modified. --- ## Examples ### Normalizing Date to Midnight ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(); const start = date.startOfDay(); console.log(start.getHours()); // 0 console.log(start.getMinutes()); // 0 console.log(start.getSeconds()); // 0 console.log(start.getMilliseconds()); // 0 ``` ### Date Range Queries ```typescript import { NepaliDate } from "nepali-date-library"; // Generate midnight boundaries for database filters const fromDate = new NepaliDate("2081-02-10").startOfDay(); const toDate = new NepaliDate("2081-02-10").endOfDay(); console.log(fromDate.getEnglishDate().toISOString()); console.log(toDate.getEnglishDate().toISOString()); ``` --- ## Related * [`date.endOfDay()`](/docs/nodejs/methods/end-of-day): Return end of the day (`23:59:59.999`). * [`date.startOfMonth()`](/docs/nodejs/methods/start-of-month): Return first day of the current month. * [`date.startOfYear()`](/docs/nodejs/methods/start-of-year): Return first day of the current year. --- ## Page: date.startOfMonth() (NodeJS) (/docs/nodejs/methods/start-of-month) Description: [NodeJS] Return a new NepaliDate instance set to the first day of the current Bikram Sambat month. Official API reference and code examples for NodeJS / TypeScript. The `startOfMonth` method returns a new `NepaliDate` instance positioned on day 1 of the active Bikram Sambat month with time set to midnight. It is commonly used for monthly calendar views, statements, and aggregation buckets. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript startOfMonth(): NepaliDate; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` set to day `1` of the current year and month. The original instance is not modified. --- ## Examples ### Getting the First Day of the Month ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 25 const date = new NepaliDate(2081, 0, 25); const start = date.startOfMonth(); console.log(start.format("YYYY-MM-DD")); // "2081-01-01" console.log(start.getDate()); // 1 ``` ### Calendar Header Computation ```typescript import { NepaliDate } from "nepali-date-library"; const today = new NepaliDate(); const firstDay = today.startOfMonth(); // Find weekday that the month begins on console.log(firstDay.getDay()); // 0 = Sunday, 1 = Monday, etc. ``` --- ## Related * [`date.endOfMonth()`](/docs/nodejs/methods/end-of-month): Return the last day of the current month. * [`date.startOfYear()`](/docs/nodejs/methods/start-of-year): Return the first day of the current year. * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Return total days in the month. --- ## Page: date.startOfWeek() (NodeJS) (/docs/nodejs/methods/start-of-week) Description: [NodeJS] Return a new NepaliDate instance set to the first day of the week on Sunday. Official API reference and code examples for NodeJS / TypeScript. The `startOfWeek` method returns a new `NepaliDate` instance set to Sunday, the first day of the weekly cycle containing the current date. It serves as an anchor date for week based scheduling and calendar grids. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript startOfWeek(startOfWeek?: number): NepaliDate; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `startOfWeek` | `number` | No | `0` | Day of week index (`0-6`), where `0` is Sunday and `1` is Monday. | --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` instance set to the start of the week at midnight. The original instance is not modified. --- ## Exceptions Throws an `Error` if `startOfWeek` is not an integer between `0` and `6`: ```typescript "startOfWeek must be an integer between 0 and 6" ``` --- ## Examples ### Default Week Start (Sunday) ```typescript import { NepaliDate } from "nepali-date-library"; // Suppose date falls on a Wednesday (day 3) const date = new NepaliDate("2081-02-16"); const weekStart = date.startOfWeek(); console.log(weekStart.getDay()); // 0 (Sunday) console.log(weekStart.getHours()); // 0 console.log(weekStart.format("YYYY-MM-DD")); ``` ### Custom Week Start (Monday) ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-02-16"); // Week starts on Monday (1) const mondayStart = date.startOfWeek(1); console.log(mondayStart.getDay()); // 1 (Monday) ``` --- ## Related * [`date.endOfWeek()`](/docs/nodejs/methods/end-of-week): Return the end of the week. * [`date.startOfDay()`](/docs/nodejs/methods/start-of-day): Return the start of the day. * [`date.getDay()`](/docs/nodejs/methods/get-day): Get current day of week index (`0-6`). --- ## Page: date.startOfYear() (NodeJS) (/docs/nodejs/methods/start-of-year) Description: [NodeJS] Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh. Official API reference and code examples for NodeJS / TypeScript. The `startOfYear` method returns a new `NepaliDate` instance set to 1 Baisakh, the first day of the Bikram Sambat calendar year. This is useful for year to date financial tracking and annual summary reports. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript startOfYear(): NepaliDate; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `NepaliDate` * Returns a new `NepaliDate` set to 1st Baisakh of the current year. The original instance is not modified. --- ## Examples ### Navigating to Bikram Sambat New Year ```typescript import { NepaliDate } from "nepali-date-library"; // Any date within 2081 BS const date = new NepaliDate("2081-08-15"); const newYear = date.startOfYear(); console.log(newYear.format("YYYY-MM-DD")); // "2081-01-01" console.log(newYear.getMonth()); // 0 (Baisakh) console.log(newYear.getDate()); // 1 ``` ### Year-to-Date Calculations ```typescript import { NepaliDate } from "nepali-date-library"; const today = new NepaliDate("2081-06-15"); const yearStart = today.startOfYear(); const daysElapsed = today.diff(yearStart, "day"); console.log(daysElapsed); // Number of days since start of the year ``` --- ## Related * [`date.endOfYear()`](/docs/nodejs/methods/end-of-year): Return the final day of the Bikram Sambat year. * [`date.startOfMonth()`](/docs/nodejs/methods/start-of-month): Return the first day of the current month. * [`date.getYear()`](/docs/nodejs/methods/get-year): Retrieve current Bikram Sambat year number. --- ## Page: date.toString() (NodeJS) (/docs/nodejs/methods/to-string) Description: [NodeJS] Return the default string representation of a NepaliDate instance in standard year, month, and day format. Official API reference and code examples for NodeJS / TypeScript. The `toString` method converts the `NepaliDate` instance into a standard readable date string formatted as year, month, and day separated by forward slashes. It provides a simple default serialization format suitable for logs and quick display. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript toString(): string; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `string` * Returns the date formatted as `${year}/${month + 1}/${day}` where month is 1-indexed. --- ## Examples ### Default Serialization ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 15 (month index 0) const date = new NepaliDate(2081, 0, 15); console.log(date.toString()); // "2081/1/15" console.log(String(date)); // "2081/1/15" ``` ### String Interpolation ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-10-25"); console.log(`Nepali Date: ${date}`); // "Nepali Date: 2081/10/25" ``` --- ## Related * [`date.format()`](/docs/nodejs/methods/format): Custom formatted strings with zero-padding and Nepali script. * [`date.getEnglishDate()`](/docs/nodejs/methods/get-english-date): Retrieve equivalent JavaScript Date. --- ## Page: Quick Start (NodeJS) (/docs/nodejs/quick-start) Description: [NodeJS] Practical guide and essential code examples to start working with Bikram Sambat dates in Node.js and TypeScript. Official API reference and code examples for NodeJS / TypeScript. This quick start guide demonstrates common practical workflows for creating dates, performing calendar arithmetic, formatting output strings, and converting between Gregorian and Bikram Sambat calendars. Use these examples as reference patterns for building date pickers, booking systems, financial tools, and general calendar features. --- ## 1. Creating and Inspecting Dates Initialize dates representing the current moment, specific Bikram Sambat coordinates, or existing Gregorian dates: ```typescript import { NepaliDate } from "nepali-date-library"; // Current date and time in Nepal const now = new NepaliDate(); // Specific Bikram Sambat date (Year, 0-indexed Month, Day) // Month 6 represents Kartik (0 = Baisakh, 6 = Kartik) const constitutionDay = new NepaliDate(2072, 5, 3); // Parse from standard string formats (YYYY-MM-DD, YYYY/MM/DD, YYYY.MM.DD) const festivalDate = new NepaliDate("2081-07-15"); console.log(festivalDate.getYear()); // 2081 console.log(festivalDate.getMonth()); // 6 (0-indexed) console.log(festivalDate.getDate()); // 15 console.log(festivalDate.getDay()); // 5 (0 = Sunday, 5 = Friday) ``` --- ## 2. Converting Between AD and BS For database persistence and external API integration, convert between Gregorian (AD) and Bikram Sambat (BS): ### Using Standalone Converter Functions ```typescript import { ADtoBS, BStoAD } from "nepali-date-library"; // Convert Gregorian date string to Bikram Sambat const bsDate = ADtoBS("2024-10-31"); console.log(bsDate); // "2081-07-15" // Convert Bikram Sambat date string to Gregorian const adDate = BStoAD("2081-07-15"); console.log(adDate); // "2024-10-31" ``` ### Using the `NepaliDate` Class ```typescript import { NepaliDate } from "nepali-date-library"; // From native JS Date to BS const jsDate = new Date("2024-10-31T00:00:00.000Z"); const nepaliDate = new NepaliDate(jsDate); console.log(nepaliDate.format("YYYY-MM-DD")); // "2081-07-15" // From BS instance to native JS Date const nativeDate = nepaliDate.getEnglishDate(); console.log(nativeDate.toISOString()); // "2024-10-31T00:00:00.000Z" ``` --- ## 3. Formatting Dates Format dates with customizable masks and localized Devanagari script: ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate(2081, 6, 15); // Standard English formatting console.log(date.format("YYYY-MM-DD")); // "2081-07-15" console.log(date.format("DD MMMM YYYY")); // "15 Kartik 2081" console.log(date.format("dddd, MMMM DD, YYYY")); // "Friday, Kartik 15, 2081" // Devanagari script and numeral formatting console.log(date.format("yyyy-mm-dd")); // "२०८१-०७-१५" console.log(date.format("dd mmmm yyyy")); // "१५ कार्तिक २०८१" ``` --- ## 4. Date Arithmetic Manipulate dates while safely respecting variable month lengths: ```typescript import { NepaliDate } from "nepali-date-library"; const date = new NepaliDate("2081-01-20"); // Adding and subtracting days date.addDays(15); console.log(date.format("YYYY-MM-DD")); // "2081-02-04" // Adding months date.addMonths(2); console.log(date.format("YYYY-MM-DD")); // "2081-04-04" // Month boundaries const endOfMonth = date.clone().endOfMonth(); console.log(endOfMonth.format("YYYY-MM-DD")); // "2081-04-32" ``` --- ## 5. Nepalese Fiscal Year Handling Automate Nepal's Shrawan-to-Ashadh fiscal calendar calculations: ```typescript import { NepaliDate } from "nepali-date-library"; // Current active fiscal year integer const currentFY = NepaliDate.getCurrentFiscalYear(); console.log(currentFY); // 2081 // Get all 4 fiscal quarters for the current cycle const quarters = NepaliDate.getFiscalYearQuarters(currentFY); console.log(quarters.Q1.start.format("YYYY-MM-DD")); // "2081-04-01" console.log(quarters.Q1.end.format("YYYY-MM-DD")); // "2081-06-30" ``` --- ## Page: NepaliDate.getCalendarDays() (NodeJS) (/docs/nodejs/static/get-calendar-days) Description: [NodeJS] Static utility to generate a complete forty two cell calendar grid matrix for any month and year. Official API reference and code examples for NodeJS / TypeScript. The `getCalendarDays` static method generates a complete forty two cell grid structure representing six rows of seven days for displaying a monthly calendar view. It includes trailing days from the previous month and leading days from the next month to fill out the matrix, simplifying the creation of date pickers and visual calendar components. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript static getCalendarDays( year: number, month: number ): { prevRemainingDays: number; prevMonth: { year: number; month: number; days: number[] }; currentMonth: { year: number; month: number; days: number[] }; nextMonth: { year: number; month: number; days: number[] }; remainingDays: number; }; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `number` | Yes | Bikram Sambat year (e.g. `2081`). | | `month` | `number` | Yes | Zero-indexed month (`0-11`, where `0` is Baisakh and `11` is Chaitra). | --- ## Return Value * **Type**: `Object` containing calendar grid sections: * `prevRemainingDays`: Number of leading days from the previous month needed to reach the first day's weekday. * `prevMonth`: Object containing `year`, `month`, and `days` array for preceding filler dates. * `currentMonth`: Object containing `year`, `month`, and `days` array (`1` through `daysInMonth`) for the active month. * `nextMonth`: Object containing `year`, `month`, and `days` array for succeeding filler dates to complete 42 cells. * `remainingDays`: Number of trailing days in `nextMonth`. --- ## Exceptions Throws an `Error` if the year or month index is invalid: ```typescript "Invalid year or month" ``` --- ## Examples ### Building a Monthly UI Calendar Grid ```typescript import { NepaliDate } from "nepali-date-library"; // Generate grid for Baisakh 2081 const grid = NepaliDate.getCalendarDays(2081, 0); console.log("Leading days count:", grid.prevRemainingDays); console.log("Leading days:", grid.prevMonth.days); console.log("Active month days:", grid.currentMonth.days); console.log("Trailing days:", grid.nextMonth.days); ``` ### Rendering a 42-Cell React Calendar ```tsx import React from "react"; import { NepaliDate } from "nepali-date-library"; export function NepaliCalendarView({ year, month }: { year: number; month: number }) { const grid = NepaliDate.getCalendarDays(year, month); return (
{/* Leading days from previous month */} {grid.prevMonth.days.map((d) => (
{d}
))} {/* Active month days */} {grid.currentMonth.days.map((d) => (
{d}
))} {/* Trailing days from next month */} {grid.nextMonth.days.map((d) => (
{d}
))}
); } ``` --- ## Related * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Total number of days in the month. * [`date.getWeeksInMonth()`](/docs/nodejs/methods/get-weeks-in-month): Number of week rows needed. * [`NepaliDate.isValid()`](/docs/nodejs/static/is-valid): Date validation. --- ## Page: NepaliDate.getDayName() (NodeJS) (/docs/nodejs/static/get-day-name) Description: [NodeJS] Static utility to retrieve the localized English or Nepali name for any day of the week index. Official API reference and code examples for NodeJS / TypeScript. The `getDayName` static method converts a numeric weekday index from 0 for Sunday through 6 for Saturday into its localized name. It supports both English and Nepali Devanagari script output, allowing flexible localization across international and local application interfaces. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript static getDayName(day: number, short?: boolean, nepali?: boolean): string; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `day` | `number` | Yes | - | Day of week index (`0-6`, where `0` is Sunday and `6` is Saturday). | | `short` | `boolean` | No | `false` | When `true`, returns the abbreviated 3-letter or short weekday name. | | `nepali` | `boolean` | No | `false` | When `true`, returns the weekday name in Devanagari script. | --- ## Return Value * **Type**: `string` * Localized day of week name string. --- ## Exceptions Throws an `Error` if `day` is less than `0` or greater than `6`: ```typescript "Invalid day index, must be between 0-6" ``` --- ## Output Reference Matrix | Day Index | Default (`short: false, nepali: false`) | Short English (`short: true, nepali: false`) | Nepali Full (`short: false, nepali: true`) | Nepali Short (`short: true, nepali: true`) | | :---: | :--- | :--- | :--- | :--- | | `0` | `"Sunday"` | `"Sun"` | `"आइतबार"` | `"आइत"` | | `1` | `"Monday"` | `"Mon"` | `"सोमबार"` | `"सोम"` | | `2` | `"Tuesday"` | `"Tue"` | `"मंगलबार"` | `"मंगल"` | | `3` | `"Wednesday"` | `"Wed"` | `"बुधबार"` | `"बुध"` | | `4` | `"Thursday"` | `"Thu"` | `"बिहिबार"` | `"बिहि"` | | `5` | `"Friday"` | `"Fri"` | `"शुक्रबार"` | `"शुक्र"` | | `6` | `"Saturday"` | `"Sat"` | `"शनिबार"` | `"शनि"` | --- ## Examples ### Generating Weekday Labels for UI ```typescript import { NepaliDate } from "nepali-date-library"; // Default English console.log(NepaliDate.getDayName(0)); // "Sunday" // English Short console.log(NepaliDate.getDayName(0, true)); // "Sun" // Nepali Devanagari Full console.log(NepaliDate.getDayName(0, false, true)); // "आइतबार" // Nepali Devanagari Short console.log(NepaliDate.getDayName(0, true, true)); // "आइत" ``` --- ## Related * [`NepaliDate.getMonthName()`](/docs/nodejs/static/get-month-name): Localized month names. * [`WEEK_EN`](/docs/nodejs/constants/week-en): English week array constant. * [`WEEK_NP`](/docs/nodejs/constants/week-np): Nepali week array constant. --- ## Page: NepaliDate.getMonthName() (NodeJS) (/docs/nodejs/static/get-month-name) Description: [NodeJS] Static utility to retrieve the localized English or Nepali month name for any month index. Official API reference and code examples for NodeJS / TypeScript. The `getMonthName` static method returns the localized name of a Bikram Sambat month given its zero based index from 0 for Baisakh to 11 for Chaitra. It supports full names as well as short abbreviations in both English and Devanagari script. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript static getMonthName(month: number, short?: boolean, nepali?: boolean): string; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `month` | `number` | Yes | - | Zero-indexed month number (`0-11`, where `0` is Baisakh). | | `short` | `boolean` | No | `false` | When `true`, returns the 3-letter abbreviated name. | | `nepali` | `boolean` | No | `false` | When `true`, returns the name in Devanagari script. | --- ## Return Value * **Type**: `string` * Localized month name string. --- ## Exceptions Throws an `Error` if `month` is less than `0` or greater than `11`: ```typescript "Invalid month index, must be between 0-11" ``` --- ## Output Reference Matrix | Month Index | Default (`short: false, nepali: false`) | Short English (`short: true, nepali: false`) | Nepali Full (`short: false, nepali: true`) | Nepali Short (`short: true, nepali: true`) | | :---: | :--- | :--- | :--- | :--- | | `0` | `"Baisakh"` | `"Bai"` | `"बैशाख"` | `"बै"` | | `1` | `"Jestha"` | `"Jes"` | `"जेठ"` | `"जे"` | | `2` | `"Asar"` | `"Asa"` | `"असार"` | `"अ"` | | `3` | `"Shrawan"` | `"Shr"` | `"श्रावण"` | `"श्रा"` | | `4` | `"Bhadra"` | `"Bhd"` | `"भाद्र"` | `"भा"` | | `5` | `"Aswin"` | `"Asw"` | `"आश्विन"` | `"आ"` | | `6` | `"Kartik"` | `"Kar"` | `"कार्तिक"` | `"का"` | | `7` | `"Mangsir"` | `"Man"` | `"मंसिर"` | `"मं"` | | `8` | `"Poush"` | `"Pou"` | `"पौष"` | `"पौ"` | | `9` | `"Magh"` | `"Mag"` | `"माघ"` | `"मा"` | | `10` | `"Falgun"` | `"Fal"` | `"फाल्गुण"` | `"फा"` | | `11` | `"Chaitra"` | `"Cha"` | `"चैत्र"` | `"चै"` | --- ## Examples ### Generating Localized Month Labels ```typescript import { NepaliDate } from "nepali-date-library"; // Default English Full console.log(NepaliDate.getMonthName(0)); // "Baisakh" // English Short console.log(NepaliDate.getMonthName(0, true)); // "Bai" // Nepali Devanagari Full console.log(NepaliDate.getMonthName(0, false, true)); // "बैशाख" // Nepali Devanagari Short console.log(NepaliDate.getMonthName(0, true, true)); // "बै" ``` --- ## Related * [`NepaliDate.getDayName()`](/docs/nodejs/static/get-day-name): Localized weekday names. * [`MONTH_EN`](/docs/nodejs/constants/month-en): Array constant for English months. * [`MONTH_NP`](/docs/nodejs/constants/month-np): Array constant for Nepali months. --- ## Page: NepaliDate.isValid() (NodeJS) (/docs/nodejs/static/is-valid) Description: [NodeJS] Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date. Official API reference and code examples for NodeJS / TypeScript. The static `isValid` method verifies whether a specified Bikram Sambat year, month index, and day number represent a real calendar date. It consults verified historical data tables to confirm that the year falls within the supported range of 1976 through 2100 BS and that the day number does not exceed the actual number of days in that specific month. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript static isValid(year: number, month: number, day: number): boolean; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `number` | Yes | Bikram Sambat year (e.g. `2081`). Supported range: `1976` to `2100`. | | `month` | `number` | Yes | Zero-indexed month (`0-11`, where `0` is Baisakh and `11` is Chaitra). | | `day` | `number` | Yes | Day of the month (`1-32`). | --- ## Return Value * **Type**: `boolean` * Returns `true` if the year is within supported range, month is between `0` and `11`, and day does not exceed the exact number of days in that month; otherwise returns `false`. --- ## Examples ### Pre-validating User Input ```typescript import { NepaliDate } from "nepali-date-library"; // 2081 Baisakh 31 is valid (Baisakh has 31 days) console.log(NepaliDate.isValid(2081, 0, 31)); // true // 2081 Baisakh 32 does not exist console.log(NepaliDate.isValid(2081, 0, 32)); // false // Month index must be 0-11 console.log(NepaliDate.isValid(2081, 12, 1)); // false ``` ### Form Input Validation Guard ```typescript import { NepaliDate } from "nepali-date-library"; function createNepaliEvent(y: number, m: number, d: number) { if (!NepaliDate.isValid(y, m, d)) { throw new Error(`Invalid Bikram Sambat date: ${y}-${m + 1}-${d}`); } return new NepaliDate(y, m, d); } ``` --- ## Related * [`date.isValid()`](/docs/nodejs/methods/is-valid): Instance method equivalent. * [`date.daysInMonth()`](/docs/nodejs/methods/days-in-month): Query total days in a month. --- ## Page: NepaliDate.maximum() (NodeJS) (/docs/nodejs/static/maximum) Description: [NodeJS] Static method returning the maximum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for NodeJS / TypeScript. The `maximum` static method returns a native JavaScript Date object representing the latest Gregorian date supported by the library calendar engine. This corresponds to the final day of Chaitra in year 2100 BS and serves as an upper bound for date validation and calendar limits. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript static maximum(): Date; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `Date` * Returns a standard JavaScript `Date` instance representing the absolute upper limit of the calendar mapping dataset. --- ## Examples ### Checking Upper Calendar Limit ```typescript import { NepaliDate } from "nepali-date-library"; const maxDate = NepaliDate.maximum(); console.log(maxDate.toISOString()); // Converting maximum back to NepaliDate const nepaliMax = new NepaliDate(maxDate); console.log(nepaliMax.format("YYYY-MM-DD")); // "2100-12-30" (or 31) ``` --- ## Related * [`NepaliDate.minimum()`](/docs/nodejs/static/minimum): Earliest date supported. * [`NEPALI_DATE_MAP`](/docs/nodejs/constants/nepali-date-map): Calendar map dataset. --- ## Page: NepaliDate.minimum() (NodeJS) (/docs/nodejs/static/minimum) Description: [NodeJS] Static method returning the minimum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for NodeJS / TypeScript. The `minimum` static method returns a native JavaScript Date object representing the earliest Gregorian date supported by the library calendar engine. This corresponds to the first day of Baisakh in year 1976 BS and provides a reliable lower boundary for date pickers and form input validation. --- ## Import ```typescript import { NepaliDate } from "nepali-date-library"; ``` --- ## Signature ```typescript static minimum(): Date; ``` --- ## Parameters This method does not take any parameters. --- ## Return Value * **Type**: `Date` * Returns a standard JavaScript `Date` instance representing the minimum boundary (`1919-04-13T00:00:00.000Z`). --- ## Examples ### Checking Lower Calendar Limit ```typescript import { NepaliDate } from "nepali-date-library"; const minDate = NepaliDate.minimum(); console.log(minDate.toISOString()); // "1919-04-13T00:00:00.000Z" // Converting minimum back to NepaliDate const nepaliMin = new NepaliDate(minDate); console.log(nepaliMin.format("YYYY-MM-DD")); // "1976-01-01" ``` --- ## Related * [`NepaliDate.maximum()`](/docs/nodejs/static/maximum): Latest date supported. * [`NEPALI_DATE_MAP`](/docs/nodejs/constants/nepali-date-map): Calendar map dataset. --- ## Page: What is Nepali Date? (Origination & Calendar) (/docs/origination) Description: Deep dive into the origins, history, astronomical foundation, calendar mechanics, and timeline of Bikram Sambat (विक्रम संवत्). The **Nepali Date** is based on the **Bikram Sambat** (Devanagari: **विक्रम संवत्**, abbreviated as **BS** or **B.S.**), the official national civil calendar of **Nepal**. Used across all organs of the Nepalese state—from parliamentary legislation and Supreme Court decrees to banking operations, taxation, school academic sessions, and day-to-day citizen records—Bikram Sambat is a sophisticated **solar sidereal calendar** with roots extending over two millennia. --- ## Historical Genesis of Bikram Sambat ### The Founding in 57 BCE Bikram Sambat originated in **57 BCE (Before Common Era)** in the ancient city of **Ujjain** (in modern Madhya Pradesh, India). According to widespread historical tradition, the era was instituted by **King Vikramaditya of Ujjain** to commemorate his decisive military victory over the invading Saka (Indo-Scythian) forces, liberating the region and relieving the financial debt of his citizens. Because the era was inaugurated in 57 BCE, Bikram Sambat is approximately **56.7 years ahead** of the Western Gregorian calendar (Common Era / AD). ### Evolution of the Era's Inscriptional Name Epigraphic and numismatic records show that the name of this calendar era evolved across three distinct phases: 1. **Krita Era (कृत संवत्)**: Earliest stone inscriptions from the 3rd to 5th centuries CE referred to this system as *Krita*, possibly honoring a foundational event or sovereign leader. 2. **Malava Era (मालव संवत्)**: Between the 5th and 9th centuries CE, the era was called *Malava Gana Sambat* (the era of the Malava republic), corresponding to the migration and governance of the Malava tribe. 3. **Vikrama Samvat (विक्रम संवत्)**: By the 9th and 10th centuries CE, starting prominently around the Dholpur stone inscription (dated 842 CE / 898 BS), the era became permanently identified with King Vikramaditya. --- ## The Calendar Eras of Nepal Nepal has one of the world's richest epigraphic and calendar traditions, having utilized several prominent eras throughout its documented history: ### 1. Saka Sambat (शक संवत् - 78 CE) Introduced in ancient Nepal during the Licchavi period, the Saka Sambat was the primary calendar of early royal inscriptions. The oldest dated stone epigraph in Nepal—the pillar inscription of **King Manadeva I at the Changu Narayan Temple**—is dated **386 Saka Sambat (464 CE / 521 BS)**. ### 2. Manadeva Sambat / Amshuverma Era (576 CE) During the late Licchavi period under rulers such as King Amshuverma and King Jisnugupta, a shortened regional calendar system known as the Manadeva Sambat was employed across the Kathmandu Valley for public administration and religious foundations. ### 3. Nepal Sambat (नेपाल संवत् - 879 CE / 936 BS) Founded by **Shankhadhar Sakhwa** on Kartik Shukla Pratipada in 879 CE after he cleared the debts of all citizens in the Kathmandu Valley during the reign of King Raghavadeva. Nepal Sambat served as the principal civic, lunar, and commercial calendar of the Malla Dynasty (1200–1768 CE) and remains revered today as a national heritage calendar of Nepal. ### 4. Bikram Sambat in Ancient and Medieval Nepal While Nepal Sambat predominated in the Kathmandu Valley's domestic trade, Bikram Sambat maintained continuous usage across western and northern Nepal: - In the **Khasa Malla Empire** of the Karnali basin (centered in the Sinja Valley, Jumla), Bikram Sambat was the undisputed official calendar. The **Dullu Stone Pillar of King Prithvi Malla** (located in Dailekh) is engraved in Bikram Sambat **1414 BS (1357 CE)** using the ancient Khas language. - King Jayasthiti Malla (reigned 1382–1395 CE) and King Pratap Malla of Kathmandu utilized Bikram Sambat alongside Nepal Sambat in stone treaties, temple edicts, and Sanskrit panegyrics. ### 5. Unification and Official Adoption in Nepal (1768–1901 CE) When **King Prithvi Narayan Shah of Gorkha** unified Nepal and established Kathmandu as the capital in **1825 BS (1768 CE)**, he adopted Bikram Sambat as the standard calendar for royal seals (*Lal Mohar*), military directives, treaties, and administrative governance. In **1958 BS (1901 CE)**, during the premiership of Rana Prime Minister **Chandra Shumsher Jung Bahadur Rana**, Bikram Sambat was formally promulgated by imperial decree as the **sole official civil and administrative calendar of the Kingdom of Nepal**, standardizing astronomical solar calculations across all government offices. --- ## Chronological Timeline of Events Explore the two-thousand-year progression of Bikram Sambat from its ancient foundation to its constitutional mandate in modern Nepal: King Vikramaditya of Ujjain liberates the Malwa region from invading Saka (Indo-Scythian) rulers. To mark the triumph and provide debt relief to his citizens, the Vikram Samvat era begins, situated approximately 56.7 years ahead of the Common Era (AD). The Saka Sambat is instituted across South Asia. In Nepal, early Licchavi monarchs adopt it as the standard epigraphic calendar for royal decrees and stone inscriptions. King Manadeva I erects the pillar inscription at the Changu Narayan Temple dated 386 Saka Sambat. This stands as Nepal's earliest conclusively verified written epigraphic record. King Amshuverma and King Jisnugupta introduce the shortened regional Manadeva Sambat across the Kathmandu Valley for public administration and diplomatic edicts. Merchant philanthropist Shankhadhar Sakhwa absolves all public debt in the Kathmandu Valley during the reign of King Raghavadeva. He inaugurates Nepal Sambat (1 NS) on Kartik Shukla Pratipada, which becomes the principal calendar of the Malla Dynasty. King Prithvi Malla of the Khasa Malla kingdom carves the historic Dullu stone pillar in Dailekh, Western Nepal. Carved explicitly in Bikram Sambat 1414 and ancient Khas Bhasha, it proves centuries of continuous Bikram Sambat usage across the Himalayan kingdoms. King Prithvi Narayan Shah of Gorkha unifies the kingdoms of Nepal and establishes Kathmandu as the nation's capital. Bikram Sambat is instituted as the standard administrative calendar for royal seals (Lal Mohar), state treaties, and administrative governance. Prime Minister Chandra Shumsher Jung Bahadur Rana officially proclaims Bikram Sambat as the sole primary civil and administrative calendar of the Kingdom of Nepal on Baisakh 1, 1958 BS, standardizing solar calendar calculations across government bureaus. Following the 1951 democratic revolution, Bikram Sambat is codified for parliamentary legislation, Supreme Court rulings, official Nepal Rajpatra (gazettes), and public administration. The Government of Nepal formalizes the Nepal Panchanga Nirnayak Samiti (Calendar Determination Committee) as the national regulatory body to mathematically verify planetary movements, festival dates, and calendar matrices. Nepal Standard Time (NPT) is officially standardized at UTC+05:45 based on the meridian of Mount Gauri Shankar (86°15' E), harmonizing civil timekeeping with astronomical calendar operations. The promulgation of the Constitution of Nepal in 2072 BS re-affirms Bikram Sambat as the official calendar for state organs, national budgets, and civil registries. --- ## Astronomical Foundations & Calendar Mechanics Unlike the Western Gregorian calendar, which is a **solar tropical** calendar based on the cycle of the seasons (equinoxes and solstices), Bikram Sambat is a **solar sidereal (*Nirayana*)** calendar governed by the principles of classical Hindu astronomy (*Surya Siddhanta*). ### 1. The Sidereal Solar Year (*Nirayana Saur Varsha*) A sidereal year is the time it takes the Earth to complete one full revolution around the Sun relative to the fixed stars. - The tropical year (used by Gregorian) equals approximately **365.2422 days**. - The sidereal year (used by Bikram Sambat) equals approximately **365.25636 days**. - Due to the precession of the equinoxes (*Ayanamsha*), the sidereal year advances forward relative to the tropical year by approximately **1 day every 71.6 years**. ### 2. Solar Ingress (*Sankranti*) In Bikram Sambat, the first day of every month begins upon the Sun's transit (*Sankranti*) from one zodiac constellation (*Rashi*) into the next: - **Mesha Sankranti (Aries Ingress)**: Marks the entrance of the Sun into the constellation of Mesha (Aries). This exact astronomical occurrence defines **Baisakh 1**, celebrating **Nepali New Year (*Nawa Barsha*)**. - **Makar Sankranti (Capricorn Ingress)**: Marks the Sun's entrance into Makara, signaling the winter solstice turning point and the festival of **Maghe Sankranti**. ### 3. Kepler's Second Law & Variable Month Lengths (29 to 32 Days) A defining characteristic of Bikram Sambat is that **month lengths vary between 29 and 32 days from year to year**. This is not arbitrary; it is a direct consequence of celestial mechanics: 1. According to **Kepler's Second Law**, Earth travels faster along its elliptical orbit when it is closest to the Sun (perihelion, occurring in early January) and slower when it is farthest from the Sun (aphelion, occurring in early July). 2. Because the Earth moves faster during the northern hemisphere's winter, the Sun appears to traverse the winter constellations (Dhanu, Makara, Kumbha) in less time. Consequently, winter months like **Kartik, Mangsir, Poush, and Magh** typically span **29 to 30 days**. 3. During the northern hemisphere's summer, the Earth moves slower in its orbit, taking longer to traverse constellations like Mithuna and Karkata. Consequently, summer months like **Jestha, Ashadh, Shrawan, and Bhadra** typically span **31 to 32 days**. > [!NOTE] > Because the exact moment of Sankranti can occur at any hour of the day or night, canonical Panchanga rules determine whether the new month begins on the same solar day (if Sankranti occurs before sunset or noon) or the following solar day. This produces variations where a given month may have 31 days in one year, but 32 days in another. --- ## The 12 Nepali Months & Seasonal Cycles (*Ritus*) The Bikram Sambat year consists of **12 solar months** categorized into **six traditional two-month seasons (*Ritus*)**: | # | Month (English) | Month (नेपाली) | Zodiac Sign (*Rashi*) | Season (*Ritu*) | Gregorian Span | Days Range | | :---: | :--- | :--- | :--- | :--- | :--- | :---: | | **1** | **Baisakh** | बैशाख | Mesha (मेष - Aries) | Basanta (वसन्तः - Spring) | Apr 13/14 – May 13/14 | 30 – 31 | | **2** | **Jestha** | जेठ | Vrishabha (वृषभ - Taurus) | Grishma (ग्रीष्म - Summer) | May 14/15 – Jun 14/15 | 31 – 32 | | **3** | **Ashadh** | असार | Mithuna (मिथुन - Gemini) | Grishma (ग्रीष्म - Summer) | Jun 15/16 – Jul 15/16 | 31 – 32 | | **4** | **Shrawan** | श्रावण / साउन | Karkata (कर्कट - Cancer) | Barsha (वर्षा - Monsoon) | Jul 16/17 – Aug 16/17 | 31 – 32 | | **5** | **Bhadra** | भाद्र / भदौ | Simha (सिंह - Leo) | Barsha (वर्षा - Monsoon) | Aug 17/18 – Sep 16/17 | 31 – 32 | | **6** | **Ashwin** | आश्विन / असोज | Kanya (कन्या - Virgo) | Sharad (शरद् - Autumn) | Sep 17/18 – Oct 17/18 | 30 – 31 | | **7** | **Kartik** | कार्तिक / कात्तिक | Tula (तुला - Libra) | Sharad (शरद् - Autumn) | Oct 18/19 – Nov 15/16 | 29 – 30 | | **8** | **Mangsir** | मार्ग / मंसिर | Vrischika (वृश्चिक - Scorpio) | Hemanta (हेमन्त - Late Autumn) | Nov 16/17 – Dec 15/16 | 29 – 30 | | **9** | **Poush** | पौष / पुस | Dhanu (धनु - Sagittarius) | Hemanta (हेमन्त - Late Autumn) | Dec 16/17 – Jan 14/15 | 29 – 30 | | **10** | **Magh** | माघ | Makara (मकर - Capricorn) | Shishir (शिशिर - Winter) | Jan 15/16 – Feb 12/13 | 29 – 30 | | **11** | **Falgun** | फाल्गुन / फागुन | Kumbha (कुम्भ - Aquarius) | Shishir (शिशिर - Winter) | Feb 13/14 – Mar 13/14 | 29 – 30 | | **12** | **Chaitra** | चैत्र / चैत | Mina (मीन - Pisces) | Basanta (वसन्तः - Spring) | Mar 14/15 – Apr 12/13 | 30 – 31 | --- ## Days of the Week (*Vaar*) The seven-day week in Bikram Sambat mirrors the classical planetary order (*Navagraha*): | Day (English) | Day (नेपाली) | Devanagari | Planetary Body | Meaning | | :--- | :--- | :--- | :--- | :--- | | **Sunday** | Aaitabar | आइतबार | Aditya / Surya (सूर्य) | Day of the Sun | | **Monday** | Sombar | सोमबार | Soma / Chandra (चन्द्र) | Day of the Moon | | **Tuesday** | Mangalbar | मङ्गलबार | Mangala (मङ्गल) | Day of Mars | | **Wednesday** | Budhabar | बुधबार | Budha (बुध) | Day of Mercury | | **Thursday** | Bihibar | बिहिबार | Brihaspati / Guru (बृहस्पति) | Day of Jupiter | | **Friday** | Shukrabar | शुक्रबार | Shukra (शुक्र) | Day of Venus | | **Saturday** | Sanibar | शनिबार | Shani (शनि) | Day of Saturn | --- ## The Nepalese Fiscal Year (*Aarthik Barsha*) In Nepal, both public finance and commercial corporate reporting run on an official fiscal cycle defined entirely by Bikram Sambat dates: - **Fiscal Year Start**: **1 Shrawan** (approximately mid-July). - **Fiscal Year End**: **Last day of Ashadh** (approximately mid-July of the following year). - **Format**: Written as `YYYY/YY` in BS (for example, `2081/82 BS`). - **Quarterly Accounting Windows**: - **Q1 (First Quarter)**: Shrawan 1 – Kartik end - **Q2 (Second Quarter)**: Mangsir 1 – Poush end - **Q3 (Third Quarter)**: Magh 1 – Chaitra end - **Q4 (Fourth Quarter)**: Baisakh 1 – Ashadh end All corporate income tax filings, government budget announcements (constitutionally mandated on 15 Jestha BS), and audited balance sheets operate strictly within this fiscal boundary. --- ## Bikram Sambat (BS) vs. Gregorian (AD) Comparison | Dimension | Bikram Sambat (BS) | Gregorian Calendar (AD / CE) | | :--- | :--- | :--- | | **System Classification** | Solar Sidereal (*Nirayana*) | Solar Tropical (*Sayana*) | | **Reference Epoch** | 57 BCE (Victory of Vikramaditya) | 1 CE (Traditional Anno Domini) | | **Year Discrepancy** | Approx **56 years, 8 months ahead** | Baseline (+0) | | **New Year Day** | **1 Baisakh** (mid-April) | January 1 | | **Month Calculation** | Astrological solar ingress (*Sankranti*) | Arbitrarily fixed human convention | | **Month Lengths** | Variable dynamically: **29, 30, 31, 32 days** | Fixed: 28/29, 30, 31 days | | **Leap Day Mechanism** | Natural solar variance across constellations | Quadrennial Leap Day (+1 day in Feb) | | **Certifying Body** | **Nepal Panchanga Nirnayak Samiti** | International Earth Rotation Service (IERS) | | **Official Civil Status** | **National Calendar of Nepal** | International standard (ISO 8601) | --- ## Technical Implications for Software Engineering Building software applications that handle Bikram Sambat presents unique architectural requirements that do not exist with purely algorithmic calendars: ### 1. Mathematical Algorithms Cannot Predict Month Lengths In the Gregorian calendar, determining if a year is a leap year requires a simple formula: ``` (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0) ``` In Bikram Sambat, **no such modular formula exists**. Because month lengths depend on the precise astronomical minute of the Sun's transit across constellations as observed from Kathmandu, month lengths are certified yearly by the **Nepal Panchanga Nirnayak Samiti**. ### 2. Comprehensive Calendar Mapping & Annual Ashwin Verification Because modular formulas cannot predict month lengths, reliable date libraries must embed pre-computed lookup matrices containing verified month lengths for historical and modern Bikram Sambat years. The **Nepali Date Library** embeds calendar mapping data spanning **1976 BS through 2100 BS** (more than 124 years). Because the official Government of Nepal calendar for the upcoming year is released annually in the month of **Ashwin (Ashoj)** by the **Nepal Panchanga Nirnayak Samiti**, the library verifies dates up to the current active year and incorporates authoritative government updates annually upon publication. ### 3. Database Architecture Recommendation When architecting systems supporting Bikram Sambat: - **Storage Layer**: Store all temporal values in databases as standard UTC timestamps or ISO-8601 Gregorian dates (`YYYY-MM-DD`). - **Application Layer**: Use `nepali-date-library` to convert UTC timestamps to Bikram Sambat dates for UI display, fiscal reports, date pickers, and localized formatting. - **Form Inputs**: Convert user-entered Bikram Sambat values to Gregorian prior to saving in persistent storage. ### 4. Nepal Standard Time (NPT) Nepal Standard Time is **UTC+05:45**, one of the few non-hourly timezones in the world. It is calculated based on the meridian passing through the summit of **Mount Gauri Shankar** at longitude **86°15' East**. When performing date calculations near midnight, ensure that your application accounts for the +05:45 offset to avoid single-day boundary shifts. --- ## Page: Project Overview (/docs/overview) Description: Comprehensive overview of the Nepali Date Library multi-language ecosystem, live package metrics, architecture, and developer profile. The **Nepali Date Library** is an open-source, production-grade computational suite engineered to bring accurate, standardized, and zero-dependency **Bikram Sambat (BS)** date operations to modern software ecosystems across **Node.js / TypeScript**, **Python**, and **PHP**. Whether you are building financial banking software adhering to Nepal's Shrawan-to-Ashadh fiscal calendar, government enterprise portals, e-commerce checkouts, or mobile applications, the suite provides unified semantics and continuously audited calendar tables. --- ## Ecosystem Distributions & Metrics The library is officially distributed across the primary package registries of each supported language ecosystem: --- ## Core Architectural Pillars The library suite is built around five foundational design principles: ### 1. Zero External Dependencies Every package in the suite is built from the ground up without runtime external dependencies. This eliminates supply-chain risks, avoids version conflicts, and keeps bundle footprints minimal. ### 2. Standardized Cross-Language API Developers working across full-stack applications (e.g., a Python backend with a Node.js frontend or a PHP Laravel service with a TypeScript worker) enjoy identical method names, formatting tokens, and date manipulation semantics. ### 3. Annual Calendar Verification & 124-Year Range (1976 – 2100 BS) Because Bikram Sambat months are based on solar ingress (*Sankranti*) and vary from 29 to 32 days based on astronomical solar transit, official month lengths are determined each year by the **Nepal Panchanga Nirnayak Samiti** (नेपाल पञ्चाङ्ग निर्णायक समिति). Every year around the month of **Ashwin (Ashoj)**, when the Government of Nepal officially gazettes the upcoming year's calendar, the library audits and updates its mapping data. Dates up to the current active calendar year are verified against official gazettes, while future projections up to 2100 BS are systematically updated each year upon official publication. ### 4. High-Throughput Performance All date conversions and arithmetic execute in under a few microseconds, making the library suitable for high-frequency database batch migrations, real-time analytics pipelines, and edge compute functions. ### 5. Built-In Nepalese Fiscal Year Logic Native support for Nepal's official fiscal calendar (*Aarthik Barsha*), running from 1 Shrawan to the final day of Ashadh, including quarter categorization (Q1 to Q4) and fiscal year string formatting (`2081/82`). --- ## Feature Matrix Across SDKs | Feature Capability | Node.js / TypeScript | Python | PHP | | :--- | :---: | :---: | :---: | | **Bidirectional AD ↔ BS Conversion** | Yes | Yes | Yes | | **Supported Range (1976 – 2100 BS)** | Yes | Yes | Yes | | **Date Arithmetic (+/- Days, Months, Years)** | Yes | Yes | Yes | | **Custom Format Tokens (`YYYY-MM-DD`, etc.)** | Yes | Yes | Yes | | **Nepali Fiscal Year & Quarter Calculation** | Yes | Yes | Yes | | **Devanagari Numerals & Month Names** | Yes | Yes | Yes | | **Strict Type Safety & IntelliSense** | TypeScript types (`.d.ts`) | Type hints (`py.typed`) | PHP 8.0+ strict typing | | **Zero Runtime Dependencies** | Yes | Yes | Yes | | **Package Distribution** | npm / yarn / pnpm | PyPI (pip / uv / poetry) | Packagist (Composer) | --- ## Maintainer Created and maintained by **Sandip Ghimire**: --- ## Open Source & Licensing The entire Nepali Date Library suite is released under the permissive **MIT License**, permitting unrestricted commercial use, modification, distribution, and private deployment. Contributions, feature proposals, and bug reports are warmly welcomed across the respective GitHub repositories: - Submit issues or pull requests to the corresponding language repository. - Follow standard semantic versioning practices when proposing changes. - Ensure that any proposed additions preserve zero external runtime dependencies. --- ## Page: Overview (PHP) (/docs/php) Description: [PHP] Complete documentation and feature guide for the Nepali Date Library in PHP applications. Official API reference and code examples for PHP. The Nepali Date Library for PHP provides a modern object oriented toolkit with zero external dependencies for Bikram Sambat calendar operations. It handles bidirectional conversion between Bikram Sambat and Gregorian calendars, date arithmetic, custom string formatting, fiscal year calculations, and calendar grid generation for PHP web applications and enterprise systems. --- ## Installation Install the package via Composer: ```bash composer require sghimire/nepali-date-library ``` --- ## Quick Example ```php format('YYYY-MM-DD'); // Specific Bikram Sambat date (month 0 is Baisakh) $event = new NepaliDate(2081, 6, 15); echo $event->format('dddd, MMMM DD, YYYY'); // Standalone date conversion helpers $bsDate = ADtoBS('2024-11-15'); $adDate = BStoAD('2081-07-30'); ``` --- ## Feature Matrix | Feature | Support | Description | | :--- | :---: | :--- | | **Bikram Sambat Calendar Engine** | Yes | Calendar matrix spanning 1976 through 2100 BS, audited and updated annually each Ashwin. | | **Bidirectional AD to BS Conversion** | Yes | Standalone conversion functions and full object instances. | | **Date Arithmetic** | Yes | Add and subtract days, months, and years with automatic rollover. | | **Fiscal Year Operations** | Yes | Official Nepalese fiscal calendar starting on 1 Shrawan. | | **Custom Format Patterns** | Yes | Token formatting for year, month, weekday, and Devanagari script. | | **Calendar Grid Builder** | Yes | Forty two cell matrix generation for calendar interfaces. | --- ## Package Information | Specification | Details | | :--- | :--- | | **Composer Package** | [`sghimire/nepali-date-library`](https://packagist.org/packages/sghimire/nepali-date-library) | | **Repository** | [GitHub](https://github.com/SandipGhimire/Nepali-Date-Library-PHP) | | **Supported PHP** | PHP 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4+ | | **License** | MIT License | --- ## Page: new NepaliDate() (PHP) (/docs/php/class/constructor) Description: [PHP] Constructor overloads and initialization options for creating NepaliDate instances in PHP. Official API reference and code examples for PHP. The `NepaliDate` constructor creates instances representing specific points in time mapped to the Bikram Sambat calendar system. You can construct an instance representing the current moment, provide separate year, month, and day integers, supply a standard date string, or pass a native PHP DateTimeInterface object. Bikram Sambat months are indexed starting from 0 for Baisakh through 11 for Chaitra. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signatures ```php // 1. Current Date and Time new NepaliDate(): NepaliDate; // 2. From PHP DateTimeInterface object new NepaliDate(DateTimeInterface $date): NepaliDate; // 3. From another NepaliDate instance (copy constructor) new NepaliDate(NepaliDate $date): NepaliDate; // 4. From Bikram Sambat date string new NepaliDate(string $dateString): NepaliDate; // 5. From separate Year, Month, Day integers new NepaliDate(int $year, int $month, int $day): NepaliDate; // 6. From Unix millisecond timestamp new NepaliDate(int $timestampMs): NepaliDate; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$yearOrDate` | `int`, `string`, `DateTimeInterface`, `NepaliDate`, `null` | No | Year integer, ISO date string, DateTimeInterface, or another NepaliDate instance. | | `$month` | `int`, `null` | No | Zero based month index from `0` for Baisakh to `11` for Chaitra when specifying integers. | | `$day` | `int`, `null` | No | Day of the month from `1` to `32` depending on the year and month. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: A newly instantiated `NepaliDate` instance representing the specified point in time. --- ## Examples ### Current Date and Time ```php use NepaliDateLibrary\NepaliDate; $now = new NepaliDate(); echo $now->format('YYYY-MM-DD'); ``` ### From Numeric Coordinates ```php // Month 0 is Baisakh, Day 1 $newYear = new NepaliDate(2081, 0, 1); echo $newYear->format('YYYY-MM-DD'); // "2081-01-01" ``` ### From Date String ```php // Delimiters can be hyphens, slashes, or dots $date1 = new NepaliDate('2081-07-15'); $date2 = new NepaliDate('2081/07/15'); $date3 = new NepaliDate('2081.07.15'); ``` ### From PHP DateTimeImmutable ```php use DateTimeImmutable; use DateTimeZone; use NepaliDateLibrary\NepaliDate; $adDate = DateTimeImmutable::createFromFormat('!Y-m-d', '2024-10-31', new DateTimeZone('UTC')); $nd = new NepaliDate($adDate); echo $nd->format('YYYY-MM-DD'); // "2081-07-15" ``` --- ## Related * [`Instance Properties`](/docs/php/class/properties): Getters for calendar coordinates. * [`date->set()`](/docs/php/methods/set): Update year, month, and day coordinates simultaneously. --- ## Page: Instance Properties & Getters (PHP) (/docs/php/class/properties) Description: [PHP] Guide to property encapsulation and public getters available on every NepaliDate instance in PHP. Official API reference and code examples for PHP. In PHP the `NepaliDate` class follows strict object oriented encapsulation principles. Internal state properties are private to protect calendar integrity, while public getter methods provide access to the four digit Bikram Sambat year, zero based month index, day of the month, and underlying Gregorian timestamp. --- ## Public Getters Reference | Method | Return Type | Description | Value Range | | :--- | :--- | :--- | :--- | | `$date->getYear()` | `int` | The four digit Bikram Sambat year. | `1976` to `2100` | | `$date->getMonth()` | `int` | The zero based Bikram Sambat month index. | `0` (Baisakh) to `11` (Chaitra) | | `$date->getDate()` | `int` | The day of the month. | `1` to `32` | | `$date->getEnglishDate()` | `DateTimeImmutable` | The equivalent Gregorian date in UTC. | Native PHP DateTimeImmutable | | `$date->getTime()` | `int` | The Unix epoch millisecond timestamp. | 64-bit integer timestamp | --- ## Examples ### Reading Coordinates via Getters ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); echo $date->getYear(); // 2081 echo $date->getMonth(); // 6 (Kartik is index 6) echo $date->getDate(); // 15 echo $date->getEnglishDate()->format('Y-m-d'); // "2024-10-31" ``` ### Working with Month Indices Because `$date->getMonth()` is zero based, add 1 when outputting conventional month numbers: ```php $humanMonth = $date->getMonth() + 1; // 7 echo NepaliDate::getMonthName($date->getMonth()); // "Kartik" ``` --- ## Related * [`date->getYear()`](/docs/php/methods/get-year): Getter method for year. * [`date->getMonth()`](/docs/php/methods/get-month): Getter method for month index. * [`date->getDate()`](/docs/php/methods/get-date): Getter method for day of month. --- ## Page: Constants::$MONTH_EN (PHP) (/docs/php/constants/month-en) Description: [PHP] Array containing standard romanized English names of all twelve Bikram Sambat calendar months. Official API reference and code examples for PHP. The `Constants::$MONTH_EN` constant is an immutable array containing the official romanized English names of the twelve Bikram Sambat months. The array is indexed starting from 0 for Baisakh up to index 11 for Chaitra, making it convenient for looking up month names corresponding to numeric month values returned by date methods. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$MONTH_EN = [ "Baisakh", "Jestha", "Asar", "Shrawan", "Bhadra", "Aswin", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra", ]; ``` --- ## Month Index Table | Index | English Name | Approximate Gregorian Window | | :---: | :--- | :--- | | `0` | `"Baisakh"` | Mid April to Mid May | | `1` | `"Jestha"` | Mid May to Mid June | | `2` | `"Asar"` | Mid June to Mid July | | `3` | `"Shrawan"` | Mid July to Mid August | | `4` | `"Bhadra"` | Mid August to Mid September | | `5` | `"Aswin"` | Mid September to Mid October | | `6` | `"Kartik"` | Mid October to Mid November | | `7` | `"Mangsir"` | Mid November to Mid December | | `8` | `"Poush"` | Mid December to Mid January | | `9` | `"Magh"` | Mid January to Mid February | | `10` | `"Falgun"` | Mid February to Mid March | | `11` | `"Chaitra"` | Mid March to Mid April | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); $monthIndex = $date->getMonth(); echo Constants::$MONTH_EN[$monthIndex]; // "Kartik" ``` --- ## Related * [`Constants::$MONTH_SHORT_EN`](/docs/php/constants/month-short-en): Abbreviated three letter English month names. * [`Constants::$MONTH_NP`](/docs/php/constants/month-np): Full Devanagari Nepali month names. --- ## Page: Constants::$MONTH_NP (PHP) (/docs/php/constants/month-np) Description: [PHP] Array containing official Devanagari Nepali names of all twelve Bikram Sambat calendar months. Official API reference and code examples for PHP. The `Constants::$MONTH_NP` constant is an immutable array containing the standard Nepali names in Devanagari script for the twelve Bikram Sambat months. Each index maps directly to the zero based month number, starting at index 0 for Baisakh through index 11 for Chaitra, enabling accurate localization in user interfaces and printed documents. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$MONTH_NP = [ "बैशाख", "जेठ", "असार", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मंसिर", "पौष", "माघ", "फाल्गुण", "चैत्र", ]; ``` --- ## Month Index Table | Index | Devanagari Name | Romanized Name | | :---: | :--- | :--- | | `0` | `बैशाख` | Baisakh | | `1` | `जेठ` | Jestha | | `2` | `असार` | Asar | | `3` | `श्रावण` | Shrawan | | `4` | `भाद्र` | Bhadra | | `5` | `आश्विन` | Aswin | | `6` | `कार्तिक` | Kartik | | `7` | `मंसिर` | Mangsir | | `8` | `पौष` | Poush | | `9` | `माघ` | Magh | | `10` | `फाल्गुण` | Falgun | | `11` | `चैत्र` | Chaitra | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); echo Constants::$MONTH_NP[$date->getMonth()]; // "कार्तिक" ``` --- ## Related * [`Constants::$MONTH_SHORT_NP`](/docs/php/constants/month-short-np): Short Devanagari month abbreviations. * [`Constants::$MONTH_EN`](/docs/php/constants/month-en): Romanized English month names. --- ## Page: Constants::$MONTH_SHORT_EN (PHP) (/docs/php/constants/month-short-en) Description: [PHP] Array containing three letter abbreviated English names for all twelve Bikram Sambat months. Official API reference and code examples for PHP. The `Constants::$MONTH_SHORT_EN` constant provides three letter abbreviated English labels for each of the twelve Bikram Sambat months. It follows the zero based index convention from index 0 for Bai up to index 11 for Cha, making it ideal for compact calendar widgets, mobile screens, and table headers. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$MONTH_SHORT_EN = [ "Bai", "Jes", "Asa", "Shr", "Bhd", "Asw", "Kar", "Man", "Pou", "Mag", "Fal", "Cha", ]; ``` --- ## Month Abbreviation Table | Index | Abbreviation | Full Name | | :---: | :--- | :--- | | `0` | `"Bai"` | Baisakh | | `1` | `"Jes"` | Jestha | | `2` | `"Asa"` | Asar | | `3` | `"Shr"` | Shrawan | | `4` | `"Bhd"` | Bhadra | | `5` | `"Asw"` | Aswin | | `6` | `"Kar"` | Kartik | | `7` | `"Man"` | Mangsir | | `8` | `"Pou"` | Poush | | `9` | `"Mag"` | Magh | | `10` | `"Fal"` | Falgun | | `11` | `"Cha"` | Chaitra | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); echo Constants::$MONTH_SHORT_EN[$date->getMonth()]; // "Kar" ``` --- ## Related * [`Constants::$MONTH_EN`](/docs/php/constants/month-en): Full English month names. * [`Constants::$MONTH_SHORT_NP`](/docs/php/constants/month-short-np): Devanagari short month abbreviations. --- ## Page: Constants::$MONTH_SHORT_NP (PHP) (/docs/php/constants/month-short-np) Description: [PHP] Array containing abbreviated Devanagari Nepali names for all twelve Bikram Sambat calendar months. Official API reference and code examples for PHP. The `Constants::$MONTH_SHORT_NP` constant supplies short Devanagari abbreviations for each Bikram Sambat month. Starting with index 0 for Baisakh and ending with index 11 for Chaitra, these abbreviated labels are designed for space constrained displays such as date pickers, dashboard summaries, and mobile layouts. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$MONTH_SHORT_NP = [ "बै", "जे", "अ", "श्रा", "भा", "आ", "का", "मं", "पौ", "मा", "फा", "चै", ]; ``` --- ## Month Abbreviation Table | Index | Short Devanagari | Full Devanagari | Romanized | | :---: | :--- | :--- | :--- | | `0` | `बै` | बैशाख | Baisakh | | `1` | `जे` | जेठ | Jestha | | `2` | `अ` | असार | Asar | | `3` | `श्रा` | श्रावण | Shrawan | | `4` | `भा` | भाद्र | Bhadra | | `5` | `आ` | आश्विन | Aswin | | `6` | `का` | कार्तिक | Kartik | | `7` | `मं` | मंसिर | Mangsir | | `8` | `पौ` | पौष | Poush | | `9` | `मा` | माघ | Magh | | `10` | `फा` | फाल्गुण | Falgun | | `11` | `चै` | चैत्र | Chaitra | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); echo Constants::$MONTH_SHORT_NP[$date->getMonth()]; // "का" ``` --- ## Related * [`Constants::$MONTH_NP`](/docs/php/constants/month-np): Full Devanagari month names. * [`Constants::$MONTH_SHORT_EN`](/docs/php/constants/month-short-en): Three letter English month abbreviations. --- ## Page: Constants::$NEPALI_DATE_MAP (PHP) (/docs/php/constants/nepali-date-map) Description: [PHP] Historical calendar mapping table storing verified day counts for every Bikram Sambat month between 1976 and 2100 BS. Official API reference and code examples for PHP. The `Constants::$NEPALI_DATE_MAP` data structure contains the calendar matrix for the Bikram Sambat system spanning years 1976 through 2100 BS. Because Bikram Sambat months have variable day counts determined by astronomical solar calculations rather than fixed rules, this mapping table provides the definitive source of truth for conversions, day calculations, and month lengths. > [!NOTE] > Dates up to the active calendar year are verified against official publications from the **Nepal Panchanga Nirnayak Samiti** (नेपाल पञ्चाङ्ग निर्णायक समिति). Every year around the month of **Ashwin (Ashoj)**, when the official government calendar is gazetted for the subsequent year, this mapping table is audited and updated with exact solar ingress corrections. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Structure ```php class Constants { /** * @var array */ public static $NEPALI_DATE_MAP; } ``` --- ## Field Reference | Field | Type | Description | | :--- | :--- | :--- | | `year` | `int` | The Bikram Sambat year integer between 1976 and 2100 BS. | | `days` | `int[]` | Twelve integers specifying the exact day counts for each month from Baisakh to Chaitra. | | `totalDays` | `int` | Total cumulative days in that specific calendar year. | | `daysTillNow` | `int` | Cumulative day offset since the calendar epoch. | --- ## Example Usage ```php use NepaliDateLibrary\Helper\Constants; // Retrieve month day counts for year 2081 BS $year2081 = null; foreach (Constants::$NEPALI_DATE_MAP as $entry) { if ($entry['year'] === 2081) { $year2081 = $entry; break; } } echo "Days in Baisakh 2081: " . $year2081['days'][0]; // 31 ``` --- ## Related * [`date->daysInMonth()`](/docs/php/methods/days-in-month): Query total days in a given month. * [`NepaliDate::isValid()`](/docs/php/static/is-valid): Statically validate calendar coordinates. --- ## Page: Constants::$NUMBER_NP (PHP) (/docs/php/constants/number-np) Description: [PHP] Array containing Devanagari numeral glyphs for digits zero through nine used for Nepali number localization. Official API reference and code examples for PHP. The `Constants::$NUMBER_NP` constant is an array containing the ten Devanagari numeral characters representing digits 0 through 9 in Nepali script. It provides a direct lookup table for formatting numbers, years, dates, and currency values into native Devanagari script for Nepali language interfaces. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$NUMBER_NP = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"]; ``` --- ## Digit Lookup Table | Index | Arabic Digit | Devanagari Numeral | Unicode Code Point | | :---: | :---: | :---: | :--- | | `0` | `0` | `०` | `U+0966` | | `1` | `1` | `१` | `U+0967` | | `2` | `2` | `२` | `U+0968` | | `3` | `3` | `३` | `U+0969` | | `4` | `4` | `४` | `U+096A` | | `5` | `5` | `५` | `U+096B` | | `6` | `6` | `६` | `U+096C` | | `7` | `7` | `७` | `U+096D` | | `8` | `8` | `८` | `U+096E` | | `9` | `9` | `९` | `U+096F` | --- ## Examples ```php use NepaliDateLibrary\Helper\Constants; function toDevanagari(int $number): string { $digits = str_split((string) $number); return implode('', array_map(function ($d) { return Constants::$NUMBER_NP[(int) $d]; }, $digits)); } echo toDevanagari(2081); // "२०८१" ``` --- ## Related * [`date->format()`](/docs/php/methods/format): Format dates with Devanagari token support. * [`Constants::$MONTH_NP`](/docs/php/constants/month-np): Devanagari month names. --- ## Page: Constants::$WEEK_EN (PHP) (/docs/php/constants/week-en) Description: [PHP] Array containing full English names for all seven days of the week starting from Sunday. Official API reference and code examples for PHP. The `Constants::$WEEK_EN` constant is an array containing the full English weekday names ordered from Sunday at index 0 through Saturday at index 6. This ordering matches the standard day index convention returned by date methods, allowing seamless weekday lookups in English interfaces. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$WEEK_EN = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", ]; ``` --- ## Weekday Index Table | Index | English Name | Nepali Equivalent | | :---: | :--- | :--- | | `0` | `"Sunday"` | Aaitabar | | `1` | `"Monday"` | Sombar | | `2` | `"Tuesday"` | Mangalbar | | `3` | `"Wednesday"` | Budhabar | | `4` | `"Thursday"` | Bihibar | | `5` | `"Friday"` | Sukrabar | | `6` | `"Saturday"` | Shanibar | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); echo Constants::$WEEK_EN[$date->getDay()]; // "Friday" ``` --- ## Related * [`Constants::$WEEK_SHORT_EN`](/docs/php/constants/week-short-en): Abbreviated three letter English weekday names. * [`Constants::$WEEK_NP`](/docs/php/constants/week-np): Full Devanagari Nepali weekday names. --- ## Page: Constants::$WEEK_NP (PHP) (/docs/php/constants/week-np) Description: [PHP] Array containing full Devanagari Nepali names for all seven days of the week starting from Sunday. Official API reference and code examples for PHP. The `Constants::$WEEK_NP` constant provides the full Devanagari Nepali names for the seven days of the week, beginning with Aaitabar at index 0 and concluding with Shanibar at index 6. It enables complete localization for calendar headings, date labels, and event scheduling in Nepali language applications. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$WEEK_NP = [ "आइतबार", "सोमबार", "मंगलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार", ]; ``` --- ## Weekday Index Table | Index | Devanagari Name | Romanized | English | | :---: | :--- | :--- | :--- | | `0` | `आइतबार` | Aaitabar | Sunday | | `1` | `सोमबार` | Sombar | Monday | | `2` | `मंगलबार` | Mangalbar | Tuesday | | `3` | `बुधबार` | Budhabar | Wednesday | | `4` | `बिहिबार` | Bihibar | Thursday | | `5` | `शुक्रबार` | Sukrabar | Friday | | `6` | `शनिबार` | Shanibar | Saturday | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); echo Constants::$WEEK_NP[$date->getDay()]; // "शुक्रबार" ``` --- ## Related * [`Constants::$WEEK_SHORT_NP`](/docs/php/constants/week-short-np): Short Devanagari weekday abbreviations. * [`Constants::$WEEK_EN`](/docs/php/constants/week-en): Full English weekday names. --- ## Page: Constants::$WEEK_SHORT_EN (PHP) (/docs/php/constants/week-short-en) Description: [PHP] Array containing abbreviated English weekday names ordered from Sunday through Saturday. Official API reference and code examples for PHP. The `Constants::$WEEK_SHORT_EN` constant contains short three letter English abbreviations for each day of the week, starting with Sun at index 0 and ending with Sat at index 6. These concise labels are widely used in monthly calendar headers, compact date selectors, and agenda views. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$WEEK_SHORT_EN = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ]; ``` --- ## Weekday Abbreviation Table | Index | Abbreviation | Full Name | | :---: | :--- | :--- | | `0` | `"Sun"` | Sunday | | `1` | `"Mon"` | Monday | | `2` | `"Tue"` | Tuesday | | `3` | `"Wed"` | Wednesday | | `4` | `"Thu"` | Thursday | | `5` | `"Fri"` | Friday | | `6` | `"Sat"` | Saturday | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); echo Constants::$WEEK_SHORT_EN[$date->getDay()]; // "Fri" ``` --- ## Related * [`Constants::$WEEK_EN`](/docs/php/constants/week-en): Full English weekday names. * [`Constants::$WEEK_SHORT_NP`](/docs/php/constants/week-short-np): Devanagari short weekday abbreviations. --- ## Page: Constants::$WEEK_SHORT_NP (PHP) (/docs/php/constants/week-short-np) Description: [PHP] Array containing short Devanagari abbreviations for each day of the week starting from Sunday. Official API reference and code examples for PHP. The `Constants::$WEEK_SHORT_NP` constant supplies short Devanagari abbreviations for each day of the week, beginning with index 0 for Aaitabar and ending with index 6 for Shanibar. These compact symbols are ideal for calendar grid headers and mobile date selectors where horizontal width is limited. --- ## Import ```php use NepaliDateLibrary\Helper\Constants; ``` --- ## Value ```php Constants::$WEEK_SHORT_NP = [ "आ", "सो", "मं", "बु", "बि", "शु", "श", ]; ``` --- ## Weekday Abbreviation Table | Index | Short Devanagari | Full Devanagari | English | | :---: | :--- | :--- | :--- | | `0` | `आ` | आइतबार | Sunday | | `1` | `सो` | सोमबार | Monday | | `2` | `मं` | मंगलबार | Tuesday | | `3` | `बु` | बुधबार | Wednesday | | `4` | `बि` | बिहिबार | Thursday | | `5` | `शु` | शुक्रबार | Friday | | `6` | `श` | शनिबार | Saturday | --- ## Example Usage ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); echo Constants::$WEEK_SHORT_NP[$date->getDay()]; // "शु" ``` --- ## Related * [`Constants::$WEEK_NP`](/docs/php/constants/week-np): Full Devanagari weekday names. * [`Constants::$WEEK_SHORT_EN`](/docs/php/constants/week-short-en): Three letter English weekday abbreviations. --- ## Page: Date Converter Guide (PHP) (/docs/php/date-converter) Description: [PHP] Comprehensive guide to converting dates between Gregorian and Bikram Sambat calendar systems using standalone helper functions. Official API reference and code examples for PHP. The date converter utilities provide pure standalone functions for converting date strings directly between the Gregorian calendar and the Bikram Sambat calendar. These functions operate without creating full class instances, making them suitable for high throughput batch processing, database migrations, and backend service integration. --- ## Available Functions The library exports two primary conversion functions in the `NepaliDateLibrary` namespace: * [`NepaliDateLibrary\ADtoBS(string $adDate)`](/docs/php/date-converter/ad-to-bs): Converts a Gregorian calendar date string to a Bikram Sambat date string. * [`NepaliDateLibrary\BStoAD(string $bsDate)`](/docs/php/date-converter/bs-to-ad): Converts a Bikram Sambat date string to a Gregorian calendar date string. --- ## Format Requirements Both functions require strict ISO formatted date strings: ```text YYYY-MM-DD ``` * Four digit year (`YYYY`) * Two digit month with leading zero (`MM`) * Two digit day with leading zero (`DD`) --- ## Comparison: Helper Functions vs NepaliDate Class | Requirement | Use `ADtoBS` and `BStoAD` | Use `NepaliDate` Class | | :--- | :---: | :---: | | Fast string conversion | Recommended | Optional | | Database pipelines and ETL | Recommended | Optional | | Date arithmetic (`addDays`, `diff`) | No | Recommended | | Custom token formatting | No | Recommended | | Calendar boundary calculations | No | Recommended | | Fiscal year operations | No | Recommended | --- ## Quick Example ```php use function NepaliDateLibrary\ADtoBS; use function NepaliDateLibrary\BStoAD; // Gregorian to Bikram Sambat $bs = ADtoBS('2024-11-15'); echo $bs; // "2081-07-30" // Bikram Sambat to Gregorian $ad = BStoAD('2081-07-30'); echo $ad; // "2024-11-15" ``` --- ## Page: ADtoBS() (PHP) (/docs/php/date-converter/ad-to-bs) Description: [PHP] Pure helper function to convert Gregorian calendar date strings into Bikram Sambat date strings. Official API reference and code examples for PHP. The `ADtoBS` function performs direct mathematical conversion of a Gregorian date string into its corresponding Bikram Sambat date string. It accepts standard date formats and returns the converted Nepali date, handling month day variations and leap year calculations automatically without external dependencies. --- ## Import ```php use function NepaliDateLibrary\ADtoBS; ``` --- ## Signature ```php function ADtoBS(string $adDate): string; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$adDate` | `string` | Yes | Gregorian date string formatted strictly as `YYYY-MM-DD`. | --- ## Return Value * **Type**: `string` * **Format**: `YYYY-MM-DD` representing the corresponding Bikram Sambat date. --- ## Exceptions | Exception Class | Trigger Condition | | :--- | :--- | | `InvalidArgumentException` | Thrown if input does not match format `YYYY-MM-DD` or contains invalid calendar dates. | | `RuntimeException` | Thrown if the date falls outside the supported historical range. | --- ## Examples ### Basic Conversion ```php use function NepaliDateLibrary\ADtoBS; $nepaliDate = ADtoBS('2023-04-14'); echo $nepaliDate; // "2080-01-01" ``` ### Processing Database Records ```php $records = [ ['id' => 1, 'created_at' => '2024-01-01'], ['id' => 2, 'created_at' => '2024-07-15'], ]; foreach ($records as &$item) { $item['created_at_bs'] = ADtoBS($item['created_at']); } ``` --- ## Related * [`BStoAD()`](/docs/php/date-converter/bs-to-ad): Reverse conversion from Bikram Sambat to Gregorian. * [`NepaliDate Class`](/docs/php/class/constructor): Full date manipulation and arithmetic object. --- ## Page: BStoAD() (PHP) (/docs/php/date-converter/bs-to-ad) Description: [PHP] Pure helper function to convert Bikram Sambat date strings into Gregorian calendar date strings. Official API reference and code examples for PHP. The `BStoAD` function converts a Bikram Sambat date string into its equivalent Gregorian calendar date string. It validates the input Nepali date against verified historical calendar maps and returns a formatted Gregorian date string suitable for storage in standard SQL databases or transmission over web APIs. --- ## Import ```php use function NepaliDateLibrary\BStoAD; ``` --- ## Signature ```php function BStoAD(string $bsDate): string; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$bsDate` | `string` | Yes | Bikram Sambat date string formatted strictly as `YYYY-MM-DD`. | --- ## Return Value * **Type**: `string` * **Format**: `YYYY-MM-DD` representing the equivalent Gregorian calendar date. --- ## Exceptions | Exception Class | Trigger Condition | | :--- | :--- | | `InvalidArgumentException` | Thrown if input does not match format `YYYY-MM-DD` or has out of range year, month, or day values. | | `RuntimeException` | Thrown if the conversion calculation fails unexpectedly. | --- ## Examples ### Basic Conversion ```php use function NepaliDateLibrary\BStoAD; $gregorianDate = BStoAD('2080-01-01'); echo $gregorianDate; // "2023-04-14" ``` ### Storing in SQL Databases ```php $userInputBs = '2081-07-15'; $databaseAdDate = BStoAD($userInputBs); echo $databaseAdDate; // "2024-10-31" ``` --- ## Related * [`ADtoBS()`](/docs/php/date-converter/ad-to-bs): Convert Gregorian date strings to Bikram Sambat. * [`date->getEnglishDate()`](/docs/php/methods/get-english-date): Retrieve a native PHP DateTimeImmutable object. --- ## Page: Fiscal Year & Quarters Guide (PHP) (/docs/php/fiscal-year) Description: [PHP] Architecture and calculation rules for Nepal official fiscal year and quarterly trimester accounting cycles. Official API reference and code examples for PHP. In Nepal the official fiscal year begins on 1 Shrawan and ends on the final day of Ashadh in the following calendar year. The nepali date library includes specialized functions to compute fiscal years, identify trimester quarters, and determine quarter start and end boundary dates for financial, tax, and accounting systems. --- ## Fiscal Year Structure Because the fiscal year starts in the fourth month of Bikram Sambat (Shrawan), every fiscal cycle spans two calendar years: * **Format**: Standardized as `YYYY/YY` (for example `2081/82 BS`). * **Start Date**: `1 Shrawan` (Month index `3`, Day `1`). * **End Date**: `Last day of Ashadh` (Month index `2`, Day `31` or `32` of the succeeding calendar year). --- ## Fiscal Quarters (Trimesters) The financial year in Nepal is divided into four three month trimesters: | Quarter | Trimester Name | Constituent Months | Month Indices | Approximate Period | | :---: | :--- | :--- | :---: | :--- | | **Q1** | First Trimester | Shrawan, Bhadra, Aswin | `3`, `4`, `5` | Mid July to Mid October | | **Q2** | Second Trimester | Kartik, Mangsir, Poush | `6`, `7`, `8` | Mid October to Mid January | | **Q3** | Third Trimester | Magh, Falgun, Chaitra | `9`, `10`, `11` | Mid January to Mid April | | **Q4** | Fourth Trimester | Baisakh, Jestha, Ashadh | `0`, `1`, `2` | Mid April to Mid July (Next Year) | --- ## Available API Methods | Method | Type | Description | | :--- | :---: | :--- | | [`NepaliDate::getCurrentFiscalYear()`](/docs/php/fiscal-year/get-current-fiscal-year) | Static | Returns the starting Bikram Sambat year of the active fiscal year. | | [`date->getCurrentFiscalYearQuarter()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter) | Instance | Returns the fiscal quarter index (1 to 4) for the date. | | [`date->getCurrentFiscalYearQuarterDates()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter-dates) | Instance | Returns exact start and end `NepaliDate` objects for the active fiscal quarter. | | [`NepaliDate::getFiscalYearQuarter()`](/docs/php/fiscal-year/get-fiscal-year-quarter) | Static | Returns start and end boundaries for any specified quarter and year. | | [`NepaliDate::getFiscalYearQuarters()`](/docs/php/fiscal-year/get-fiscal-year-quarters) | Static | Returns boundary dates for all four fiscal trimesters of a given year. | | [`Calendar Quarters Guide`](/docs/php/fiscal-year/calendar-quarters) | Guide | Explains standard Bikram Sambat calendar quarters vs fiscal trimesters. | --- ## Page: Calendar Quarters (PHP) (/docs/php/fiscal-year/calendar-quarters) Description: [PHP] Explanation of standard Bikram Sambat calendar quarters compared to government fiscal trimesters. Official API reference and code examples for PHP. Standard calendar quarters divide the Bikram Sambat calendar year into four equal three month periods starting from 1 Baisakh. This guide clarifies the structural difference between standard calendar quarters and Nepal government fiscal year trimesters, which commence three months later on 1 Shrawan. --- ## Calendar Quarters Breakdown Unlike the government fiscal calendar which begins in Shrawan, standard calendar quarters follow the natural calendar year starting from Baisakh: | Quarter | Months Included | Month Indices | Approximate Gregorian Window | | :---: | :--- | :---: | :--- | | **Q1** | Baisakh, Jestha, Asar | `0`, `1`, `2` | Mid April to Mid July | | **Q2** | Shrawan, Bhadra, Aswin | `3`, `4`, `5` | Mid July to Mid October | | **Q3** | Kartik, Mangsir, Poush | `6`, `7`, `8` | Mid October to Mid January | | **Q4** | Magh, Falgun, Chaitra | `9`, `10`, `11` | Mid January to Mid April | --- ## Related Methods in PHP The library provides dedicated methods for working with standard calendar quarters: ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-15'); // Calendar quarter number (1 to 4) echo $date->getCurrentQuarter(); // 1 // Static lookup for a specific year and quarter $q2Dates = NepaliDate::getQuarter(2, 2081); echo "Q2 starts: " . $q2Dates['start']->format('YYYY-MM-DD'); // All four calendar quarters for year 2081 $allQuarters = NepaliDate::getQuarters(2081); ``` --- ## Calendar vs Fiscal Quarters Comparison | Feature | Standard Calendar Quarter | Government Fiscal Trimester | | :--- | :--- | :--- | | **Year Start** | 1 Baisakh (Mid April) | 1 Shrawan (Mid July) | | **Q1 Months** | Baisakh, Jestha, Asar | Shrawan, Bhadra, Aswin | | **Methods** | `getCurrentQuarter()`, `getQuarter()` | `getCurrentFiscalYearQuarter()`, `getFiscalYearQuarter()` | | **Use Cases** | Public calendars, UI views, general scheduling | Taxes, government accounting, corporate audits | --- ## Page: NepaliDate::getCurrentFiscalYear() (PHP) (/docs/php/fiscal-year/get-current-fiscal-year) Description: [PHP] Method to retrieve the formatted fiscal year string for a given NepaliDate instance. Official API reference and code examples for PHP. The `getCurrentFiscalYear` method determines which official Nepalese fiscal year contains the current date instance. It returns a standardized fiscal year string such as 2081/82 based on whether the date falls before or after the 1 Shrawan fiscal transition boundary. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function getCurrentFiscalYear(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Description**: The starting four digit Bikram Sambat calendar year of the current fiscal year. * **Example**: Returns `2081` for fiscal year 2081/82 BS. --- ## Examples ### Checking Active Fiscal Year ```php use NepaliDateLibrary\NepaliDate; $fyStart = NepaliDate::getCurrentFiscalYear(); $fyLabel = "{$fyStart}/" . substr((string) ($fyStart + 1), -2); echo "Fiscal Year: {$fyLabel} BS"; // e.g. "2081/82 BS" ``` --- ## Related * [`date->getCurrentFiscalYearQuarter()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter): Get the active fiscal trimester number. * [`date->getCurrentFiscalYearQuarterDates()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter-dates): Get boundary dates of the active fiscal quarter. --- ## Page: date->getCurrentFiscalYearQuarter() (PHP) (/docs/php/fiscal-year/get-current-fiscal-year-quarter) Description: [PHP] Method to calculate the active fiscal trimester quarter number for a NepaliDate instance. Official API reference and code examples for PHP. The `getCurrentFiscalYearQuarter` method returns an integer from 1 to 4 representing the active fiscal trimester of the current date. Because Nepal fiscal calendar starts in Shrawan, quarter 1 covers Shrawan through Ashwin, quarter 2 spans Kartik through Poush, quarter 3 covers Magh through Chaitra, and quarter 4 spans Baisakh through Ashadh. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getCurrentFiscalYearQuarter(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1` to `4` * **Description**: The fiscal trimester index for the date. --- ## Trimester Mapping Table | Month Index | Month Name | Fiscal Quarter | Trimester Label | | :---: | :--- | :---: | :--- | | `3` | Shrawan | `1` | First Trimester (Q1) | | `4` | Bhadra | `1` | First Trimester (Q1) | | `5` | Aswin | `1` | First Trimester (Q1) | | `6` | Kartik | `2` | Second Trimester (Q2) | | `7` | Mangsir | `2` | Second Trimester (Q2) | | `8` | Poush | `2` | Second Trimester (Q2) | | `9` | Magh | `3` | Third Trimester (Q3) | | `10` | Falgun | `3` | Third Trimester (Q3) | | `11` | Chaitra | `3` | Third Trimester (Q3) | | `0` | Baisakh | `4` | Fourth Trimester (Q4) | | `1` | Jestha | `4` | Fourth Trimester (Q4) | | `2` | Asar | `4` | Fourth Trimester (Q4) | --- ## Examples ```php use NepaliDateLibrary\NepaliDate; $date1 = new NepaliDate('2081-04-15'); // Shrawan echo $date1->getCurrentFiscalYearQuarter(); // 1 $date2 = new NepaliDate('2081-07-20'); // Kartik echo $date2->getCurrentFiscalYearQuarter(); // 2 $date3 = new NepaliDate('2081-10-10'); // Magh echo $date3->getCurrentFiscalYearQuarter(); // 3 $date4 = new NepaliDate('2082-01-05'); // Baisakh echo $date4->getCurrentFiscalYearQuarter(); // 4 ``` --- ## Related * [`date->getCurrentFiscalYearQuarterDates()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter-dates): Retrieve boundary start and end dates. * [`date->getCurrentQuarter()`](/docs/php/methods/get-current-quarter): Standard Bikram Sambat calendar quarter. --- ## Page: date->getCurrentFiscalYearQuarterDates() (PHP) (/docs/php/fiscal-year/get-current-fiscal-year-quarter-dates) Description: [PHP] Method to retrieve exact start and end boundary dates for the active fiscal quarter. Official API reference and code examples for PHP. The `getCurrentFiscalYearQuarterDates` method computes the exact starting date and ending date for the fiscal quarter containing the current date instance. It returns an object containing boundary dates as new NepaliDate objects, which is helpful for quarterly financial reporting, audit periods, and tax filing windows. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getCurrentFiscalYearQuarterDates(): array; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `array{start: NepaliDate, end: NepaliDate}` * **Structure**: * `'start'`: `NepaliDate` object positioned on the first day of the fiscal quarter at midnight. * `'end'`: `NepaliDate` object positioned on the final day of the fiscal quarter. --- ## Examples ### Generating Quarterly Accounting Windows ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-05-15'); // Bhadra (Q1) $quarterInfo = $date->getCurrentFiscalYearQuarterDates(); $startDate = $quarterInfo['start']; $endDate = $quarterInfo['end']; echo "Q1 starts: " . $startDate->format('YYYY-MM-DD') . PHP_EOL; // "2081-04-01" (1 Shrawan) echo "Q1 ends: " . $endDate->format('YYYY-MM-DD') . PHP_EOL; // "2081-06-30" (End of Aswin) ``` --- ## Related * [`NepaliDate::getFiscalYearQuarter()`](/docs/php/fiscal-year/get-fiscal-year-quarter): Look up boundaries for any quarter. * [`date->getCurrentFiscalYearQuarter()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter): Retrieve active quarter index. --- ## Page: NepaliDate::getFiscalYearQuarter() (PHP) (/docs/php/fiscal-year/get-fiscal-year-quarter) Description: [PHP] Static method to determine the fiscal trimester number for any specified month index. Official API reference and code examples for PHP. The static `getFiscalYearQuarter` method determines the fiscal trimester number corresponding to a given Bikram Sambat month index from 0 to 11. It allows quick lookups without needing to instantiate a full NepaliDate object, making it useful in financial aggregation pipelines and reporting utilities. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function getFiscalYearQuarter(int $quarter, ?int $fiscalYear = null): array; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$quarter` | `int` | Yes | Trimester index from `1` to `4`. | | `$fiscalYear` | `int`, `null` | No | Starting Bikram Sambat year of the fiscal period. Defaults to current fiscal year. | --- ## Return Value * **Type**: `array{start: NepaliDate, end: NepaliDate}` * **Structure**: Array with `'start'` and `'end'` keys holding boundary `NepaliDate` instances. --- ## Examples ```php use NepaliDateLibrary\NepaliDate; // Get boundaries for Q2 of fiscal year 2081/82 BS $q2Dates = NepaliDate::getFiscalYearQuarter(2, 2081); echo "Start: " . $q2Dates['start']->format('YYYY-MM-DD') . PHP_EOL; // 1 Kartik echo "End: " . $q2Dates['end']->format('YYYY-MM-DD') . PHP_EOL; // Last day of Poush ``` --- ## Related * [`NepaliDate::getFiscalYearQuarters()`](/docs/php/fiscal-year/get-fiscal-year-quarters): Retrieve all four quarters for a fiscal year. * [`date->getCurrentFiscalYearQuarterDates()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter-dates): Instance method for current date. --- ## Page: NepaliDate::getFiscalYearQuarters() (PHP) (/docs/php/fiscal-year/get-fiscal-year-quarters) Description: [PHP] Static utility returning all four fiscal trimesters with their constituent months and date ranges for a given year. Official API reference and code examples for PHP. The static `getFiscalYearQuarters` method returns a complete structural breakdown of all four fiscal trimesters for a specified Bikram Sambat year. Each quarter entry includes its trimester index, English and Nepali month names, and corresponding calendar boundary information. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function getFiscalYearQuarters(?int $fiscalYear = null): array; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$fiscalYear` | `int`, `null` | No | Four digit starting Bikram Sambat year. Defaults to current fiscal year. | --- ## Return Value * **Type**: `array` * **Structure**: An associative array with keys `'Q1'`, `'Q2'`, `'Q3'`, and `'Q4'`, each containing `'start'` and `'end'` `NepaliDate` objects. --- ## Examples ```php use NepaliDateLibrary\NepaliDate; $quarters = NepaliDate::getFiscalYearQuarters(2081); foreach ($quarters as $qName => $boundaries) { $startStr = $boundaries['start']->format('YYYY-MM-DD'); $endStr = $boundaries['end']->format('YYYY-MM-DD'); echo "{$qName}: {$startStr} to {$endStr}" . PHP_EOL; } ``` --- ## Related * [`NepaliDate::getFiscalYearQuarter()`](/docs/php/fiscal-year/get-fiscal-year-quarter): Query a single trimester boundary. * [`date->getCurrentFiscalYearQuarterDates()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter-dates): Active quarter boundaries for an instance. --- ## Page: Installation & Setup (PHP) (/docs/php/installation) Description: [PHP] Installation and setup instructions for nepali date library in PHP applications using Composer. Official API reference and code examples for PHP. The nepali date library is distributed as a standard Composer package on Packagist with zero external dependencies. It works seamlessly across modern PHP versions and integrates directly with Laravel, Symfony, WordPress, and standalone PHP projects. --- ## Package Installation ```bash composer require sghimire/nepali-date-library ``` --- ## Composer Configuration Add the package dependency to your `composer.json` file manually if preferred: ```json { "require": { "sghimire/nepali-date-library": "^1.0" } } ``` Then run `composer update` or `composer install` to download the package. --- ## Autoloading Include the Composer generated autoload script at the entry point of your PHP script: ```php format('YYYY-MM-DD'); ``` --- ## Next Steps * [Quick Start Guide](/docs/php/quick-start): Learn core workflows and common patterns. * [NepaliDate Class Reference](/docs/php/class/constructor): Explore constructor signatures and instance creation. --- ## Page: date->addDays() (PHP) (/docs/php/methods/add-days) Description: [PHP] Add or subtract a specified number of days to a NepaliDate instance with automatic month and year rollover. Official API reference and code examples for PHP. The `addDays` method modifies the current `NepaliDate` instance by adding or subtracting a given integer number of days. It automatically handles variable Bikram Sambat month day counts, transitions across month boundaries, and advances or decrements the year when needed. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function addDays(int $days): self; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$days` | `int` | Yes | Positive or negative number of days to add. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: Returns `$this` after mutating internal coordinates. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-25'); $date->addDays(10); echo $date->format('YYYY-MM-DD'); // Transitions into Jestha ``` --- ## Related * [`date->addMonths()`](/docs/php/methods/add-months): Add or subtract months. * [`date->diff()`](/docs/php/methods/diff): Calculate day differences. --- ## Page: date->addMonths() (PHP) (/docs/php/methods/add-months) Description: [PHP] Add or subtract months to a NepaliDate instance while adjusting for variable month lengths. Official API reference and code examples for PHP. The `addMonths` method advances or rewinds the current `NepaliDate` instance by a specified number of months. If the current day of the month exceeds the total days available in the destination month, the method automatically clamps the day to the final valid day of that month to ensure calendar consistency. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function addMonths(int $months): self; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$months` | `int` | Yes | Positive or negative integer of months to add. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: Returns `$this` after mutation. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-15'); $date->addMonths(6); echo $date->format('YYYY-MM-DD'); // "2081-07-15" ``` --- ## Related * [`date->addYears()`](/docs/php/methods/add-years): Add or subtract years. * [`date->addDays()`](/docs/php/methods/add-days): Add or subtract days. --- ## Page: date->addYears() (PHP) (/docs/php/methods/add-years) Description: [PHP] Add or subtract years to a NepaliDate instance while preserving month and day values. Official API reference and code examples for PHP. The `addYears` method adds or subtracts a specified number of years to the current `NepaliDate` instance. It recalculates the underlying timestamp while retaining the month and day coordinates, adjusting the day number if the target year has fewer days in that specific month. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function addYears(int $years): self; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$years` | `int` | Yes | Number of years to advance or rewind. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: Returns `$this` after mutation. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2075-01-01'); $date->addYears(5); echo $date->format('YYYY-MM-DD'); // "2080-01-01" ``` --- ## Related * [`date->addMonths()`](/docs/php/methods/add-months): Add or subtract months. * [`date->diff()`](/docs/php/methods/diff): Difference between two dates. --- ## Page: date->clone() (PHP) (/docs/php/methods/clone) Description: [PHP] Create an independent deep clone of an existing NepaliDate instance. Official API reference and code examples for PHP. The `clone` method creates and returns an independent duplicate of the current `NepaliDate` instance. Because several library arithmetic and mutation methods alter instances in place, creating a clone allows you to perform calculations without modifying the original date object. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function clone(): self; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: A new independent `NepaliDate` instance with identical coordinates and timestamp. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $original = new NepaliDate('2081-07-15'); $duplicate = $original->clone(); // Mutating duplicate does not affect original $duplicate->addDays(10); echo $original->format('YYYY-MM-DD') . PHP_EOL; // "2081-07-15" echo $duplicate->format('YYYY-MM-DD') . PHP_EOL; // "2081-07-25" ``` --- ## Related * [`NepaliDate Constructor`](/docs/php/class/constructor): Copy constructor support. * [`date->addDays()`](/docs/php/methods/add-days): In-place day arithmetic. --- ## Page: date->daysInMonth() (PHP) (/docs/php/methods/days-in-month) Description: [PHP] Retrieve the total number of days in the current or specified Bikram Sambat month. Official API reference and code examples for PHP. The `daysInMonth` method returns the total number of days present in the active month of the current `NepaliDate` instance, or for an explicitly provided year and month combination. Because Bikram Sambat month durations vary from 29 to 32 days depending on astronomical solar calculations, this method provides accurate month lengths. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function daysInMonth(?int $year = null, ?int $month = null): int; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `$year` | `int`, `null` | No | `null` | Optional year to inspect. Defaults to current instance year. | | `$month` | `int`, `null` | No | `null` | Optional zero based month index. Defaults to current instance month. | --- ## Return Value * **Type**: `int` * **Range**: `29` to `32` * **Description**: Total number of days in the active month. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-01'); // Baisakh 2081 echo "Days in Baisakh 2081: " . $date->daysInMonth(); // 31 ``` --- ## Related * [`date->getWeeksInMonth()`](/docs/php/methods/get-weeks-in-month): Calendar rows for month. * [`NepaliDate::getCalendarDays()`](/docs/php/static/get-calendar-days): Generate calendar matrix. --- ## Page: date->diff() (PHP) (/docs/php/methods/diff) Description: [PHP] Calculate the chronological difference between two NepaliDate instances in specific time units. Official API reference and code examples for PHP. The `diff` method calculates the elapsed time duration between the current `NepaliDate` instance and another date object. It can return the difference in days, months, years, hours, minutes, seconds, or milliseconds, making it suitable for calculating age, tenure, or interval durations. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function diff(NepaliDate $date, string $unit): int; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$date` | `NepaliDate` | Yes | Target date instance to compare against. | | `$unit` | `string` | Yes | Measurement unit: `'days'`, `'months'`, `'years'`, `'hours'`, `'minutes'`, `'seconds'`. | --- ## Return Value * **Type**: `int` * **Description**: Integer difference count in the specified unit. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $d1 = new NepaliDate('2081-01-01'); $d2 = new NepaliDate('2081-01-20'); $daysDiff = $d2->diff($d1, 'days'); echo "Difference in days: {$daysDiff}"; // 19 ``` --- ## Related * [`date->isBefore()`](/docs/php/methods/is-before): Check chronological order. * [`date->isAfter()`](/docs/php/methods/is-after): Check chronological order. --- ## Page: date->endOfDay() (PHP) (/docs/php/methods/end-of-day) Description: [PHP] Return a new NepaliDate instance set to the final millisecond of the current day. Official API reference and code examples for PHP. The `endOfDay` method returns a new `NepaliDate` instance with time coordinates set to the final moment of the day at 23 hours, 59 minutes, 59 seconds, and 999 milliseconds. This is commonly used when setting upper boundaries for database queries, event schedules, and daily audit filters. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function endOfDay(): self; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to 23:59:59.999 UTC. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); $dayEnd = $date->endOfDay(); echo $dayEnd->getHours() . PHP_EOL; // 23 echo $dayEnd->getMinutes() . PHP_EOL; // 59 ``` --- ## Related * [`date->startOfDay()`](/docs/php/methods/start-of-day): Set time to midnight. * [`date->endOfMonth()`](/docs/php/methods/end-of-month): Final day of the month. --- ## Page: date->endOfMonth() (PHP) (/docs/php/methods/end-of-month) Description: [PHP] Return a new NepaliDate instance set to the final day of the current Bikram Sambat month. Official API reference and code examples for PHP. The `endOfMonth` method returns a new `NepaliDate` instance positioned on the last valid calendar day of the active month. It automatically checks the calendar map to determine whether the month ends on day 29, 30, 31, or 32, which is useful for monthly reporting and billing cycles. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function endOfMonth(): self; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance on the final day of the current month. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-10'); $lastDay = $date->endOfMonth(); echo $lastDay->format('YYYY-MM-DD'); // Day 31 for Baisakh 2081 ``` --- ## Related * [`date->startOfMonth()`](/docs/php/methods/start-of-month): First day of the month. * [`date->daysInMonth()`](/docs/php/methods/days-in-month): Total days in the month. --- ## Page: date->endOfWeek() (PHP) (/docs/php/methods/end-of-week) Description: [PHP] Return a new NepaliDate instance set to the final day of the current week on Saturday. Official API reference and code examples for PHP. The `endOfWeek` method produces a new `NepaliDate` instance representing the last day of the week containing the current date. In standard Nepali calendar practice, Saturday is regarded as the final day of the weekly cycle. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function endOfWeek(int $startOfWeek = 0): self; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `$startOfWeek` | `int` | No | `0` | Weekday index treated as week start. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to Saturday (index 6). --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); $weekEnd = $date->endOfWeek(); echo $weekEnd->getDay(); // 6 (Saturday) ``` --- ## Related * [`date->startOfWeek()`](/docs/php/methods/start-of-week): First day of the week. * [`date->endOfMonth()`](/docs/php/methods/end-of-month): Final day of the month. --- ## Page: date->endOfYear() (PHP) (/docs/php/methods/end-of-year) Description: [PHP] Return a new NepaliDate instance set to the final day of the Bikram Sambat year on the last day of Chaitra. Official API reference and code examples for PHP. The `endOfYear` method returns a new `NepaliDate` instance set to the closing day of the current Bikram Sambat calendar year. This corresponds to the final day of Chaitra, which is commonly needed for annual reconciliations and fiscal year preparations. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function endOfYear(): self; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance on the final day of Chaitra. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); $yearEnd = $date->endOfYear(); echo $yearEnd->format('YYYY-MM-DD'); ``` --- ## Related * [`date->startOfYear()`](/docs/php/methods/start-of-year): First day of the year. * [`date->isLeapYear()`](/docs/php/methods/is-leap-year): Total year day check. --- ## Page: date->format() (PHP) (/docs/php/methods/format) Description: [PHP] Format a NepaliDate instance into a custom string using token patterns for English and Nepali output. Official API reference and code examples for PHP. The `format` method transforms a `NepaliDate` instance into a formatted string according to a pattern of token specifiers. It supports tokens for year, month, day, weekday, hours, minutes, and seconds, with full support for localized English names as well as Devanagari script numerals and words. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function format(string $formatStr): string; ``` --- ## Common Format Tokens | Token | Output Format | Example | | :--- | :--- | :--- | | `YYYY` | Four digit year | `2081` | | `YY` | Two digit year | `81` | | `MMMM` | Full month name | `Kartik` | | `MMM` | Short month name | `Kar` | | `MM` | Two digit month number | `07` | | `M` | One or two digit month number | `7` | | `DD` | Two digit day of month | `15` | | `D` | One or two digit day of month | `15` | | `dddd` | Full weekday name | `Friday` | | `ddd` | Short weekday name | `Fri` | | `HH` | Two digit 24-hour time | `14` | | `mm` | Two digit minute | `30` | | `ss` | Two digit second | `45` | | `NYYY` | Devanagari numerals year | `२०८१` | | `NMMM` | Full Devanagari month name | `कार्तिक` | | `NDD` | Devanagari numerals day | `१५` | | `NDDD` | Full Devanagari weekday name | `शुक्रबार` | --- ## Examples ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); // Standard ISO format echo $date->format('YYYY-MM-DD'); // "2081-07-15" // Long English date echo $date->format('dddd, MMMM DD, YYYY'); // "Friday, Kartik 15, 2081" // Devanagari format echo $date->format('NDDD, NMMM NDD, NYYY'); // "शुक्रबार, कार्तिक १५, २०८१" ``` --- ## Related * [`date->clone()`](/docs/php/methods/clone): Duplicate a date instance. * [`NepaliDate::getMonthName()`](/docs/php/static/get-month-name): Static month name helper. --- ## Page: date->getCurrentQuarter() (PHP) (/docs/php/methods/get-current-quarter) Description: [PHP] Return the standard Bikram Sambat calendar quarter number from one to four for the current date. Official API reference and code examples for PHP. The `getCurrentQuarter` method returns an integer from 1 to 4 designating the standard calendar quarter containing the current date. Calendar quarters divide the Bikram Sambat year into four sequential segments starting from 1 Baisakh, which differs from government fiscal trimesters that commence in Shrawan. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getCurrentQuarter(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1` to `4` * **Description**: Standard calendar quarter number. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-15'); // Baisakh echo $date->getCurrentQuarter(); // 1 $date2 = new NepaliDate('2081-07-15'); // Kartik echo $date2->getCurrentQuarter(); // 3 ``` --- ## Related * [`date->getCurrentFiscalYearQuarter()`](/docs/php/fiscal-year/get-current-fiscal-year-quarter): Official fiscal trimester number. * [`Calendar Quarters Guide`](/docs/php/fiscal-year/calendar-quarters): Comparison guide. --- ## Page: date->getDate() (PHP) (/docs/php/methods/get-date) Description: [PHP] Retrieve the numeric day of the month from a NepaliDate instance. Official API reference and code examples for PHP. The `getDate` method returns the day of the month as an integer from 1 to 32 for the current `NepaliDate` instance. Unlike Gregorian months which have at most 31 days, Bikram Sambat calendar months can extend up to 32 days depending on the year and month. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getDate(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1` to `32` * **Description**: Day of the month integer. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); echo $date->getDate(); // 15 ``` --- ## Related * [`date->setDate()`](/docs/php/methods/set-date): Mutate the day of the month. * [`date->getDay()`](/docs/php/methods/get-day): Retrieve the day of the week. --- ## Page: date->getDay() (PHP) (/docs/php/methods/get-day) Description: [PHP] Retrieve the numeric day of the week index from zero for Sunday through six for Saturday. Official API reference and code examples for PHP. The `getDay` method returns an integer representing the day of the week for the current `NepaliDate` instance. The return value ranges from 0 for Sunday to 6 for Saturday, aligning with standard calendar day conventions. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getDay(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `6` * **Description**: Day of the week integer starting from `0` for Sunday up to `6` for Saturday. --- ## Example ```php use NepaliDateLibrary\NepaliDate; use NepaliDateLibrary\Helper\Constants; $date = new NepaliDate('2081-07-15'); $weekdayIndex = $date->getDay(); echo $weekdayIndex . PHP_EOL; // 5 (Friday) echo Constants::$WEEK_EN[$weekdayIndex]; // "Friday" ``` --- ## Related * [`NepaliDate::getDayName()`](/docs/php/static/get-day-name): Retrieve localized weekday names. * [`date->getDate()`](/docs/php/methods/get-date): Retrieve the day of the month. --- ## Page: date->getEnglishDate() (PHP) (/docs/php/methods/get-english-date) Description: [PHP] Retrieve the equivalent Gregorian date as a native JavaScript Date object. Official API reference and code examples for PHP. The `getEnglishDate` method returns the native PHP DateTimeImmutable object corresponding to the current `NepaliDate` instance. This allows seamless integration with third party libraries, databases, and standard PHP APIs that expect a native Gregorian datetime object. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getEnglishDate(): DateTimeImmutable; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `DateTimeImmutable` * **Description**: Native PHP DateTimeImmutable object in UTC matching the current Bikram Sambat date. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $nd = new NepaliDate('2081-07-15'); $adDate = $nd->getEnglishDate(); echo get_class($adDate) . PHP_EOL; // "DateTimeImmutable" echo $adDate->format('Y-m-d'); // "2024-10-31" ``` --- ## Related * [`BStoAD()`](/docs/php/date-converter/bs-to-ad): String based date conversion. * [`NepaliDate Constructor`](/docs/php/class/constructor): Construct from DateTimeInterface. --- ## Page: date->getHours() (PHP) (/docs/php/methods/get-hours) Description: [PHP] Retrieve the hour component from zero to twenty three for the current date instance. Official API reference and code examples for PHP. The `getHours` method returns the hour of the day as an integer between 0 and 23 for the current `NepaliDate` instance. It reflects local time coordinates stored within the instance timestamp. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getHours(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `23` * **Description**: Hour integer representing time of day. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $now = new NepaliDate(); echo "Current hour: " . $now->getHours(); ``` --- ## Related * [`date->getMinutes()`](/docs/php/methods/get-minutes): Retrieve the minute component. * [`date->getSeconds()`](/docs/php/methods/get-seconds): Retrieve the second component. --- ## Page: date->getMilliseconds() (PHP) (/docs/php/methods/get-milliseconds) Description: [PHP] Retrieve the millisecond component from zero to nine hundred ninety nine. Official API reference and code examples for PHP. The `getMilliseconds` method returns the millisecond fraction of the current second as an integer from 0 to 999. It provides high resolution timing details for precision logging and event timestamping. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getMilliseconds(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `999` * **Description**: Millisecond integer between 0 and 999. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $now = new NepaliDate(); echo "Milliseconds: " . $now->getMilliseconds(); ``` --- ## Related * [`date->getTime()`](/docs/php/methods/get-time): Retrieve epoch timestamp in milliseconds. * [`date->getSeconds()`](/docs/php/methods/get-seconds): Retrieve second component. --- ## Page: date->getMinutes() (PHP) (/docs/php/methods/get-minutes) Description: [PHP] Retrieve the minute component from zero to fifty nine for the current date instance. Official API reference and code examples for PHP. The `getMinutes` method returns the minute value as an integer from 0 to 59 for the current `NepaliDate` instance. It is derived from the underlying timestamp representing the recorded time of the date object. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getMinutes(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `59` * **Description**: Minute integer between 0 and 59. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $now = new NepaliDate(); echo "Current minute: " . $now->getMinutes(); ``` --- ## Related * [`date->getHours()`](/docs/php/methods/get-hours): Retrieve the hour component. * [`date->getSeconds()`](/docs/php/methods/get-seconds): Retrieve the second component. --- ## Page: date->getMonth() (PHP) (/docs/php/methods/get-month) Description: [PHP] Retrieve the zero based Bikram Sambat month index from zero for Baisakh to eleven for Chaitra. Official API reference and code examples for PHP. The `getMonth` method returns the month of the year as an integer between 0 and 11 for the current `NepaliDate` instance. The library adheres to the zero based indexing standard where 0 represents Baisakh, 1 represents Jestha, and 11 represents Chaitra. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getMonth(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `11` * **Description**: Zero based month index from Baisakh (`0`) to Chaitra (`11`). --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); // Kartik echo $date->getMonth(); // 6 (Kartik is index 6) ``` --- ## Related * [`date->setMonth()`](/docs/php/methods/set-month): Mutate the month component. * [`NepaliDate::getMonthName()`](/docs/php/static/get-month-name): Look up the month name. --- ## Page: date->getSeconds() (PHP) (/docs/php/methods/get-seconds) Description: [PHP] Retrieve the second component from zero to fifty nine for the current date instance. Official API reference and code examples for PHP. The `getSeconds` method returns the second value as an integer from 0 to 59 for the current `NepaliDate` instance. It enables precise second level timing and formatting. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getSeconds(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `59` * **Description**: Second integer between 0 and 59. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $now = new NepaliDate(); echo "Current second: " . $now->getSeconds(); ``` --- ## Related * [`date->getMinutes()`](/docs/php/methods/get-minutes): Retrieve the minute component. * [`date->getMilliseconds()`](/docs/php/methods/get-milliseconds): Retrieve milliseconds. --- ## Page: date->getTime() (PHP) (/docs/php/methods/get-time) Description: [PHP] Retrieve the numeric timestamp in milliseconds since the Unix epoch. Official API reference and code examples for PHP. The `getTime` method returns the number of milliseconds elapsed since the Unix epoch of January 1, 1970 UTC. This integer value matches the return value of standard epoch timestamps and allows direct numerical comparison between date instances. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getTime(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Description**: Milliseconds elapsed since January 1, 1970 00:00:00 UTC. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $d1 = new NepaliDate('2081-01-01'); $d2 = new NepaliDate('2081-01-02'); var_dump($d1->getTime() < $d2->getTime()); // true ``` --- ## Related * [`date->getEnglishDate()`](/docs/php/methods/get-english-date): Retrieve PHP DateTimeImmutable object. * [`date->diff()`](/docs/php/methods/diff): Calculate duration differences. --- ## Page: date->getWeeksInMonth() (PHP) (/docs/php/methods/get-weeks-in-month) Description: [PHP] Calculate the number of calendar week rows required to render the current month in a grid. Official API reference and code examples for PHP. The `getWeeksInMonth` method computes the total number of seven day week rows required to display the entire month in a standard calendar grid. Depending on which weekday the month starts on and how many days it contains, the returned count is usually five or six rows. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getWeeksInMonth(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `4`, `5`, or `6` * **Description**: Number of week rows needed for a calendar view. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-01'); echo "Weeks in month: " . $date->getWeeksInMonth(); ``` --- ## Related * [`NepaliDate::getCalendarDays()`](/docs/php/static/get-calendar-days): Matrix grid builder. * [`date->daysInMonth()`](/docs/php/methods/days-in-month): Total days in month. --- ## Page: date->getYear() (PHP) (/docs/php/methods/get-year) Description: [PHP] Retrieve the four digit Bikram Sambat year number from a NepaliDate instance. Official API reference and code examples for PHP. The `getYear` method returns the full four digit Bikram Sambat year as an integer for the current `NepaliDate` instance. It returns the complete calendar year such as 2081 within the supported range of 1976 through 2100 BS. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function getYear(): int; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1976` to `2100` * **Description**: Four digit Bikram Sambat year integer. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); echo $date->getYear(); // 2081 ``` --- ## Related * [`date->setYear()`](/docs/php/methods/set-year): Mutate the year component. * [`date->getMonth()`](/docs/php/methods/get-month): Retrieve the month component. --- ## Page: date->isAfter() (PHP) (/docs/php/methods/is-after) Description: [PHP] Check whether the current date occurs chronologically after another specified date. Official API reference and code examples for PHP. The `isAfter` method evaluates whether the current `NepaliDate` instance occurs chronologically later than another date or timestamp. It compares exact millisecond values to determine chronological order accurately. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function isAfter(NepaliDate $date): bool; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$date` | `NepaliDate` | Yes | Target date to compare against. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `true` if current date is chronologically later than `$date`. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $d1 = new NepaliDate('2081-01-15'); $d2 = new NepaliDate('2081-01-01'); var_dump($d1->isAfter($d2)); // true ``` --- ## Related * [`date->isBefore()`](/docs/php/methods/is-before): Check if earlier in time. * [`date->isEqual()`](/docs/php/methods/is-equal): Check calendar date equality. --- ## Page: date->isBefore() (PHP) (/docs/php/methods/is-before) Description: [PHP] Check whether the current date occurs chronologically before another specified date. Official API reference and code examples for PHP. The `isBefore` method evaluates whether the current `NepaliDate` instance occurs earlier in time than another provided date. It takes into account both date and time components down to millisecond accuracy. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function isBefore(NepaliDate $date): bool; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$date` | `NepaliDate` | Yes | Target date to compare against. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `true` if current date is chronologically earlier than `$date`. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $d1 = new NepaliDate('2081-01-01'); $d2 = new NepaliDate('2081-01-15'); var_dump($d1->isBefore($d2)); // true var_dump($d2->isBefore($d1)); // false ``` --- ## Related * [`date->isAfter()`](/docs/php/methods/is-after): Check if later in time. * [`date->isEqual()`](/docs/php/methods/is-equal): Check calendar date equality. --- ## Page: date->isEqual() (PHP) (/docs/php/methods/is-equal) Description: [PHP] Check whether two date instances share the exact same calendar date coordinates regardless of time. Official API reference and code examples for PHP. The `isEqual` method checks whether the current `NepaliDate` instance shares the exact same Bikram Sambat year, month, and day coordinates as another date object, ignoring any differences in hours, minutes, seconds, or milliseconds. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function isEqual(NepaliDate $date): bool; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$date` | `NepaliDate` | Yes | Date instance to compare coordinates with. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `true` if year, month, and day are identical. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $d1 = new NepaliDate('2081-07-15'); $d2 = new NepaliDate('2081-07-15'); var_dump($d1->isEqual($d2)); // true ``` --- ## Related * [`date->isSame()`](/docs/php/methods/is-same): Compare with custom granularity. * [`date->isBefore()`](/docs/php/methods/is-before): Check chronological order. --- ## Page: date->isLeapYear() (PHP) (/docs/php/methods/is-leap-year) Description: [PHP] Determine whether the current Bikram Sambat calendar year has three hundred sixty six or more days. Official API reference and code examples for PHP. The `isLeapYear` method checks whether the active Bikram Sambat year contains 366 or more days based on official solar calendar tables. Because Bikram Sambat year lengths depend on astronomical calculations rather than fixed leap year cycles, this method checks the actual cumulative day count for the year. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function isLeapYear(): bool; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `bool` * **Description**: Returns `true` if the year has 366 or more days. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-01'); var_dump($date->isLeapYear()); ``` --- ## Related * [`date->daysInMonth()`](/docs/php/methods/days-in-month): Total days in a month. * [`Constants::$NEPALI_DATE_MAP`](/docs/php/constants/nepali-date-map): Calendar mapping table. --- ## Page: date->isSame() (PHP) (/docs/php/methods/is-same) Description: [PHP] Check whether two dates match across a specified granularity such as year, month, or day. Official API reference and code examples for PHP. The `isSame` method compares the current `NepaliDate` instance with another date at a specified level of granularity, such as year, month, day, hour, or minute. It returns true if both dates match within that specific unit, simplifying range checks and calendar filters. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function isSame(NepaliDate $date, string $unit): bool; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$date` | `NepaliDate` | Yes | Date instance to compare with. | | `$unit` | `string` | Yes | Granularity: `'year'`, `'month'`, `'date'`, `'day'`. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `true` if the specified unit matches. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $d1 = new NepaliDate('2081-07-05'); $d2 = new NepaliDate('2081-07-20'); // Same month and year var_dump($d1->isSame($d2, 'month')); // true // Different day var_dump($d1->isSame($d2, 'date')); // false ``` --- ## Related * [`date->isEqual()`](/docs/php/methods/is-equal): Compare full date equality. * [`date->diff()`](/docs/php/methods/diff): Quantitative difference. --- ## Page: date->isValidInstance() (PHP) (/docs/php/methods/is-valid) Description: [PHP] Validate whether the current NepaliDate instance represents a legitimate calendar date within supported bounds. Official API reference and code examples for PHP. The `isValidInstance` method checks whether the current `NepaliDate` instance contains valid calendar values and falls within the supported range of 1976 through 2100 BS. It verifies that year, month, and day coordinates correspond to an authentic historical date. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function isValidInstance(): bool; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `bool` * **Description**: Returns `true` if the date is valid. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); var_dump($date->isValidInstance()); // true ``` --- ## Related * [`NepaliDate::isValid()`](/docs/php/static/is-valid): Static validation method. * [`NepaliDate::minimum()`](/docs/php/static/minimum): Earliest supported date. --- ## Page: date->parse() (PHP) (/docs/php/methods/parse) Description: [PHP] Parse a formatted Bikram Sambat date string and update the current date instance in place. Official API reference and code examples for PHP. The `parse` method parses a Bikram Sambat date string and updates the coordinates of the current `NepaliDate` instance in place. It supports various delimiter styles including slashes, dots, and hyphens, recalculating the underlying timestamp upon successful parsing. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function parse(string $dateString): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$dateString` | `string` | Yes | Formatted Bikram Sambat date string (e.g. `'2081-07-15'`). | --- ## Return Value * **Type**: `void` * **Note**: Mutates the current instance in place. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate(); $date->parse('2081-07-15'); echo $date->format('YYYY-MM-DD'); // "2081-07-15" ``` --- ## Related * [`NepaliDate Constructor`](/docs/php/class/constructor): Create instances from strings. * [`date->format()`](/docs/php/methods/format): Format dates to strings. --- ## Page: date->set() (PHP) (/docs/php/methods/set) Description: [PHP] Set year, month, and day coordinates simultaneously on a NepaliDate instance. Official API reference and code examples for PHP. The `set` method updates the Bikram Sambat year, zero based month index, and day values of the current `NepaliDate` instance in a single atomic call. It validates the combined coordinates against the calendar map and recalculates the internal timestamp. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function set(int $year, int $month, int $date): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$year` | `int` | Yes | Bikram Sambat year integer between 1976 and 2100. | | `$month` | `int` | Yes | Zero based month index from 0 (Baisakh) to 11 (Chaitra). | | `$date` | `int` | Yes | Day number of the month from 1 to 32. | --- ## Return Value * **Type**: `void` * **Note**: Mutates the current `NepaliDate` instance in place. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2080-01-01'); $date->set(2081, 6, 15); // Kartik 15, 2081 BS echo $date->format('YYYY-MM-DD'); // "2081-07-15" ``` --- ## Related * [`date->setYear()`](/docs/php/methods/set-year): Mutate year only. * [`date->setMonth()`](/docs/php/methods/set-month): Mutate month only. --- ## Page: date->setDate() (PHP) (/docs/php/methods/set-date) Description: [PHP] Set the day of the month on a NepaliDate instance and recalculate its timestamp. Official API reference and code examples for PHP. The `setDate` method updates the day of the month for the current `NepaliDate` instance and recalculates its underlying Gregorian timestamp. It validates the new day against the maximum number of days available in the active month. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function setDate(int $day): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$day` | `int` | Yes | Target day of the month between `1` and `32`. | --- ## Return Value * **Type**: `void` * **Note**: Mutates the current instance in place. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-01'); $date->setDate(15); echo $date->format('YYYY-MM-DD'); // "2081-07-15" ``` --- ## Related * [`date->getDate()`](/docs/php/methods/get-date): Retrieve day of the month. * [`date->addDays()`](/docs/php/methods/add-days): Add or subtract days. --- ## Page: date->setMonth() (PHP) (/docs/php/methods/set-month) Description: [PHP] Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping. Official API reference and code examples for PHP. The `setMonth` method updates the Bikram Sambat month for the current `NepaliDate` instance using a zero based month index from 0 for Baisakh to 11 for Chaitra. If the current day exceeds the total days in the destination month, the day is automatically clamped to the final valid day of that month. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function setMonth(int $month): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$month` | `int` | Yes | Target zero based month index from `0` to `11`. | --- ## Return Value * **Type**: `void` * **Note**: Mutates the current instance in place. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-01-31'); // Change to month index 1 (Jestha) $date->setMonth(1); echo $date->format('YYYY-MM-DD'); ``` --- ## Related * [`date->getMonth()`](/docs/php/methods/get-month): Retrieve month index. * [`date->addMonths()`](/docs/php/methods/add-months): Add or subtract months. --- ## Page: date->setYear() (PHP) (/docs/php/methods/set-year) Description: [PHP] Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range. Official API reference and code examples for PHP. The `setYear` method updates the four digit Bikram Sambat year on the current `NepaliDate` instance and adjusts the timestamp accordingly. The target year must fall within the supported range between 1976 and 2100 BS. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function setYear(int $year): void; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$year` | `int` | Yes | Target Bikram Sambat year between 1976 and 2100. | --- ## Return Value * **Type**: `void` * **Note**: Mutates the current instance in place. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2080-07-15'); $date->setYear(2081); echo $date->format('YYYY-MM-DD'); // "2081-07-15" ``` --- ## Related * [`date->getYear()`](/docs/php/methods/get-year): Retrieve current year. * [`date->addYears()`](/docs/php/methods/add-years): Add or subtract years. --- ## Page: date->startOfDay() (PHP) (/docs/php/methods/start-of-day) Description: [PHP] Return a new NepaliDate instance set to the first moment of the current day at midnight. Official API reference and code examples for PHP. The `startOfDay` method returns a new `NepaliDate` instance with time coordinates set to midnight at 00 hours, 00 minutes, 00 seconds, and 000 milliseconds. This is useful for date normalization and time neutral comparisons. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function startOfDay(): self; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to 00:00:00.000 UTC. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate(); $midnight = $date->startOfDay(); echo $midnight->getHours() . PHP_EOL; // 0 echo $midnight->getMinutes() . PHP_EOL; // 0 ``` --- ## Related * [`date->endOfDay()`](/docs/php/methods/end-of-day): Set time to final millisecond of the day. * [`date->startOfMonth()`](/docs/php/methods/start-of-month): Boundary for month start. --- ## Page: date->startOfMonth() (PHP) (/docs/php/methods/start-of-month) Description: [PHP] Return a new NepaliDate instance set to the first day of the current Bikram Sambat month. Official API reference and code examples for PHP. The `startOfMonth` method returns a new `NepaliDate` instance positioned on day 1 of the active Bikram Sambat month with time set to midnight. It is commonly used for monthly calendar views, statements, and aggregation buckets. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function startOfMonth(): self; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance on day 1 of the month. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); $firstDay = $date->startOfMonth(); echo $firstDay->format('YYYY-MM-DD'); // "2081-07-01" ``` --- ## Related * [`date->endOfMonth()`](/docs/php/methods/end-of-month): Final day of the month. * [`date->startOfYear()`](/docs/php/methods/start-of-year): First day of the year. --- ## Page: date->startOfWeek() (PHP) (/docs/php/methods/start-of-week) Description: [PHP] Return a new NepaliDate instance set to the first day of the week on Sunday. Official API reference and code examples for PHP. The `startOfWeek` method returns a new `NepaliDate` instance set to Sunday, the first day of the weekly cycle containing the current date. It serves as an anchor date for week based scheduling and calendar grids. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function startOfWeek(int $startOfWeek = 0): self; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `$startOfWeek` | `int` | No | `0` | Weekday index to treat as week start (0 for Sunday). | --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to the first day of the week. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); $weekStart = $date->startOfWeek(); echo $weekStart->getDay(); // 0 (Sunday) ``` --- ## Related * [`date->endOfWeek()`](/docs/php/methods/end-of-week): Saturday boundary of the week. * [`date->startOfMonth()`](/docs/php/methods/start-of-month): First day of the month. --- ## Page: date->startOfYear() (PHP) (/docs/php/methods/start-of-year) Description: [PHP] Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh. Official API reference and code examples for PHP. The `startOfYear` method returns a new `NepaliDate` instance set to 1 Baisakh, the first day of the Bikram Sambat calendar year. This is useful for year to date financial tracking and annual summary reports. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function startOfYear(): self; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance positioned on 1 Baisakh of the current year. --- ## Example ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); $yearStart = $date->startOfYear(); echo $yearStart->format('YYYY-MM-DD'); // "2081-01-01" ``` --- ## Related * [`date->endOfYear()`](/docs/php/methods/end-of-year): Final day of the year. * [`date->startOfMonth()`](/docs/php/methods/start-of-month): First day of the month. --- ## Page: date->toString() (PHP) (/docs/php/methods/to-string) Description: [PHP] Return the default string representation of a NepaliDate instance in standard year, month, and day format. Official API reference and code examples for PHP. The `toString` method converts the `NepaliDate` instance into a standard readable date string formatted as year, month, and day separated by forward slashes. It provides a simple default serialization format suitable for logs and quick display. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public function toString(): string; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `string` * **Format**: `YYYY/M/D` (e.g. `"2081/7/15"`). --- ## Examples ```php use NepaliDateLibrary\NepaliDate; $date = new NepaliDate('2081-07-15'); echo $date->toString() . PHP_EOL; // "2081/7/15" // String casting triggers __toString() echo (string) $date; // "2081/7/15" ``` --- ## Related * [`date->format()`](/docs/php/methods/format): Custom token formatting. * [`date->clone()`](/docs/php/methods/clone): Duplicate an instance. --- ## Page: Quick Start (PHP) (/docs/php/quick-start) Description: [PHP] Practical guide and essential code examples to start working with Bikram Sambat dates in PHP. Official API reference and code examples for PHP. This quick start guide demonstrates common practical workflows for creating dates, performing calendar arithmetic, formatting output strings, and converting between Gregorian and Bikram Sambat calendars in PHP. Use these patterns for building web portals, financial reports, and calendar tools. --- ## 1. Creating Dates Initialize dates representing the current moment, specific Bikram Sambat coordinates, or existing Gregorian dates: ```php format('YYYY-MM-DD') . PHP_EOL; // Specific Bikram Sambat date (Year, Month 0-11, Day 1-32) // Month index 6 corresponds to Kartik $constitutionDay = new NepaliDate(2072, 5, 3); echo $constitutionDay->format('YYYY-MM-DD') . PHP_EOL; // Parse from standard string formats (YYYY-MM-DD, YYYY/MM/DD, YYYY.MM.DD) $parsedDate = new NepaliDate('2081-07-15'); echo $parsedDate->format('MMMM DD, YYYY') . PHP_EOL; // From native PHP DateTimeInterface object $gregorian = DateTimeImmutable::createFromFormat('!Y-m-d', '2024-10-31', new DateTimeZone('UTC')); $fromGregorian = new NepaliDate($gregorian); echo $fromGregorian->format('YYYY-MM-DD') . PHP_EOL; ``` --- ## 2. Converting Between Calendars Convert strings directly without instantiating class objects: ```php addDays(15); echo $date->format('YYYY-MM-DD') . PHP_EOL; // Add 3 months $date->addMonths(3); echo $date->format('YYYY-MM-DD') . PHP_EOL; // Calculate difference in days between two dates $d1 = new NepaliDate('2081-01-01'); $d2 = new NepaliDate('2081-01-15'); $diffDays = $d2->diff($d1, 'days'); echo "Days difference: {$diffDays}" . PHP_EOL; ``` --- ## 4. Fiscal Year and Trimesters Query official Nepalese fiscal calendar information: ```php getCurrentFiscalYearQuarter(); echo "Fiscal Quarter: {$quarter}" . PHP_EOL; // Current fiscal year starting integer $fy = NepaliDate::getCurrentFiscalYear(); echo "Current Fiscal Year: {$fy}" . PHP_EOL; // Start and end dates of the active fiscal quarter $dates = $date->getCurrentFiscalYearQuarterDates(); echo "Quarter starts: " . $dates['start']->format('YYYY-MM-DD') . PHP_EOL; echo "Quarter ends: " . $dates['end']->format('YYYY-MM-DD') . PHP_EOL; ``` --- ## 5. Devanagari Formatting Format dates with Nepali numerals and month names: ```php format('dddd, MMMM DD, YYYY') . PHP_EOL; // "Friday, Kartik 15, 2081" // Devanagari format tokens echo $date->format('NDDD, NMMM NDD, NYYY') . PHP_EOL; ``` --- ## Page: NepaliDate::getCalendarDays() (PHP) (/docs/php/static/get-calendar-days) Description: [PHP] Static utility to generate a complete forty two cell calendar grid matrix for any month and year. Official API reference and code examples for PHP. The `getCalendarDays` static method generates a complete forty two cell grid structure representing six rows of seven days for displaying a monthly calendar view. It includes trailing days from the previous month and leading days from the next month to fill out the matrix, simplifying the creation of date pickers and visual calendar components. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function getCalendarDays(int $year, int $month): array; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$year` | `int` | Yes | Four digit Bikram Sambat year between `1976` and `2100`. | | `$month` | `int` | Yes | Zero based month index from `0` (Baisakh) to `11` (Chaitra). | --- ## Return Value * **Type**: `array{year: int, month: int, days: array}` * **Structure**: * `'year'`: Bikram Sambat year integer. * `'month'`: Month index integer. * `'days'`: List of 42 cell associative arrays with keys: * `'date'`: `NepaliDate` instance. * `'isCurrentMonth'`: Boolean indicating if day belongs to requested month. * `'day'`: Day number integer. --- ## Examples ```php use NepaliDateLibrary\NepaliDate; // Generate grid matrix for Kartik 2081 BS (month index 6) $grid = NepaliDate::getCalendarDays(2081, 6); echo "Total cells: " . count($grid['days']) . PHP_EOL; // 42 cells // Iterate cells in monthly view foreach ($grid['days'] as $cell) { $status = $cell['isCurrentMonth'] ? 'Current' : 'Neighbor'; echo "Day {$cell['day']} ({$status})" . PHP_EOL; } ``` --- ## Related * [`date->daysInMonth()`](/docs/php/methods/days-in-month): Total days in a month. * [`date->getWeeksInMonth()`](/docs/php/methods/get-weeks-in-month): Number of calendar rows needed. --- ## Page: NepaliDate::getDayName() (PHP) (/docs/php/static/get-day-name) Description: [PHP] Static utility to retrieve the localized English or Nepali name for any day of the week index. Official API reference and code examples for PHP. The `getDayName` static method converts a numeric weekday index from 0 for Sunday through 6 for Saturday into its localized name. It supports both English and Nepali Devanagari script output, allowing flexible localization across international and local application interfaces. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function getDayName( int $day, bool $short = false, bool $nepali = false ): string; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `$day` | `int` | Yes | - | Weekday index from `0` for Sunday to `6` for Saturday. | | `$short` | `bool` | No | `false` | Return abbreviated name. | | `$nepali` | `bool` | No | `false` | Return name in Devanagari Nepali script. | --- ## Return Value * **Type**: `string` * **Description**: Localized weekday name string. --- ## Examples ```php use NepaliDateLibrary\NepaliDate; // English full name (5 is Friday) echo NepaliDate::getDayName(5) . PHP_EOL; // "Friday" // English abbreviation echo NepaliDate::getDayName(5, true) . PHP_EOL; // "Fri" // Devanagari full name echo NepaliDate::getDayName(5, false, true) . PHP_EOL; // "शुक्रबार" // Devanagari abbreviation echo NepaliDate::getDayName(5, true, true) . PHP_EOL; // "शु" ``` --- ## Related * [`NepaliDate::getMonthName()`](/docs/php/static/get-month-name): Retrieve localized month names. * [`Constants::$WEEK_EN`](/docs/php/constants/week-en): Complete list of English weekday names. --- ## Page: NepaliDate::getMonthName() (PHP) (/docs/php/static/get-month-name) Description: [PHP] Static utility to retrieve the localized English or Nepali month name for any month index. Official API reference and code examples for PHP. The `getMonthName` static method returns the localized name of a Bikram Sambat month given its zero based index from 0 for Baisakh to 11 for Chaitra. It supports full names as well as short abbreviations in both English and Devanagari script. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function getMonthName( int $month, bool $short = false, bool $nepali = false ): string; ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `$month` | `int` | Yes | - | Zero based month index from `0` to `11`. | | `$short` | `bool` | No | `false` | Return abbreviated three letter or short string. | | `$nepali` | `bool` | No | `false` | Return name in native Devanagari Nepali script. | --- ## Return Value * **Type**: `string` * **Description**: Localized month name string. --- ## Examples ```php use NepaliDateLibrary\NepaliDate; // English full name (Kartik is index 6) echo NepaliDate::getMonthName(6) . PHP_EOL; // "Kartik" // English abbreviation echo NepaliDate::getMonthName(6, true) . PHP_EOL; // "Kar" // Devanagari full name echo NepaliDate::getMonthName(6, false, true) . PHP_EOL; // "कार्तिक" // Devanagari abbreviation echo NepaliDate::getMonthName(6, true, true) . PHP_EOL; // "का" ``` --- ## Related * [`NepaliDate::getDayName()`](/docs/php/static/get-day-name): Retrieve localized weekday names. * [`Constants::$MONTH_EN`](/docs/php/constants/month-en): Complete list of English month names. --- ## Page: NepaliDate::isValid() (PHP) (/docs/php/static/is-valid) Description: [PHP] Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date. Official API reference and code examples for PHP. The static `isValid` method verifies whether a specified Bikram Sambat year, month index, and day number represent a real calendar date. It consults verified historical data tables to confirm that the year falls within the supported range of 1976 through 2100 BS and that the day number does not exceed the actual number of days in that specific month. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function isValid(int $year, int $month, int $day): bool; ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `$year` | `int` | Yes | Four digit Bikram Sambat year between `1976` and `2100`. | | `$month` | `int` | Yes | Zero based month index from `0` (Baisakh) to `11` (Chaitra). | | `$day` | `int` | Yes | Day number of the month from `1` to `32`. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `true` if the date is valid, otherwise `false`. --- ## Examples ```php use NepaliDateLibrary\NepaliDate; // Valid date (Baisakh 1, 2081 BS) var_dump(NepaliDate::isValid(2081, 0, 1)); // true // Invalid day (Baisakh 32 does not exist in 2080 BS) var_dump(NepaliDate::isValid(2080, 0, 32)); // false // Out of range year var_dump(NepaliDate::isValid(1950, 0, 1)); // false ``` --- ## Related * [`date->isValidInstance()`](/docs/php/methods/is-valid): Instance validation method. * [`NepaliDate::minimum()`](/docs/php/static/minimum): Earliest supported date boundary. --- ## Page: NepaliDate::maximum() (PHP) (/docs/php/static/maximum) Description: [PHP] Static method returning the maximum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for PHP. The `maximum` static method returns a native PHP DateTimeImmutable object representing the latest Gregorian date supported by the library calendar engine. This corresponds to the final day of Chaitra in year 2100 BS and serves as an upper bound for date validation and calendar limits. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function maximum(): DateTimeImmutable; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `DateTimeImmutable` * **Value**: Gregorian UTC datetime corresponding to the last day of Chaitra in year `2100 BS` (mid April 2044 AD). --- ## Examples ```php use NepaliDateLibrary\NepaliDate; $maxDate = NepaliDate::maximum(); echo "Latest supported AD date: " . $maxDate->format('Y-m-d') . PHP_EOL; // Construct NepaliDate from the maximum boundary $ndMax = new NepaliDate($maxDate); echo "Latest BS date: " . $ndMax->format('YYYY-MM-DD'); ``` --- ## Related * [`NepaliDate::minimum()`](/docs/php/static/minimum): Earliest supported date boundary. * [`NepaliDate::isValid()`](/docs/php/static/is-valid): Check date bounds. --- ## Page: NepaliDate::minimum() (PHP) (/docs/php/static/minimum) Description: [PHP] Static method returning the minimum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for PHP. The `minimum` static method returns a native PHP DateTimeImmutable object representing the earliest Gregorian date supported by the library calendar engine. This corresponds to the first day of Baisakh in year 1976 BS and provides a reliable lower boundary for date pickers and form input validation. --- ## Import ```php use NepaliDateLibrary\NepaliDate; ``` --- ## Signature ```php public static function minimum(): DateTimeImmutable; ``` --- ## Parameters * None. --- ## Return Value * **Type**: `DateTimeImmutable` * **Value**: Gregorian UTC datetime corresponding to `1976-01-01 BS` (mid April 1919 AD). --- ## Examples ```php use NepaliDateLibrary\NepaliDate; $minDate = NepaliDate::minimum(); echo "Earliest supported AD date: " . $minDate->format('Y-m-d') . PHP_EOL; // Construct NepaliDate from the minimum boundary $ndMin = new NepaliDate($minDate); echo "Earliest BS date: " . $ndMin->format('YYYY-MM-DD'); // "1976-01-01" ``` --- ## Related * [`NepaliDate::maximum()`](/docs/php/static/maximum): Latest supported date boundary. * [`NepaliDate::isValid()`](/docs/php/static/is-valid): Validate date coordinates. --- ## Page: Overview (PYTHON) (/docs/python) Description: [PYTHON] Complete documentation and feature guide for the Nepali Date Library in Python applications. Official API reference and code examples for Python. The Nepali Date Library for Python provides a clean and idiomatic toolkit with zero external dependencies for Bikram Sambat calendar operations. It handles bidirectional conversion between Bikram Sambat and Gregorian calendars, date arithmetic, custom string formatting, fiscal year calculations, and calendar grid generation for Python applications and data pipelines. --- ## Installation Install the package from PyPI using your package manager: ```bash pip install nepali-date-library ``` --- ## Quick Example ```python from nepali_date_library import NepaliDate, ADtoBS, BStoAD # Current Nepali date today = NepaliDate() print(today.format("YYYY-MM-DD")) # Specific Bikram Sambat date (month 0 is Baisakh) event = NepaliDate(2081, 6, 15) print(event.format("dddd, MMMM DD, YYYY")) # Standalone date conversion bs_date = ADtoBS("2024-11-15") ad_date = BStoAD("2081-07-30") ``` --- ## Feature Matrix | Feature | Support | Description | | :--- | :---: | :--- | | **Bikram Sambat Calendar Engine** | Yes | Calendar matrix spanning 1976 through 2100 BS, audited and updated annually each Ashwin. | | **Bidirectional AD to BS Conversion** | Yes | Standalone conversion functions and full object instances. | | **Date Arithmetic** | Yes | Add and subtract days, months, and years with automatic rollover. | | **Fiscal Year Operations** | Yes | Official Nepalese fiscal calendar starting on 1 Shrawan. | | **Custom Format Patterns** | Yes | Token formatting for year, month, weekday, and Devanagari script. | | **Calendar Grid Builder** | Yes | Forty two cell matrix generation for calendar interfaces. | --- ## Package Information | Specification | Details | | :--- | :--- | | **PyPI Package** | [`nepali-date-library`](https://pypi.org/project/nepali-date-library/) | | **Repository** | [GitHub](https://github.com/SandipGhimire/Nepali-Date-Library-Python) | | **Supported Python** | Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13+ | | **License** | MIT License | --- ## Page: NepaliDate() (PYTHON) (/docs/python/class/constructor) Description: [PYTHON] Constructor overloads and initialization options for creating NepaliDate instances in Python. Official API reference and code examples for Python. The `NepaliDate` constructor creates instances representing specific points in time mapped to the Bikram Sambat calendar system. You can construct an instance representing the current moment, provide separate year, month, and day integers, supply a standard date string, or pass a native Python datetime object. Bikram Sambat months are indexed starting from 0 for Baisakh through 11 for Chaitra. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signatures ```python # 1. Current Date and Time NepaliDate() -> NepaliDate # 2. From Gregorian datetime object NepaliDate(date: datetime) -> NepaliDate # 3. From another NepaliDate instance (copy constructor) NepaliDate(date: NepaliDate) -> NepaliDate # 4. From Bikram Sambat date string NepaliDate(date_string: str) -> NepaliDate # 5. From separate Year, Month, Day integers NepaliDate(year: int, month: int, day: int) -> NepaliDate # 6. From Unix millisecond timestamp NepaliDate(timestamp_ms: int) -> NepaliDate ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year_or_date` | `int`, `str`, `datetime`, `NepaliDate`, `None` | No | Year integer, ISO date string, Gregorian datetime, or another NepaliDate instance. | | `month` | `int` | No | Zero based month index from `0` for Baisakh to `11` for Chaitra when specifying integers. | | `day` | `int` | No | Day of the month from `1` to `32` depending on the year and month. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: A newly instantiated `NepaliDate` instance representing the specified point in time. --- ## Examples ### Current Date and Time ```python from nepali_date_library import NepaliDate now = NepaliDate() print(now.format("YYYY-MM-DD")) ``` ### From Numeric Coordinates ```python # Month 0 is Baisakh, Day 1 new_year = NepaliDate(2081, 0, 1) print(new_year.format("YYYY-MM-DD")) # "2081-01-01" ``` ### From Date String ```python # Delimiters can be hyphens, slashes, or dots date1 = NepaliDate("2081-07-15") date2 = NepaliDate("2081/07/15") date3 = NepaliDate("2081.07.15") ``` ### From Python datetime ```python from datetime import datetime, timezone ad_date = datetime(2024, 10, 31, tzinfo=timezone.utc) nd = NepaliDate(ad_date) print(nd.format("YYYY-MM-DD")) # "2081-07-15" ``` --- ## Related * [`Instance Properties`](/docs/python/class/properties): Public properties accessible on NepaliDate instances. * [`date.set()`](/docs/python/methods/set): Update year, month, and day coordinates simultaneously. --- ## Page: Instance Properties (PYTHON) (/docs/python/class/properties) Description: [PYTHON] Reference for public instance properties available on every NepaliDate object including year, month, day, and underlying timestamp. Official API reference and code examples for Python. Every `NepaliDate` instance provides direct read access to its core calendar coordinates through public properties. These include the four digit Bikram Sambat year, the month number indexed from 0 to 11, the day of the month from 1 to 32, and the underlying UTC timestamp stored as a native Python datetime object. These properties reflect the current state of the date instance after any modifications or arithmetic operations. --- ## Property Reference | Property | Type | Description | Value Range | | :--- | :--- | :--- | :--- | | `year` | `int` | The four digit Bikram Sambat year. | `1976` to `2100` | | `month` | `int` | The zero based Bikram Sambat month index. | `0` (Baisakh) to `11` (Chaitra) | | `day` | `int` | The day of the month. | `1` to `32` | | `timestamp` | `datetime` | The equivalent native Python `datetime` object in UTC. | Gregorian timestamp | --- ## Examples ### Reading Properties ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") print(date.year) # 2081 print(date.month) # 6 (Kartik is index 6) print(date.day) # 15 print(date.timestamp) # 2024-10-31 00:00:00+00:00 ``` ### Working with Month Indices Because `month` is indexed starting from 0, add 1 when displaying human readable month numbers, or use helper methods: ```python print(date.month + 1) # 7 (Human readable month) print(date.get_month_name(date.month)) # "Kartik" ``` --- ## Related * [`date.get_year()`](/docs/python/methods/get-year): Getter method for year. * [`date.get_month()`](/docs/python/methods/get-month): Getter method for month index. * [`date.get_date()`](/docs/python/methods/get-date): Getter method for day of month. --- ## Page: month_en (PYTHON) (/docs/python/constants/month-en) Description: [PYTHON] Array containing standard romanized English names of all twelve Bikram Sambat calendar months. Official API reference and code examples for Python. The `month_en` constant is an immutable array containing the official romanized English names of the twelve Bikram Sambat months. The array is indexed starting from 0 for Baisakh up to index 11 for Chaitra, making it convenient for looking up month names corresponding to numeric month values returned by date methods. --- ## Import ```python from nepali_date_library import month_en ``` --- ## Value ```python month_en = [ "Baisakh", "Jestha", "Asar", "Shrawan", "Bhadra", "Aswin", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra", ] ``` --- ## Month Index Table | Index | English Name | Approximate Gregorian Window | | :---: | :--- | :--- | | `0` | `"Baisakh"` | Mid April to Mid May | | `1` | `"Jestha"` | Mid May to Mid June | | `2` | `"Asar"` | Mid June to Mid July | | `3` | `"Shrawan"` | Mid July to Mid August | | `4` | `"Bhadra"` | Mid August to Mid September | | `5` | `"Aswin"` | Mid September to Mid October | | `6` | `"Kartik"` | Mid October to Mid November | | `7` | `"Mangsir"` | Mid November to Mid December | | `8` | `"Poush"` | Mid December to Mid January | | `9` | `"Magh"` | Mid January to Mid February | | `10` | `"Falgun"` | Mid February to Mid March | | `11` | `"Chaitra"` | Mid March to Mid April | --- ## Example Usage ```python from nepali_date_library import NepaliDate, month_en date = NepaliDate("2081-07-15") month_index = date.get_month() print(f"Month: {month_en[month_index]}") # "Kartik" ``` --- ## Related * [`month_short_en`](/docs/python/constants/month-short-en): Abbreviated three letter English month names. * [`month_np`](/docs/python/constants/month-np): Full Devanagari Nepali month names. --- ## Page: month_np (PYTHON) (/docs/python/constants/month-np) Description: [PYTHON] Array containing official Devanagari Nepali names of all twelve Bikram Sambat calendar months. Official API reference and code examples for Python. The `month_np` constant is an immutable array containing the standard Nepali names in Devanagari script for the twelve Bikram Sambat months. Each index maps directly to the zero based month number, starting at index 0 for Baisakh through index 11 for Chaitra, enabling accurate localization in user interfaces and printed documents. --- ## Import ```python from nepali_date_library import month_np ``` --- ## Value ```python month_np = [ "बैशाख", "जेठ", "असार", "श्रावण", "भाद्र", "आश्विन", "कार्तिक", "मंसिर", "पौष", "माघ", "फाल्गुण", "चैत्र", ] ``` --- ## Month Index Table | Index | Devanagari Name | Romanized Name | | :---: | :--- | :--- | | `0` | `बैशाख` | Baisakh | | `1` | `जेठ` | Jestha | | `2` | `असार` | Asar | | `3` | `श्रावण` | Shrawan | | `4` | `भाद्र` | Bhadra | | `5` | `आश्विन` | Aswin | | `6` | `कार्तिक` | Kartik | | `7` | `मंसिर` | Mangsir | | `8` | `पौष` | Poush | | `9` | `माघ` | Magh | | `10` | `फाल्गुण` | Falgun | | `11` | `चैत्र` | Chaitra | --- ## Example Usage ```python from nepali_date_library import NepaliDate, month_np date = NepaliDate("2081-07-15") print(month_np[date.get_month()]) # "कार्तिक" ``` --- ## Related * [`month_short_np`](/docs/python/constants/month-short-np): Short Devanagari month abbreviations. * [`month_en`](/docs/python/constants/month-en): Romanized English month names. --- ## Page: month_short_en (PYTHON) (/docs/python/constants/month-short-en) Description: [PYTHON] Array containing three letter abbreviated English names for all twelve Bikram Sambat months. Official API reference and code examples for Python. The `month_short_en` constant provides three letter abbreviated English labels for each of the twelve Bikram Sambat months. It follows the zero based index convention from index 0 for Bai up to index 11 for Cha, making it ideal for compact calendar widgets, mobile screens, and table headers. --- ## Import ```python from nepali_date_library import month_short_en ``` --- ## Value ```python month_short_en = [ "Bai", "Jes", "Asa", "Shr", "Bhd", "Asw", "Kar", "Man", "Pou", "Mag", "Fal", "Cha", ] ``` --- ## Month Abbreviation Table | Index | Abbreviation | Full Name | | :---: | :--- | :--- | | `0` | `"Bai"` | Baisakh | | `1` | `"Jes"` | Jestha | | `2` | `"Asa"` | Asar | | `3` | `"Shr"` | Shrawan | | `4` | `"Bhd"` | Bhadra | | `5` | `"Asw"` | Aswin | | `6` | `"Kar"` | Kartik | | `7` | `"Man"` | Mangsir | | `8` | `"Pou"` | Poush | | `9` | `"Mag"` | Magh | | `10` | `"Fal"` | Falgun | | `11` | `"Cha"` | Chaitra | --- ## Example Usage ```python from nepali_date_library import NepaliDate, month_short_en date = NepaliDate("2081-07-15") print(month_short_en[date.get_month()]) # "Kar" ``` --- ## Related * [`month_en`](/docs/python/constants/month-en): Full English month names. * [`month_short_np`](/docs/python/constants/month-short-np): Devanagari short month abbreviations. --- ## Page: month_short_np (PYTHON) (/docs/python/constants/month-short-np) Description: [PYTHON] Array containing abbreviated Devanagari Nepali names for all twelve Bikram Sambat calendar months. Official API reference and code examples for Python. The `month_short_np` constant supplies short Devanagari abbreviations for each Bikram Sambat month. Starting with index 0 for Baisakh and ending with index 11 for Chaitra, these abbreviated labels are designed for space constrained displays such as date pickers, dashboard summaries, and mobile layouts. --- ## Import ```python from nepali_date_library import month_short_np ``` --- ## Value ```python month_short_np = [ "बै", "जे", "अ", "श्रा", "भा", "आ", "का", "मं", "पौ", "मा", "फा", "चै", ] ``` --- ## Month Abbreviation Table | Index | Short Devanagari | Full Devanagari | Romanized | | :---: | :--- | :--- | :--- | | `0` | `बै` | बैशाख | Baisakh | | `1` | `जे` | जेठ | Jestha | | `2` | `अ` | असार | Asar | | `3` | `श्रा` | श्रावण | Shrawan | | `4` | `भा` | भाद्र | Bhadra | | `5` | `आ` | आश्विन | Aswin | | `6` | `का` | कार्तिक | Kartik | | `7` | `मं` | मंसिर | Mangsir | | `8` | `पौ` | पौष | Poush | | `9` | `मा` | माघ | Magh | | `10` | `फा` | फाल्गुण | Falgun | | `11` | `चै` | चैत्र | Chaitra | --- ## Example Usage ```python from nepali_date_library import NepaliDate, month_short_np date = NepaliDate("2081-07-15") print(month_short_np[date.get_month()]) # "का" ``` --- ## Related * [`month_np`](/docs/python/constants/month-np): Full Devanagari month names. * [`month_short_en`](/docs/python/constants/month-short-en): Three letter English month abbreviations. --- ## Page: nepali_date_map (PYTHON) (/docs/python/constants/nepali-date-map) Description: [PYTHON] Historical calendar mapping table storing verified day counts for every Bikram Sambat month between 1976 and 2100 BS. Official API reference and code examples for Python. The `nepali_date_map` data structure contains the calendar matrix for the Bikram Sambat system spanning years 1976 through 2100 BS. Because Bikram Sambat months have variable day counts determined by astronomical solar calculations rather than fixed rules, this mapping table provides the definitive source of truth for conversions, day calculations, and month lengths. > [!NOTE] > Dates up to the active calendar year are verified against official publications from the **Nepal Panchanga Nirnayak Samiti** (नेपाल पञ्चाङ्ग निर्णायक समिति). Every year around the month of **Ashwin (Ashoj)**, when the official government calendar is gazetted for the subsequent year, this mapping table is audited and updated with exact solar ingress corrections. --- ## Import ```python from nepali_date_library import nepali_date_map ``` --- ## Structure Each entry in `nepali_date_map` is a dictionary containing year metadata and day counts: ```python from typing import TypedDict, List class NepaliDateEntry(TypedDict): year: int days: List[int] totalDays: int daysTillNow: int nepali_date_map: List[NepaliDateEntry] ``` --- ## Field Reference | Field | Type | Description | | :--- | :--- | :--- | | `year` | `int` | The Bikram Sambat year integer between 1976 and 2100 BS. | | `days` | `List[int]` | Twelve integers specifying the exact day counts for each month from Baisakh to Chaitra. | | `totalDays` | `int` | Total cumulative days in that specific calendar year. | | `daysTillNow` | `int` | Cumulative day offset since the calendar epoch. | --- ## Example Usage ```python from nepali_date_library import nepali_date_map # Retrieve data for year 2081 BS year_2081 = next(item for item in nepali_date_map if item["year"] == 2081) print(f"Year: {year_2081['year']}") print(f"Month day counts: {year_2081['days']}") # Day count for Baisakh (index 0) in 2081 BS baisakh_days = year_2081["days"][0] print(f"Days in Baisakh 2081: {baisakh_days}") ``` --- ## Related * [`date.days_in_month()`](/docs/python/methods/days-in-month): Query total days in a given month. * [`NepaliDate.is_valid()`](/docs/python/static/is-valid): Statically validate calendar coordinates. --- ## Page: number_np (PYTHON) (/docs/python/constants/number-np) Description: [PYTHON] Array containing Devanagari numeral glyphs for digits zero through nine used for Nepali number localization. Official API reference and code examples for Python. The `number_np` constant is an array containing the ten Devanagari numeral characters representing digits 0 through 9 in Nepali script. It provides a direct lookup table for formatting numbers, years, dates, and currency values into native Devanagari script for Nepali language interfaces. --- ## Import ```python from nepali_date_library import number_np ``` --- ## Value ```python number_np = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"] ``` --- ## Digit Lookup Table | Index | Arabic Digit | Devanagari Numeral | Unicode Code Point | | :---: | :---: | :---: | :--- | | `0` | `0` | `०` | `U+0966` | | `1` | `1` | `१` | `U+0967` | | `2` | `2` | `२` | `U+0968` | | `3` | `3` | `३` | `U+0969` | | `4` | `4` | `४` | `U+096A` | | `5` | `5` | `५` | `U+096B` | | `6` | `6` | `६` | `U+096C` | | `7` | `7` | `७` | `U+096D` | | `8` | `8` | `८` | `U+096E` | | `9` | `9` | `९` | `U+096F` | --- ## Examples ### Converting Digits to Devanagari ```python from nepali_date_library import number_np def to_devanagari(number: int) -> str: return "".join(number_np[int(digit)] for digit in str(number)) print(to_devanagari(2081)) # "२०८१" ``` --- ## Related * [`date.format()`](/docs/python/methods/format): Format dates using token specifiers with optional Devanagari numerals. * [`month_np`](/docs/python/constants/month-np): Devanagari month names. --- ## Page: week_en (PYTHON) (/docs/python/constants/week-en) Description: [PYTHON] Array containing full English names for all seven days of the week starting from Sunday. Official API reference and code examples for Python. The `week_en` constant is an array containing the full English weekday names ordered from Sunday at index 0 through Saturday at index 6. This ordering matches the standard JavaScript and Python day index convention returned by date methods, allowing seamless weekday lookups in English interfaces. --- ## Import ```python from nepali_date_library import week_en ``` --- ## Value ```python week_en = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", ] ``` --- ## Weekday Index Table | Index | English Name | Nepali Equivalent | | :---: | :--- | :--- | | `0` | `"Sunday"` | Aaitabar | | `1` | `"Monday"` | Sombar | | `2` | `"Tuesday"` | Mangalbar | | `3` | `"Wednesday"` | Budhabar | | `4` | `"Thursday"` | Bihibar | | `5` | `"Friday"` | Sukrabar | | `6` | `"Saturday"` | Shanibar | --- ## Example Usage ```python from nepali_date_library import NepaliDate, week_en date = NepaliDate("2081-07-15") day_index = date.get_day() print(f"Weekday: {week_en[day_index]}") # "Friday" ``` --- ## Related * [`week_short_en`](/docs/python/constants/week-short-en): Abbreviated three letter English weekday names. * [`week_np`](/docs/python/constants/week-np): Full Devanagari Nepali weekday names. --- ## Page: week_np (PYTHON) (/docs/python/constants/week-np) Description: [PYTHON] Array containing full Devanagari Nepali names for all seven days of the week starting from Sunday. Official API reference and code examples for Python. The `week_np` constant provides the full Devanagari Nepali names for the seven days of the week, beginning with Aaitabar at index 0 and concluding with Shanibar at index 6. It enables complete localization for calendar headings, date labels, and event scheduling in Nepali language applications. --- ## Import ```python from nepali_date_library import week_np ``` --- ## Value ```python week_np = [ "आइतबार", "सोमबार", "मंगलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार", ] ``` --- ## Weekday Index Table | Index | Devanagari Name | Romanized | English | | :---: | :--- | :--- | :--- | | `0` | `आइतबार` | Aaitabar | Sunday | | `1` | `सोमबार` | Sombar | Monday | | `2` | `मंगलबार` | Mangalbar | Tuesday | | `3` | `बुधबार` | Budhabar | Wednesday | | `4` | `बिहिबार` | Bihibar | Thursday | | `5` | `शुक्रबार` | Sukrabar | Friday | | `6` | `शनिबार` | Shanibar | Saturday | --- ## Example Usage ```python from nepali_date_library import NepaliDate, week_np date = NepaliDate("2081-07-15") print(week_np[date.get_day()]) # "शुक्रबार" ``` --- ## Related * [`week_short_np`](/docs/python/constants/week-short-np): Short Devanagari weekday abbreviations. * [`week_en`](/docs/python/constants/week-en): Full English weekday names. --- ## Page: week_short_en (PYTHON) (/docs/python/constants/week-short-en) Description: [PYTHON] Array containing abbreviated English weekday names ordered from Sunday through Saturday. Official API reference and code examples for Python. The `week_short_en` constant contains short three letter English abbreviations for each day of the week, starting with Sun at index 0 and ending with Sat at index 6. These concise labels are widely used in monthly calendar headers, compact date selectors, and agenda views. --- ## Import ```python from nepali_date_library import week_short_en ``` --- ## Value ```python week_short_en = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ] ``` --- ## Weekday Abbreviation Table | Index | Abbreviation | Full Name | | :---: | :--- | :--- | | `0` | `"Sun"` | Sunday | | `1` | `"Mon"` | Monday | | `2` | `"Tue"` | Tuesday | | `3` | `"Wed"` | Wednesday | | `4` | `"Thu"` | Thursday | | `5` | `"Fri"` | Friday | | `6` | `"Sat"` | Saturday | --- ## Example Usage ```python from nepali_date_library import NepaliDate, week_short_en date = NepaliDate("2081-07-15") print(week_short_en[date.get_day()]) # "Fri" ``` --- ## Related * [`week_en`](/docs/python/constants/week-en): Full English weekday names. * [`week_short_np`](/docs/python/constants/week-short-np): Devanagari short weekday abbreviations. --- ## Page: week_short_np (PYTHON) (/docs/python/constants/week-short-np) Description: [PYTHON] Array containing short Devanagari abbreviations for each day of the week starting from Sunday. Official API reference and code examples for Python. The `week_short_np` constant supplies short Devanagari abbreviations for each day of the week, beginning with index 0 for Aaitabar and ending with index 6 for Shanibar. These compact symbols are ideal for calendar grid headers and mobile date selectors where horizontal width is limited. --- ## Import ```python from nepali_date_library import week_short_np ``` --- ## Value ```python week_short_np = [ "आ", "सो", "मं", "बु", "बि", "शु", "श", ] ``` --- ## Weekday Abbreviation Table | Index | Short Devanagari | Full Devanagari | English | | :---: | :--- | :--- | :--- | | `0` | `आ` | आइतबार | Sunday | | `1` | `सो` | सोमबार | Monday | | `2` | `मं` | मंगलबार | Tuesday | | `3` | `बु` | बुधबार | Wednesday | | `4` | `बि` | बिहिबार | Thursday | | `5` | `शु` | शुक्रबार | Friday | | `6` | `श` | शनिबार | Saturday | --- ## Example Usage ```python from nepali_date_library import NepaliDate, week_short_np date = NepaliDate("2081-07-15") print(week_short_np[date.get_day()]) # "शु" ``` --- ## Related * [`week_np`](/docs/python/constants/week-np): Full Devanagari weekday names. * [`week_short_en`](/docs/python/constants/week-short-en): Three letter English weekday abbreviations. --- ## Page: Date Converter Guide (PYTHON) (/docs/python/date-converter) Description: [PYTHON] Comprehensive guide to converting dates between Gregorian and Bikram Sambat calendar systems using standalone helper functions. Official API reference and code examples for Python. The date converter utilities provide pure standalone functions for converting date strings directly between the Gregorian calendar and the Bikram Sambat calendar. These functions operate without creating full class instances, making them suitable for high throughput batch processing, database migrations, and backend service integration. --- ## Available Functions The library exports two primary conversion functions: * [`ADtoBS(adDate: str)`](/docs/python/date-converter/ad-to-bs): Converts a Gregorian calendar date string to a Bikram Sambat date string. * [`BStoAD(bsDate: str)`](/docs/python/date-converter/bs-to-ad): Converts a Bikram Sambat date string to a Gregorian calendar date string. --- ## Format Requirements Both functions require strict ISO formatted date strings: ```text YYYY-MM-DD ``` * Four digit year (`YYYY`) * Two digit month with leading zero (`MM`) * Two digit day with leading zero (`DD`) --- ## Comparison: Helper Functions vs NepaliDate Class | Requirement | Use `ADtoBS` and `BStoAD` | Use `NepaliDate` Class | | :--- | :---: | :---: | | Fast string conversion | Recommended | Optional | | Database pipelines and ETL | Recommended | Optional | | Date arithmetic (`add_days`, `diff`) | No | Recommended | | Custom token formatting | No | Recommended | | Calendar boundary calculations | No | Recommended | | Fiscal year operations | No | Recommended | --- ## Quick Example ```python from nepali_date_library import ADtoBS, BStoAD # Gregorian to Bikram Sambat bs = ADtoBS("2024-11-15") print(bs) # "2081-07-30" # Bikram Sambat to Gregorian ad = BStoAD("2081-07-30") print(ad) # "2024-11-15" ``` --- ## Page: ADtoBS() (PYTHON) (/docs/python/date-converter/ad-to-bs) Description: [PYTHON] Pure helper function to convert Gregorian calendar date strings into Bikram Sambat date strings. Official API reference and code examples for Python. The `ADtoBS` function performs direct mathematical conversion of a Gregorian date string into its corresponding Bikram Sambat date string. It accepts standard date formats and returns the converted Nepali date, handling month day variations and leap year calculations automatically without external dependencies. --- ## Import ```python from nepali_date_library import ADtoBS ``` --- ## Signature ```python def ADtoBS(adDate: str) -> str: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `adDate` | `str` | Yes | Gregorian date string formatted strictly as `YYYY-MM-DD`. | --- ## Return Value * **Type**: `str` * **Format**: `YYYY-MM-DD` representing the corresponding Bikram Sambat date. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid date format. Expected format: YYYY-MM-DD` | Raised if input does not strictly match the four digit year and two digit month day pattern. | | `Invalid date input ''` | Raised if date components cannot be parsed into valid Gregorian dates. | | `Fail to convert AD to BS` | Raised if the date falls outside the supported historical range. | --- ## Examples ### Basic Conversion ```python from nepali_date_library import ADtoBS nepali_date = ADtoBS("2023-04-14") print(nepali_date) # "2080-01-01" ``` ### Processing Data Records ```python records = [ {"id": 1, "created_at": "2024-01-01"}, {"id": 2, "created_at": "2024-07-15"}, ] for item in records: item["created_at_bs"] = ADtoBS(item["created_at"]) ``` --- ## Related * [`BStoAD()`](/docs/python/date-converter/bs-to-ad): Reverse conversion from Bikram Sambat to Gregorian. * [`NepaliDate Class`](/docs/python/class/constructor): Full date manipulation and arithmetic object. --- ## Page: BStoAD() (PYTHON) (/docs/python/date-converter/bs-to-ad) Description: [PYTHON] Pure helper function to convert Bikram Sambat date strings into Gregorian calendar date strings. Official API reference and code examples for Python. The `BStoAD` function converts a Bikram Sambat date string into its equivalent Gregorian calendar date string. It validates the input Nepali date against verified historical calendar maps and returns a formatted Gregorian date string suitable for storage in standard SQL databases or transmission over web APIs. --- ## Import ```python from nepali_date_library import BStoAD ``` --- ## Signature ```python def BStoAD(bsDate: str) -> str: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `bsDate` | `str` | Yes | Bikram Sambat date string formatted strictly as `YYYY-MM-DD`. | --- ## Return Value * **Type**: `str` * **Format**: `YYYY-MM-DD` representing the equivalent Gregorian calendar date. --- ## Exceptions | Error Message | Trigger Condition | | :--- | :--- | | `Invalid date format. Expected format: YYYY-MM-DD` | Raised if input string fails the regex validation `^\d{4}-\d{2}-\d{2}$`. | | `Nepal year out of range` | Raised if the year is earlier than 1976 BS or later than 2100 BS. | | `Invalid Nepali month` | Raised if the month number is not between 1 and 12. | | `Invalid Nepali date` | Raised if the day number exceeds the actual days in that specific Nepali month. | --- ## Examples ### Basic Conversion ```python from nepali_date_library import BStoAD gregorian_date = BStoAD("2080-01-01") print(gregorian_date) # "2023-04-14" ``` ### Storing in SQL Databases ```python user_input_bs = "2081-07-15" database_ad_date = BStoAD(user_input_bs) print(database_ad_date) # "2024-10-31" ``` --- ## Related * [`ADtoBS()`](/docs/python/date-converter/ad-to-bs): Convert Gregorian date strings to Bikram Sambat. * [`date.get_english_date()`](/docs/python/methods/get-english-date): Retrieve a native Python datetime object. --- ## Page: Fiscal Year & Quarters Guide (PYTHON) (/docs/python/fiscal-year) Description: [PYTHON] Architecture and calculation rules for Nepal official fiscal year and quarterly trimester accounting cycles. Official API reference and code examples for Python. In Nepal the official fiscal year begins on 1 Shrawan and ends on the final day of Ashadh in the following calendar year. The nepali date library includes specialized functions to compute fiscal years, identify trimester quarters, and determine quarter start and end boundary dates for financial, tax, and accounting systems. --- ## Fiscal Year Structure Because the fiscal year starts in the fourth month of Bikram Sambat (Shrawan), every fiscal cycle spans two calendar years: * **Format**: Standardized as `YYYY/YY` (for example `2081/82 BS`). * **Start Date**: `1 Shrawan` (Month index `3`, Day `1`). * **End Date**: `Last day of Ashadh` (Month index `2`, Day `31` or `32` of the succeeding calendar year). --- ## Fiscal Quarters (Trimesters) The financial year in Nepal is divided into four three month trimesters: | Quarter | Trimester Name | Constituent Months | Month Indices | Approximate Period | | :---: | :--- | :--- | :---: | :--- | | **Q1** | First Trimester | Shrawan, Bhadra, Aswin | `3`, `4`, `5` | Mid July to Mid October | | **Q2** | Second Trimester | Kartik, Mangsir, Poush | `6`, `7`, `8` | Mid October to Mid January | | **Q3** | Third Trimester | Magh, Falgun, Chaitra | `9`, `10`, `11` | Mid January to Mid April | | **Q4** | Fourth Trimester | Baisakh, Jestha, Ashadh | `0`, `1`, `2` | Mid April to Mid July (Next Year) | --- ## Available API Methods | Method | Type | Description | | :--- | :---: | :--- | | [`NepaliDate.current_fiscal_year()`](/docs/python/fiscal-year/current-fiscal-year) | Static | Returns the starting Bikram Sambat year of the active fiscal year. | | [`date.fiscal_quarter()`](/docs/python/fiscal-year/fiscal-quarter) | Instance | Returns the fiscal quarter index (1 to 4) for the date. | | [`date.fiscal_quarter_dates()`](/docs/python/fiscal-year/fiscal-quarter-dates) | Instance | Returns exact start and end `NepaliDate` objects for the active fiscal quarter. | | [`NepaliDate.get_fiscal_quarter()`](/docs/python/fiscal-year/get-fiscal-quarter) | Static | Returns start and end boundaries for any specified quarter and year. | | [`NepaliDate.get_fiscal_quarters()`](/docs/python/fiscal-year/get-fiscal-quarters) | Static | Returns boundary dates for all four fiscal trimesters of a given year. | | [`Calendar Quarters Guide`](/docs/python/fiscal-year/calendar-quarters) | Guide | Explains standard Bikram Sambat calendar quarters vs fiscal trimesters. | --- ## Page: Calendar Quarters (PYTHON) (/docs/python/fiscal-year/calendar-quarters) Description: [PYTHON] Explanation of standard Bikram Sambat calendar quarters compared to government fiscal trimesters. Official API reference and code examples for Python. Standard calendar quarters divide the Bikram Sambat calendar year into four equal three month periods starting from 1 Baisakh. This guide clarifies the structural difference between standard calendar quarters and Nepal government fiscal year trimesters, which commence three months later on 1 Shrawan. --- ## Calendar Quarters Breakdown Unlike the government fiscal calendar which begins in Shrawan, standard calendar quarters follow the natural calendar year starting from Baisakh: | Quarter | Months Included | Month Indices | Approximate Gregorian Window | | :---: | :--- | :---: | :--- | | **Q1** | Baisakh, Jestha, Asar | `0`, `1`, `2` | Mid April to Mid July | | **Q2** | Shrawan, Bhadra, Aswin | `3`, `4`, `5` | Mid July to Mid October | | **Q3** | Kartik, Mangsir, Poush | `6`, `7`, `8` | Mid October to Mid January | | **Q4** | Magh, Falgun, Chaitra | `9`, `10`, `11` | Mid January to Mid April | --- ## Related Methods in Python The library provides dedicated methods for working with standard calendar quarters: ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-15") # Calendar quarter number (1 to 4) print(date.current_quarter()) # 1 # Start and end dates of the active calendar quarter c_dates = date.current_quarter_dates() print(f"Starts: {c_dates['start'].format('YYYY-MM-DD')}") print(f"Ends: {c_dates['end'].format('YYYY-MM-DD')}") # Static lookup for a specific year and quarter q2_2081 = NepaliDate.get_quarter(quarter=2, year=2081) print(f"Q2 starts: {q2_2081['start'].format('YYYY-MM-DD')}") ``` --- ## Calendar vs Fiscal Quarters Comparison | Feature | Standard Calendar Quarter | Government Fiscal Trimester | | :--- | :--- | :--- | | **Year Start** | 1 Baisakh (Mid April) | 1 Shrawan (Mid July) | | **Q1 Months** | Baisakh, Jestha, Asar | Shrawan, Bhadra, Aswin | | **Methods** | `current_quarter()`, `get_quarter()` | `fiscal_quarter()`, `get_fiscal_quarter()` | | **Use Cases** | Public calendars, UI views, general scheduling | Taxes, government accounting, corporate audits | --- ## Page: NepaliDate.current_fiscal_year() (PYTHON) (/docs/python/fiscal-year/current-fiscal-year) Description: [PYTHON] Method to retrieve the formatted fiscal year string for a given NepaliDate instance. Official API reference and code examples for Python. The `current_fiscal_year` method determines which official Nepalese fiscal year contains the current date instance. It returns a standardized fiscal year string such as 2081/82 based on whether the date falls before or after the 1 Shrawan fiscal transition boundary. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def current_fiscal_year() -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Description**: The starting four digit Bikram Sambat calendar year of the current fiscal year. * **Example**: Returns `2081` for fiscal year 2081/82 BS. --- ## Examples ### Checking Active Fiscal Year ```python from nepali_date_library import NepaliDate fy_start = NepaliDate.current_fiscal_year() fy_label = f"{fy_start}/{str(fy_start + 1)[-2:]}" print(f"Fiscal Year: {fy_label} BS") # e.g. "2081/82 BS" ``` --- ## Related * [`date.fiscal_quarter()`](/docs/python/fiscal-year/fiscal-quarter): Get the active fiscal trimester number. * [`date.fiscal_quarter_dates()`](/docs/python/fiscal-year/fiscal-quarter-dates): Get boundary dates of the active fiscal quarter. --- ## Page: date.fiscal_quarter() (PYTHON) (/docs/python/fiscal-year/fiscal-quarter) Description: [PYTHON] Method to calculate the active fiscal trimester quarter number for a NepaliDate instance. Official API reference and code examples for Python. The `fiscal_quarter` method returns an integer from 1 to 4 representing the active fiscal trimester of the current date. Because Nepal fiscal calendar starts in Shrawan, quarter 1 covers Shrawan through Ashwin, quarter 2 spans Kartik through Poush, quarter 3 covers Magh through Chaitra, and quarter 4 spans Baisakh through Ashadh. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def fiscal_quarter(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1` to `4` * **Description**: The fiscal trimester index for the date. --- ## Trimester Mapping Table | Month Index | Month Name | Fiscal Quarter | Trimester Label | | :---: | :--- | :---: | :--- | | `3` | Shrawan | `1` | First Trimester (Q1) | | `4` | Bhadra | `1` | First Trimester (Q1) | | `5` | Aswin | `1` | First Trimester (Q1) | | `6` | Kartik | `2` | Second Trimester (Q2) | | `7` | Mangsir | `2` | Second Trimester (Q2) | | `8` | Poush | `2` | Second Trimester (Q2) | | `9` | Magh | `3` | Third Trimester (Q3) | | `10` | Falgun | `3` | Third Trimester (Q3) | | `11` | Chaitra | `3` | Third Trimester (Q3) | | `0` | Baisakh | `4` | Fourth Trimester (Q4) | | `1` | Jestha | `4` | Fourth Trimester (Q4) | | `2` | Asar | `4` | Fourth Trimester (Q4) | --- ## Examples ```python from nepali_date_library import NepaliDate date1 = NepaliDate("2081-04-15") # Shrawan print(date1.fiscal_quarter()) # 1 date2 = NepaliDate("2081-07-20") # Kartik print(date2.fiscal_quarter()) # 2 date3 = NepaliDate("2081-10-10") # Magh print(date3.fiscal_quarter()) # 3 date4 = NepaliDate("2082-01-05") # Baisakh print(date4.fiscal_quarter()) # 4 ``` --- ## Related * [`date.fiscal_quarter_dates()`](/docs/python/fiscal-year/fiscal-quarter-dates): Retrieve boundary start and end dates. * [`date.current_quarter()`](/docs/python/methods/current-quarter): Standard Bikram Sambat calendar quarter. --- ## Page: date.fiscal_quarter_dates() (PYTHON) (/docs/python/fiscal-year/fiscal-quarter-dates) Description: [PYTHON] Method to retrieve exact start and end boundary dates for the active fiscal quarter. Official API reference and code examples for Python. The `fiscal_quarter_dates` method computes the exact starting date and ending date for the fiscal quarter containing the current date instance. It returns an object containing boundary dates as new NepaliDate objects, which is helpful for quarterly financial reporting, audit periods, and tax filing windows. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def fiscal_quarter_dates(self) -> Dict[str, NepaliDate]: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `Dict[str, NepaliDate]` * **Structure**: * `"start"`: `NepaliDate` object positioned on the first day of the fiscal quarter at midnight. * `"end"`: `NepaliDate` object positioned on the final day of the fiscal quarter. --- ## Examples ### Generating Quarterly Accounting Windows ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-05-15") # Bhadra (Q1) quarter_info = date.fiscal_quarter_dates() start_date = quarter_info["start"] end_date = quarter_info["end"] print(f"Q1 starts: {start_date.format('YYYY-MM-DD')}") # "2081-04-01" (1 Shrawan) print(f"Q1 ends: {end_date.format('YYYY-MM-DD')}") # "2081-06-30" (End of Aswin) ``` --- ## Related * [`NepaliDate.get_fiscal_quarter()`](/docs/python/fiscal-year/get-fiscal-quarter): Look up boundaries for any quarter. * [`date.fiscal_quarter()`](/docs/python/fiscal-year/fiscal-quarter): Retrieve the active quarter index. --- ## Page: NepaliDate.get_fiscal_quarter() (PYTHON) (/docs/python/fiscal-year/get-fiscal-quarter) Description: [PYTHON] Static method to determine the fiscal trimester number for any specified month index. Official API reference and code examples for Python. The static `get_fiscal_quarter` method determines the fiscal trimester number corresponding to a given Bikram Sambat month index from 0 to 11. It allows quick lookups without needing to instantiate a full NepaliDate object, making it useful in financial aggregation pipelines and reporting utilities. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def get_fiscal_quarter( quarter: int, fiscal_year: Optional[int] = None ) -> Dict[str, NepaliDate]: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `quarter` | `int` | Yes | Trimester index from `1` to `4`. | | `fiscal_year` | `Optional[int]` | No | Starting Bikram Sambat year of the fiscal period. Defaults to current fiscal year. | --- ## Return Value * **Type**: `Dict[str, NepaliDate]` * **Structure**: Dictionary with `"start"` and `"end"` keys holding boundary `NepaliDate` instances. --- ## Examples ```python from nepali_date_library import NepaliDate # Get boundaries for Q2 of fiscal year 2081/82 BS q2_dates = NepaliDate.get_fiscal_quarter(quarter=2, fiscal_year=2081) print(f"Start: {q2_dates['start'].format('YYYY-MM-DD')}") # 1 Kartik print(f"End: {q2_dates['end'].format('YYYY-MM-DD')}") # Last day of Poush ``` --- ## Related * [`NepaliDate.get_fiscal_quarters()`](/docs/python/fiscal-year/get-fiscal-quarters): Retrieve all four quarters for a fiscal year. * [`date.fiscal_quarter_dates()`](/docs/python/fiscal-year/fiscal-quarter-dates): Instance method for current date. --- ## Page: NepaliDate.get_fiscal_quarters() (PYTHON) (/docs/python/fiscal-year/get-fiscal-quarters) Description: [PYTHON] Static utility returning all four fiscal trimesters with their constituent months and date ranges for a given year. Official API reference and code examples for Python. The static `get_fiscal_quarters` method returns a complete structural breakdown of all four fiscal trimesters for a specified Bikram Sambat year. Each quarter entry includes its trimester index, English and Nepali month names, and corresponding calendar boundary information. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def get_fiscal_quarters( fiscal_year: Optional[int] = None ) -> Dict[str, Dict[str, NepaliDate]]: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `fiscal_year` | `Optional[int]` | No | Four digit starting Bikram Sambat year. Defaults to current fiscal year. | --- ## Return Value * **Type**: `Dict[str, Dict[str, NepaliDate]]` * **Structure**: A dictionary with keys `"Q1"`, `"Q2"`, `"Q3"`, and `"Q4"`, each containing `"start"` and `"end"` `NepaliDate` objects. --- ## Examples ```python from nepali_date_library import NepaliDate quarters = NepaliDate.get_fiscal_quarters(2081) for q_name, boundaries in quarters.items(): start_str = boundaries["start"].format("YYYY-MM-DD") end_str = boundaries["end"].format("YYYY-MM-DD") print(f"{q_name}: {start_str} to {end_str}") ``` --- ## Related * [`NepaliDate.get_fiscal_quarter()`](/docs/python/fiscal-year/get-fiscal-quarter): Query a single trimester boundary. * [`date.fiscal_quarter_dates()`](/docs/python/fiscal-year/fiscal-quarter-dates): Active quarter boundaries for an instance. --- ## Page: Installation & Setup (PYTHON) (/docs/python/installation) Description: [PYTHON] Installation and setup instructions for nepali date library in Python projects using pip, uv, and poetry. Official API reference and code examples for Python. The nepali date library is distributed as a lightweight Python package available on PyPI with zero external runtime dependencies. It supports all standard Python package managers and virtual environment workflows. --- ## Package Installation ```bash pip install nepali-date-library ``` ```bash uv add nepali-date-library ``` ```bash poetry add nepali-date-library ``` --- ## Project Configuration ### requirements.txt Add the package dependency to your `requirements.txt` file: ```text nepali-date-library>=0.0.1 ``` ### pyproject.toml For modern packaging with Flit, Hatch, Poetry, or Setuptools: ```toml [project] dependencies = [ "nepali-date-library>=0.0.1", ] ``` --- ## Verification Verify that the installation succeeded by importing the class in your terminal: ```bash python3 -c "import nepali_date_library; print(nepali_date_library.__version__)" ``` --- ## Next Steps * [Quick Start Guide](/docs/python/quick-start): Learn core workflows and common patterns. * [NepaliDate Class Reference](/docs/python/class/constructor): Explore constructor signatures and instance creation. --- ## Page: date.add_days() (PYTHON) (/docs/python/methods/add-days) Description: [PYTHON] Add or subtract a specified number of days to a NepaliDate instance with automatic month and year rollover. Official API reference and code examples for Python. The `add_days` method modifies the current `NepaliDate` instance by adding or subtracting a given integer number of days. It automatically handles variable Bikram Sambat month day counts, transitions across month boundaries, and advances or decrements the year when needed. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def add_days(self, days: int) -> NepaliDate: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `days` | `int` | Yes | Positive or negative number of days to add. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: Returns `self` after mutating the internal coordinates. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-25") date.add_days(10) print(date.format("YYYY-MM-DD")) # Transitions into Jestha ``` --- ## Related * [`date.add_months()`](/docs/python/methods/add-months): Add or subtract months. * [`date.diff()`](/docs/python/methods/diff): Calculate day differences. --- ## Page: date.add_months() (PYTHON) (/docs/python/methods/add-months) Description: [PYTHON] Add or subtract months to a NepaliDate instance while adjusting for variable month lengths. Official API reference and code examples for Python. The `add_months` method advances or rewinds the current `NepaliDate` instance by a specified number of months. If the current day of the month exceeds the total days available in the destination month, the method automatically clamps the day to the final valid day of that month to ensure calendar consistency. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def add_months(self, months: int) -> NepaliDate: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `months` | `int` | Yes | Positive or negative integer of months to add. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: Returns `self` after mutation. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-15") date.add_months(6) print(date.format("YYYY-MM-DD")) # "2081-07-15" ``` --- ## Related * [`date.add_years()`](/docs/python/methods/add-years): Add or subtract years. * [`date.add_days()`](/docs/python/methods/add-days): Add or subtract days. --- ## Page: date.add_years() (PYTHON) (/docs/python/methods/add-years) Description: [PYTHON] Add or subtract years to a NepaliDate instance while preserving month and day values. Official API reference and code examples for Python. The `add_years` method adds or subtracts a specified number of years to the current `NepaliDate` instance. It recalculates the underlying timestamp while retaining the month and day coordinates, adjusting the day number if the target year has fewer days in that specific month. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def add_years(self, years: int) -> NepaliDate: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `years` | `int` | Yes | Number of years to advance or rewind. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: Returns `self` after mutation. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2075-01-01") date.add_years(5) print(date.format("YYYY-MM-DD")) # "2080-01-01" ``` --- ## Related * [`date.add_months()`](/docs/python/methods/add-months): Add or subtract months. * [`date.diff()`](/docs/python/methods/diff): Difference between two dates. --- ## Page: date.clone() (PYTHON) (/docs/python/methods/clone) Description: [PYTHON] Create an independent deep clone of an existing NepaliDate instance. Official API reference and code examples for Python. The `clone` method creates and returns an independent duplicate of the current `NepaliDate` instance. Because several library arithmetic and mutation methods alter instances in place, creating a clone allows you to perform calculations without modifying the original date object. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def clone(self) -> NepaliDate: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: A new independent `NepaliDate` instance with identical coordinates and timestamp. --- ## Example ```python from nepali_date_library import NepaliDate original = NepaliDate("2081-07-15") duplicate = original.clone() # Mutating duplicate does not affect original duplicate.add_days(10) print(original.format("YYYY-MM-DD")) # "2081-07-15" print(duplicate.format("YYYY-MM-DD")) # "2081-07-25" ``` --- ## Related * [`NepaliDate Constructor`](/docs/python/class/constructor): Copy constructor support. * [`date.add_days()`](/docs/python/methods/add-days): In-place day arithmetic. --- ## Page: date.current_quarter() (PYTHON) (/docs/python/methods/current-quarter) Description: [PYTHON] Return the standard Bikram Sambat calendar quarter number from one to four for the current date. Official API reference and code examples for Python. The `current_quarter` method returns an integer from 1 to 4 designating the standard calendar quarter containing the current date. Calendar quarters divide the Bikram Sambat year into four sequential segments starting from 1 Baisakh, which differs from government fiscal trimesters that commence in Shrawan. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def current_quarter(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1` to `4` * **Description**: Standard calendar quarter number. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-15") # Baisakh print(date.current_quarter()) # 1 date2 = NepaliDate("2081-07-15") # Kartik print(date2.current_quarter()) # 3 ``` --- ## Related * [`date.fiscal_quarter()`](/docs/python/fiscal-year/fiscal-quarter): Official fiscal trimester number. * [`Calendar Quarters Guide`](/docs/python/fiscal-year/calendar-quarters): Comparison guide. --- ## Page: date.days_in_month() (PYTHON) (/docs/python/methods/days-in-month) Description: [PYTHON] Retrieve the total number of days in the current or specified Bikram Sambat month. Official API reference and code examples for Python. The `days_in_month` method returns the total number of days present in the active month of the current `NepaliDate` instance, or for an explicitly provided year and month combination. Because Bikram Sambat month durations vary from 29 to 32 days depending on astronomical solar calculations, this method provides accurate month lengths. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def days_in_month(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `29` to `32` * **Description**: Total number of days in the active month. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-01") # Baisakh 2081 print(f"Days in Baisakh 2081: {date.days_in_month()}") # 31 ``` --- ## Related * [`date.get_weeks_in_month()`](/docs/python/methods/get-weeks-in-month): Calendar rows for month. * [`NepaliDate.get_calendar_days()`](/docs/python/static/get-calendar-days): Generate calendar matrix. --- ## Page: date.diff() (PYTHON) (/docs/python/methods/diff) Description: [PYTHON] Calculate the chronological difference between two NepaliDate instances in specific time units. Official API reference and code examples for Python. The `diff` method calculates the elapsed time duration between the current `NepaliDate` instance and another date object. It can return the difference in days, months, years, hours, minutes, seconds, or milliseconds, making it suitable for calculating age, tenure, or interval durations. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def diff(self, date: NepaliDate, unit: str) -> int: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Target date instance to compare against. | | `unit` | `str` | Yes | Measurement unit: `"days"`, `"months"`, `"years"`, `"hours"`, `"minutes"`, `"seconds"`. | --- ## Return Value * **Type**: `int` * **Description**: Integer difference count in the specified unit. --- ## Example ```python from nepali_date_library import NepaliDate d1 = NepaliDate("2081-01-01") d2 = NepaliDate("2081-01-20") days_diff = d2.diff(d1, "days") print(f"Difference in days: {days_diff}") # 19 ``` --- ## Related * [`date.is_before()`](/docs/python/methods/is-before): Check chronological order. * [`date.is_after()`](/docs/python/methods/is-after): Check chronological order. --- ## Page: date.end_of_day() (PYTHON) (/docs/python/methods/end-of-day) Description: [PYTHON] Return a new NepaliDate instance set to the final millisecond of the current day. Official API reference and code examples for Python. The `end_of_day` method returns a new `NepaliDate` instance with time coordinates set to the final moment of the day at 23 hours, 59 minutes, 59 seconds, and 999 milliseconds. This is commonly used when setting upper boundaries for database queries, event schedules, and daily audit filters. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def end_of_day(self) -> NepaliDate: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to 23:59:59.999 UTC. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") day_end = date.end_of_day() print(day_end.get_hours()) # 23 print(day_end.get_minutes()) # 59 ``` --- ## Related * [`date.start_of_day()`](/docs/python/methods/start-of-day): Set time to midnight. * [`date.end_of_month()`](/docs/python/methods/end-of-month): Final day of the month. --- ## Page: date.end_of_month() (PYTHON) (/docs/python/methods/end-of-month) Description: [PYTHON] Return a new NepaliDate instance set to the final day of the current Bikram Sambat month. Official API reference and code examples for Python. The `end_of_month` method returns a new `NepaliDate` instance positioned on the last valid calendar day of the active month. It automatically checks the calendar map to determine whether the month ends on day 29, 30, 31, or 32, which is useful for monthly reporting and billing cycles. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def end_of_month(self) -> NepaliDate: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance on the final day of the current month. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-10") last_day = date.end_of_month() print(last_day.format("YYYY-MM-DD")) # Day 31 for Baisakh 2081 ``` --- ## Related * [`date.start_of_month()`](/docs/python/methods/start-of-month): First day of the month. * [`date.days_in_month()`](/docs/python/methods/days-in-month): Total days in the month. --- ## Page: date.end_of_week() (PYTHON) (/docs/python/methods/end-of-week) Description: [PYTHON] Return a new NepaliDate instance set to the final day of the current week on Saturday. Official API reference and code examples for Python. The `end_of_week` method produces a new `NepaliDate` instance representing the last day of the week containing the current date. In standard Nepali calendar practice, Saturday is regarded as the final day of the weekly cycle. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def end_of_week(self, start_of_week: int = 0) -> NepaliDate: ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `start_of_week` | `int` | No | `0` | Weekday index treated as week start. | --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to Saturday (index 6). --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") week_end = date.end_of_week() print(week_end.get_day()) # 6 (Saturday) ``` --- ## Related * [`date.start_of_week()`](/docs/python/methods/start-of-week): First day of the week. * [`date.end_of_month()`](/docs/python/methods/end-of-month): Final day of the month. --- ## Page: date.end_of_year() (PYTHON) (/docs/python/methods/end-of-year) Description: [PYTHON] Return a new NepaliDate instance set to the final day of the Bikram Sambat year on the last day of Chaitra. Official API reference and code examples for Python. The `end_of_year` method returns a new `NepaliDate` instance set to the closing day of the current Bikram Sambat calendar year. This corresponds to the final day of Chaitra, which is commonly needed for annual reconciliations and fiscal year preparations. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def end_of_year(self) -> NepaliDate: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance on the final day of Chaitra. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") year_end = date.end_of_year() print(year_end.format("YYYY-MM-DD")) # "2081-12-30" or similar ``` --- ## Related * [`date.start_of_year()`](/docs/python/methods/start-of-year): First day of the year. * [`date.is_leap_year()`](/docs/python/methods/is-leap-year): Total year day check. --- ## Page: date.format() (PYTHON) (/docs/python/methods/format) Description: [PYTHON] Format a NepaliDate instance into a custom string using token patterns for English and Nepali output. Official API reference and code examples for Python. The `format` method transforms a `NepaliDate` instance into a formatted string according to a pattern of token specifiers. It supports tokens for year, month, day, weekday, hours, minutes, and seconds, with full support for localized English names as well as Devanagari script numerals and words. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def format(self, format_str: str) -> str: ``` --- ## Common Format Tokens | Token | Output Format | Example | | :--- | :--- | :--- | | `YYYY` | Four digit year | `2081` | | `YY` | Two digit year | `81` | | `MMMM` | Full month name | `Kartik` | | `MMM` | Short month name | `Kar` | | `MM` | Two digit month number | `07` | | `M` | One or two digit month number | `7` | | `DD` | Two digit day of month | `15` | | `D` | One or two digit day of month | `15` | | `dddd` | Full weekday name | `Friday` | | `ddd` | Short weekday name | `Fri` | | `HH` | Two digit 24-hour time | `14` | | `mm` | Two digit minute | `30` | | `ss` | Two digit second | `45` | --- ## Examples ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") # Standard ISO format print(date.format("YYYY-MM-DD")) # "2081-07-15" # Long English date print(date.format("dddd, MMMM DD, YYYY")) # "Friday, Kartik 15, 2081" ``` --- ## Related * [`date.clone()`](/docs/python/methods/clone): Duplicate a date instance. * [`NepaliDate.get_month_name()`](/docs/python/static/get-month-name): Static month name helper. --- ## Page: date.get_date() (PYTHON) (/docs/python/methods/get-date) Description: [PYTHON] Retrieve the numeric day of the month from a NepaliDate instance. Official API reference and code examples for Python. The `get_date` method returns the day of the month as an integer from 1 to 32 for the current `NepaliDate` instance. Unlike Gregorian months which have at most 31 days, Bikram Sambat calendar months can extend up to 32 days depending on the year and month. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_date(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1` to `32` * **Description**: Day of the month integer. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") print(date.get_date()) # 15 ``` --- ## Related * [`date.set_date()`](/docs/python/methods/set-date): Mutate the day of the month. * [`date.get_day()`](/docs/python/methods/get-day): Retrieve the day of the week. --- ## Page: date.get_day() (PYTHON) (/docs/python/methods/get-day) Description: [PYTHON] Retrieve the numeric day of the week index from zero for Sunday through six for Saturday. Official API reference and code examples for Python. The `get_day` method returns an integer representing the day of the week for the current `NepaliDate` instance. The return value ranges from 0 for Sunday to 6 for Saturday, aligning with standard calendar day conventions. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_day(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `6` * **Description**: Day of the week integer starting from `0` for Sunday up to `6` for Saturday. --- ## Example ```python from nepali_date_library import NepaliDate, week_en date = NepaliDate("2081-07-15") weekday_index = date.get_day() print(weekday_index) # 5 (Friday) print(week_en[weekday_index]) # "Friday" ``` --- ## Related * [`NepaliDate.get_day_name()`](/docs/python/static/get-day-name): Retrieve localized weekday names. * [`date.get_date()`](/docs/python/methods/get-date): Retrieve the day of the month. --- ## Page: date.get_english_date() (PYTHON) (/docs/python/methods/get-english-date) Description: [PYTHON] Retrieve the equivalent Gregorian date as a native JavaScript Date object. Official API reference and code examples for Python. The `get_english_date` method returns the native Python datetime object corresponding to the current `NepaliDate` instance. This allows seamless integration with third party libraries, databases, and standard Python APIs that expect a native Gregorian datetime object. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_english_date(self) -> datetime: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `datetime` * **Description**: Native Python datetime object in UTC matching the current Bikram Sambat date. --- ## Example ```python from nepali_date_library import NepaliDate nd = NepaliDate("2081-07-15") ad_date = nd.get_english_date() print(type(ad_date)) # print(ad_date.strftime("%Y-%m-%d")) # "2024-10-31" ``` --- ## Related * [`BStoAD()`](/docs/python/date-converter/bs-to-ad): String based date conversion. * [`date.set_english_date()`](/docs/python/methods/set-english-date): Update instance from datetime. --- ## Page: date.get_hours() (PYTHON) (/docs/python/methods/get-hours) Description: [PYTHON] Retrieve the hour component from zero to twenty three for the current date instance. Official API reference and code examples for Python. The `get_hours` method returns the hour of the day as an integer between 0 and 23 for the current `NepaliDate` instance. It reflects local time coordinates stored within the instance timestamp. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_hours(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `23` * **Description**: Hour integer representing time of day. --- ## Example ```python from nepali_date_library import NepaliDate now = NepaliDate() print(f"Current hour: {now.get_hours()}") ``` --- ## Related * [`date.get_minutes()`](/docs/python/methods/get-minutes): Retrieve the minute component. * [`date.get_seconds()`](/docs/python/methods/get-seconds): Retrieve the second component. --- ## Page: date.get_milliseconds() (PYTHON) (/docs/python/methods/get-milliseconds) Description: [PYTHON] Retrieve the millisecond component from zero to nine hundred ninety nine. Official API reference and code examples for Python. The `get_milliseconds` method returns the millisecond fraction of the current second as an integer from 0 to 999. It provides high resolution timing details for precision logging and event timestamping. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_milliseconds(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `999` * **Description**: Millisecond integer between 0 and 999. --- ## Example ```python from nepali_date_library import NepaliDate now = NepaliDate() print(f"Milliseconds: {now.get_milliseconds()}") ``` --- ## Related * [`date.get_time()`](/docs/python/methods/get-time): Retrieve epoch timestamp in milliseconds. * [`date.get_seconds()`](/docs/python/methods/get-seconds): Retrieve second component. --- ## Page: date.get_minutes() (PYTHON) (/docs/python/methods/get-minutes) Description: [PYTHON] Retrieve the minute component from zero to fifty nine for the current date instance. Official API reference and code examples for Python. The `get_minutes` method returns the minute value as an integer from 0 to 59 for the current `NepaliDate` instance. It is derived from the underlying timestamp representing the recorded time of the date object. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_minutes(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `59` * **Description**: Minute integer between 0 and 59. --- ## Example ```python from nepali_date_library import NepaliDate now = NepaliDate() print(f"Current minute: {now.get_minutes()}") ``` --- ## Related * [`date.get_hours()`](/docs/python/methods/get-hours): Retrieve the hour component. * [`date.get_seconds()`](/docs/python/methods/get-seconds): Retrieve the second component. --- ## Page: date.get_month() (PYTHON) (/docs/python/methods/get-month) Description: [PYTHON] Retrieve the zero based Bikram Sambat month index from zero for Baisakh to eleven for Chaitra. Official API reference and code examples for Python. The `get_month` method returns the month of the year as an integer between 0 and 11 for the current `NepaliDate` instance. The library adheres to the zero based indexing standard where 0 represents Baisakh, 1 represents Jestha, and 11 represents Chaitra. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_month(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `11` * **Description**: Zero based month index from Baisakh (`0`) to Chaitra (`11`). --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") # Kartik print(date.get_month()) # 6 (Kartik is index 6) ``` --- ## Related * [`date.set_month()`](/docs/python/methods/set-month): Mutate the month component. * [`NepaliDate.get_month_name()`](/docs/python/static/get-month-name): Look up the month name. --- ## Page: date.get_seconds() (PYTHON) (/docs/python/methods/get-seconds) Description: [PYTHON] Retrieve the second component from zero to fifty nine for the current date instance. Official API reference and code examples for Python. The `get_seconds` method returns the second value as an integer from 0 to 59 for the current `NepaliDate` instance. It enables precise second level timing and formatting. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_seconds(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `0` to `59` * **Description**: Second integer between 0 and 59. --- ## Example ```python from nepali_date_library import NepaliDate now = NepaliDate() print(f"Current second: {now.get_seconds()}") ``` --- ## Related * [`date.get_minutes()`](/docs/python/methods/get-minutes): Retrieve the minute component. * [`date.get_milliseconds()`](/docs/python/methods/get-milliseconds): Retrieve milliseconds. --- ## Page: date.get_time() (PYTHON) (/docs/python/methods/get-time) Description: [PYTHON] Retrieve the numeric timestamp in milliseconds since the Unix epoch. Official API reference and code examples for Python. The `get_time` method returns the number of milliseconds elapsed since the Unix epoch of January 1, 1970 UTC. This integer value matches the return value of standard epoch timestamps and allows direct numerical comparison between date instances. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_time(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Description**: Milliseconds elapsed since January 1, 1970 00:00:00 UTC. --- ## Example ```python from nepali_date_library import NepaliDate d1 = NepaliDate("2081-01-01") d2 = NepaliDate("2081-01-02") print(d1.get_time() < d2.get_time()) # True ``` --- ## Related * [`date.get_english_date()`](/docs/python/methods/get-english-date): Retrieve Python datetime object. * [`date.diff()`](/docs/python/methods/diff): Calculate duration differences. --- ## Page: date.get_weeks_in_month() (PYTHON) (/docs/python/methods/get-weeks-in-month) Description: [PYTHON] Calculate the number of calendar week rows required to render the current month in a grid. Official API reference and code examples for Python. The `get_weeks_in_month` method computes the total number of seven day week rows required to display the entire month in a standard calendar grid. Depending on which weekday the month starts on and how many days it contains, the returned count is usually five or six rows. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_weeks_in_month(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `4`, `5`, or `6` * **Description**: Number of week rows needed for a calendar view. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-01") print(f"Weeks in month: {date.get_weeks_in_month()}") ``` --- ## Related * [`NepaliDate.get_calendar_days()`](/docs/python/static/get-calendar-days): Matrix grid builder. * [`date.days_in_month()`](/docs/python/methods/days-in-month): Total days in month. --- ## Page: date.get_year() (PYTHON) (/docs/python/methods/get-year) Description: [PYTHON] Retrieve the four digit Bikram Sambat year number from a NepaliDate instance. Official API reference and code examples for Python. The `get_year` method returns the full four digit Bikram Sambat year as an integer for the current `NepaliDate` instance. It returns the complete calendar year such as 2081 within the supported range of 1976 through 2100 BS. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def get_year(self) -> int: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `int` * **Range**: `1976` to `2100` * **Description**: Four digit Bikram Sambat year integer. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") print(date.get_year()) # 2081 ``` --- ## Related * [`date.set_year()`](/docs/python/methods/set-year): Mutate the year component. * [`date.get_month()`](/docs/python/methods/get-month): Retrieve the month component. --- ## Page: date.is_after() (PYTHON) (/docs/python/methods/is-after) Description: [PYTHON] Check whether the current date occurs chronologically after another specified date. Official API reference and code examples for Python. The `is_after` method evaluates whether the current `NepaliDate` instance occurs chronologically later than another date or timestamp. It compares exact millisecond values to determine chronological order accurately. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def is_after(self, date: NepaliDate) -> bool: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Target date to compare against. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `True` if `self` is chronologically later than `date`. --- ## Example ```python from nepali_date_library import NepaliDate d1 = NepaliDate("2081-01-15") d2 = NepaliDate("2081-01-01") print(d1.is_after(d2)) # True ``` --- ## Related * [`date.is_before()`](/docs/python/methods/is-before): Check if earlier in time. * [`date.is_equal()`](/docs/python/methods/is-equal): Check calendar date equality. --- ## Page: date.is_before() (PYTHON) (/docs/python/methods/is-before) Description: [PYTHON] Check whether the current date occurs chronologically before another specified date. Official API reference and code examples for Python. The `is_before` method evaluates whether the current `NepaliDate` instance occurs earlier in time than another provided date. It takes into account both date and time components down to millisecond accuracy. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def is_before(self, date: NepaliDate) -> bool: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Target date to compare against. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `True` if `self` is chronologically earlier than `date`. --- ## Example ```python from nepali_date_library import NepaliDate d1 = NepaliDate("2081-01-01") d2 = NepaliDate("2081-01-15") print(d1.is_before(d2)) # True print(d2.is_before(d1)) # False ``` --- ## Related * [`date.is_after()`](/docs/python/methods/is-after): Check if later in time. * [`date.is_equal()`](/docs/python/methods/is-equal): Check calendar date equality. --- ## Page: date.is_equal() (PYTHON) (/docs/python/methods/is-equal) Description: [PYTHON] Check whether two date instances share the exact same calendar date coordinates regardless of time. Official API reference and code examples for Python. The `is_equal` method checks whether the current `NepaliDate` instance shares the exact same Bikram Sambat year, month, and day coordinates as another date object, ignoring any differences in hours, minutes, seconds, or milliseconds. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def is_equal(self, date: NepaliDate) -> bool: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Date instance to compare coordinates with. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `True` if year, month, and day are identical. --- ## Example ```python from nepali_date_library import NepaliDate d1 = NepaliDate("2081-07-15") d2 = NepaliDate("2081-07-15") print(d1.is_equal(d2)) # True ``` --- ## Related * [`date.is_same()`](/docs/python/methods/is-same): Compare with custom granularity. * [`date.is_before()`](/docs/python/methods/is-before): Check chronological order. --- ## Page: date.is_leap_year() (PYTHON) (/docs/python/methods/is-leap-year) Description: [PYTHON] Determine whether the current Bikram Sambat calendar year has three hundred sixty six or more days. Official API reference and code examples for Python. The `is_leap_year` method checks whether the active Bikram Sambat year contains 366 or more days based on official solar calendar tables. Because Bikram Sambat year lengths depend on astronomical calculations rather than fixed leap year cycles, this method checks the actual cumulative day count for the year. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def is_leap_year(self) -> bool: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `bool` * **Description**: Returns `True` if the year has 366 or more days. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-01") print(date.is_leap_year()) ``` --- ## Related * [`date.days_in_month()`](/docs/python/methods/days-in-month): Total days in a month. * [`nepali_date_map`](/docs/python/constants/nepali-date-map): Calendar mapping table. --- ## Page: date.is_same() (PYTHON) (/docs/python/methods/is-same) Description: [PYTHON] Check whether two dates match across a specified granularity such as year, month, or day. Official API reference and code examples for Python. The `is_same` method compares the current `NepaliDate` instance with another date at a specified level of granularity, such as year, month, day, hour, or minute. It returns true if both dates match within that specific unit, simplifying range checks and calendar filters. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def is_same(self, date: NepaliDate, unit: str) -> bool: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `NepaliDate` | Yes | Date instance to compare with. | | `unit` | `str` | Yes | Granularity: `"year"`, `"month"`, `"date"`, `"day"`. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `True` if the specified unit matches. --- ## Example ```python from nepali_date_library import NepaliDate d1 = NepaliDate("2081-07-05") d2 = NepaliDate("2081-07-20") # Same month and year print(d1.is_same(d2, "month")) # True # Different day print(d1.is_same(d2, "date")) # False ``` --- ## Related * [`date.is_equal()`](/docs/python/methods/is-equal): Compare full date equality. * [`date.diff()`](/docs/python/methods/diff): Quantitative difference. --- ## Page: date.is_valid_instance() (PYTHON) (/docs/python/methods/is-valid) Description: [PYTHON] Validate whether the current NepaliDate instance represents a legitimate calendar date within supported bounds. Official API reference and code examples for Python. The `is_valid_instance` method checks whether the current `NepaliDate` instance contains valid calendar values and falls within the supported range of 1976 through 2100 BS. It verifies that year, month, and day coordinates correspond to an authentic historical date. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def is_valid_instance(self) -> bool: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `bool` * **Description**: Returns `True` if the date is valid. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") print(date.is_valid_instance()) # True ``` --- ## Related * [`NepaliDate.is_valid()`](/docs/python/static/is-valid): Static validation method. * [`NepaliDate.minimum()`](/docs/python/static/minimum): Earliest supported date. --- ## Page: date.parse() (PYTHON) (/docs/python/methods/parse) Description: [PYTHON] Parse a formatted Bikram Sambat date string and update the current date instance in place. Official API reference and code examples for Python. The `parse` method parses a Bikram Sambat date string and updates the coordinates of the current `NepaliDate` instance in place. It supports various delimiter styles including slashes, dots, and hyphens, recalculating the underlying timestamp upon successful parsing. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def parse(self, date_string: str) -> None: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date_string` | `str` | Yes | Formatted Bikram Sambat date string (e.g. `"2081-07-15"`). | --- ## Return Value * **Type**: `None` * **Note**: Mutates the current instance in place. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate() date.parse("2081-07-15") print(date.format("YYYY-MM-DD")) # "2081-07-15" ``` --- ## Related * [`NepaliDate Constructor`](/docs/python/class/constructor): Create instances from strings. * [`date.format()`](/docs/python/methods/format): Format dates to strings. --- ## Page: date.set() (PYTHON) (/docs/python/methods/set) Description: [PYTHON] Set year, month, and day coordinates simultaneously on a NepaliDate instance. Official API reference and code examples for Python. The `set` method updates the Bikram Sambat year, zero based month index, and day values of the current `NepaliDate` instance in a single atomic call. It validates the combined coordinates against the calendar map and recalculates the internal timestamp. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def set(self, year: int, month: int, date: int) -> None: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `int` | Yes | Bikram Sambat year integer between 1976 and 2100. | | `month` | `int` | Yes | Zero based month index from 0 (Baisakh) to 11 (Chaitra). | | `date` | `int` | Yes | Day number of the month from 1 to 32. | --- ## Return Value * **Type**: `None` * **Note**: Mutates the current `NepaliDate` instance in place. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2080-01-01") date.set(2081, 6, 15) # Kartik 15, 2081 BS print(date.format("YYYY-MM-DD")) # "2081-07-15" ``` --- ## Related * [`date.set_year()`](/docs/python/methods/set-year): Mutate year only. * [`date.set_month()`](/docs/python/methods/set-month): Mutate month only. --- ## Page: date.set_date() (PYTHON) (/docs/python/methods/set-date) Description: [PYTHON] Set the day of the month on a NepaliDate instance and recalculate its timestamp. Official API reference and code examples for Python. The `set_date` method updates the day of the month for the current `NepaliDate` instance and recalculates its underlying Gregorian timestamp. It validates the new day against the maximum number of days available in the active month. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def set_date(self, day: int) -> None: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `day` | `int` | Yes | Target day of the month between `1` and `32`. | --- ## Return Value * **Type**: `None` * **Note**: Mutates the current instance in place. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-01") date.set_date(15) print(date.format("YYYY-MM-DD")) # "2081-07-15" ``` --- ## Related * [`date.get_date()`](/docs/python/methods/get-date): Retrieve day of the month. * [`date.add_days()`](/docs/python/methods/add-days): Add or subtract days. --- ## Page: date.set_english_date() (PYTHON) (/docs/python/methods/set-english-date) Description: [PYTHON] Update internal Bikram Sambat coordinates from a native Python datetime object. Official API reference and code examples for Python. The `set_english_date` method converts a native Python datetime object into Bikram Sambat coordinates and updates the current `NepaliDate` instance in place. It recalculates the year, month, and day coordinates based on historical ephemeris tables. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def set_english_date(self, date: datetime) -> None: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `date` | `datetime` | Yes | Gregorian datetime object to convert. | --- ## Return Value * **Type**: `None` * **Note**: Mutates the current instance in place. --- ## Example ```python from datetime import datetime, timezone from nepali_date_library import NepaliDate nd = NepaliDate() gregorian = datetime(2023, 4, 14, tzinfo=timezone.utc) nd.set_english_date(gregorian) print(nd.format("YYYY-MM-DD")) # "2080-01-01" ``` --- ## Related * [`date.get_english_date()`](/docs/python/methods/get-english-date): Retrieve Gregorian datetime object. * [`ADtoBS()`](/docs/python/date-converter/ad-to-bs): Standalone string conversion. --- ## Page: date.set_month() (PYTHON) (/docs/python/methods/set-month) Description: [PYTHON] Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping. Official API reference and code examples for Python. The `set_month` method updates the Bikram Sambat month for the current `NepaliDate` instance using a zero based month index from 0 for Baisakh to 11 for Chaitra. If the current day exceeds the total days in the destination month, the day is automatically clamped to the final valid day of that month. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def set_month(self, month: int) -> None: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `month` | `int` | Yes | Target zero based month index from `0` to `11`. | --- ## Return Value * **Type**: `None` * **Note**: Mutates the current instance in place. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-31") # Change to month index 1 (Jestha) date.set_month(1) print(date.format("YYYY-MM-DD")) ``` --- ## Related * [`date.get_month()`](/docs/python/methods/get-month): Retrieve month index. * [`date.add_months()`](/docs/python/methods/add-months): Add or subtract months. --- ## Page: date.set_year() (PYTHON) (/docs/python/methods/set-year) Description: [PYTHON] Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range. Official API reference and code examples for Python. The `set_year` method updates the four digit Bikram Sambat year on the current `NepaliDate` instance and adjusts the timestamp accordingly. The target year must fall within the supported range between 1976 and 2100 BS. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def set_year(self, year: int) -> None: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `int` | Yes | Target Bikram Sambat year between 1976 and 2100. | --- ## Return Value * **Type**: `None` * **Note**: Mutates the current instance in place. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2080-07-15") date.set_year(2081) print(date.format("YYYY-MM-DD")) # "2081-07-15" ``` --- ## Related * [`date.get_year()`](/docs/python/methods/get-year): Retrieve current year. * [`date.add_years()`](/docs/python/methods/add-years): Add or subtract years. --- ## Page: date.start_of_day() (PYTHON) (/docs/python/methods/start-of-day) Description: [PYTHON] Return a new NepaliDate instance set to the first moment of the current day at midnight. Official API reference and code examples for Python. The `start_of_day` method returns a new `NepaliDate` instance with time coordinates set to midnight at 00 hours, 00 minutes, 00 seconds, and 000 milliseconds. This is useful for date normalization and time neutral comparisons. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def start_of_day(self) -> NepaliDate: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to 00:00:00.000 UTC. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate() midnight = date.start_of_day() print(midnight.get_hours()) # 0 print(midnight.get_minutes()) # 0 ``` --- ## Related * [`date.end_of_day()`](/docs/python/methods/end-of-day): Set time to final millisecond of the day. * [`date.start_of_month()`](/docs/python/methods/start-of-month): Boundary for month start. --- ## Page: date.start_of_month() (PYTHON) (/docs/python/methods/start-of-month) Description: [PYTHON] Return a new NepaliDate instance set to the first day of the current Bikram Sambat month. Official API reference and code examples for Python. The `start_of_month` method returns a new `NepaliDate` instance positioned on day 1 of the active Bikram Sambat month with time set to midnight. It is commonly used for monthly calendar views, statements, and aggregation buckets. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def start_of_month(self) -> NepaliDate: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance on day 1 of the month. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") first_day = date.start_of_month() print(first_day.format("YYYY-MM-DD")) # "2081-07-01" ``` --- ## Related * [`date.end_of_month()`](/docs/python/methods/end-of-month): Final day of the month. * [`date.start_of_year()`](/docs/python/methods/start-of-year): First day of the year. --- ## Page: date.start_of_week() (PYTHON) (/docs/python/methods/start-of-week) Description: [PYTHON] Return a new NepaliDate instance set to the first day of the week on Sunday. Official API reference and code examples for Python. The `start_of_week` method returns a new `NepaliDate` instance set to Sunday, the first day of the weekly cycle containing the current date. It serves as an anchor date for week based scheduling and calendar grids. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def start_of_week(self, start_of_week: int = 0) -> NepaliDate: ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `start_of_week` | `int` | No | `0` | Weekday index to treat as week start (0 for Sunday). | --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance set to the first day of the week. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") week_start = date.start_of_week() print(week_start.get_day()) # 0 (Sunday) ``` --- ## Related * [`date.end_of_week()`](/docs/python/methods/end-of-week): Saturday boundary of the week. * [`date.start_of_month()`](/docs/python/methods/start-of-month): First day of the month. --- ## Page: date.start_of_year() (PYTHON) (/docs/python/methods/start-of-year) Description: [PYTHON] Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh. Official API reference and code examples for Python. The `start_of_year` method returns a new `NepaliDate` instance set to 1 Baisakh, the first day of the Bikram Sambat calendar year. This is useful for year to date financial tracking and annual summary reports. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python def start_of_year(self) -> NepaliDate: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `NepaliDate` * **Description**: New date instance positioned on 1 Baisakh of the current year. --- ## Example ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") year_start = date.start_of_year() print(year_start.format("YYYY-MM-DD")) # "2081-01-01" ``` --- ## Related * [`date.end_of_year()`](/docs/python/methods/end-of-year): Final day of the year. * [`date.start_of_month()`](/docs/python/methods/start-of-month): First day of the month. --- ## Page: Quick Start (PYTHON) (/docs/python/quick-start) Description: [PYTHON] Practical guide and essential code examples to start working with Bikram Sambat dates in Python. Official API reference and code examples for Python. This quick start guide demonstrates common practical workflows for creating dates, performing calendar arithmetic, formatting output strings, and converting between Gregorian and Bikram Sambat calendars in Python. Use these patterns for building web portals, financial reports, and calendar tools. --- ## 1. Creating Dates Initialize dates representing the current moment, specific Bikram Sambat coordinates, or existing Gregorian dates: ```python from datetime import datetime, timezone from nepali_date_library import NepaliDate # Current date and time in Nepal now = NepaliDate() print(now.format("YYYY-MM-DD")) # Specific Bikram Sambat date (Year, Month 0-11, Day 1-32) # Month index 6 corresponds to Kartik constitution_day = NepaliDate(2072, 5, 3) print(constitution_day.format("YYYY-MM-DD")) # Parse from standard string formats (YYYY-MM-DD, YYYY/MM/DD, YYYY.MM.DD) parsed_date = NepaliDate("2081-07-15") print(parsed_date.format("MMMM DD, YYYY")) # From native Python datetime gregorian_dt = datetime(2024, 10, 31, tzinfo=timezone.utc) from_gregorian = NepaliDate(gregorian_dt) print(from_gregorian.format("YYYY-MM-DD")) ``` --- ## 2. Converting Between Calendars Convert strings directly without instantiating class objects: ```python from nepali_date_library import ADtoBS, BStoAD # Convert Gregorian (AD) to Bikram Sambat (BS) bs_string = ADtoBS("2024-11-15") print(bs_string) # "2081-07-30" # Convert Bikram Sambat (BS) to Gregorian (AD) ad_string = BStoAD("2081-07-30") print(ad_string) # "2024-11-15" ``` --- ## 3. Date Arithmetic Add or subtract days, months, and years with automatic rollover: ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-01-25") # Add 15 days (automatically transitions to Jestha) date.add_days(15) print(date.format("YYYY-MM-DD")) # Add 3 months date.add_months(3) print(date.format("YYYY-MM-DD")) # Calculate difference in days between two dates d1 = NepaliDate("2081-01-01") d2 = NepaliDate("2081-01-15") diff_days = d2.diff(d1, "days") print(f"Days difference: {diff_days}") ``` --- ## 4. Fiscal Year and Trimesters Query official Nepalese fiscal calendar information: ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-06-15") # Active fiscal quarter (trimester 1 to 4) quarter = date.fiscal_quarter() print(f"Fiscal Quarter: {quarter}") # Current fiscal year string fy = NepaliDate.current_fiscal_year() print(f"Current Fiscal Year: {fy}") # Start and end dates of the active fiscal quarter dates = date.fiscal_quarter_dates() print(f"Quarter starts: {dates['start'].format('YYYY-MM-DD')}") print(f"Quarter ends: {dates['end'].format('YYYY-MM-DD')}") ``` --- ## 5. Devanagari Formatting Format dates with Nepali numerals and month names: ```python from nepali_date_library import NepaliDate date = NepaliDate("2081-07-15") # English format tokens print(date.format("dddd, MMMM DD, YYYY")) # "Friday, Kartik 15, 2081" # Devanagari Nepali format tokens print(date.format("dddd, MMMM DD, YYYY", nepali=True)) ``` --- ## Page: NepaliDate.get_calendar_days() (PYTHON) (/docs/python/static/get-calendar-days) Description: [PYTHON] Static utility to generate a complete forty two cell calendar grid matrix for any month and year. Official API reference and code examples for Python. The `get_calendar_days` static method generates a complete forty two cell grid structure representing six rows of seven days for displaying a monthly calendar view. It includes trailing days from the previous month and leading days from the next month to fill out the matrix, simplifying the creation of date pickers and visual calendar components. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def get_calendar_days(year: int, month: int) -> Dict[str, Any]: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `int` | Yes | Four digit Bikram Sambat year between `1976` and `2100`. | | `month` | `int` | Yes | Zero based month index from `0` (Baisakh) to `11` (Chaitra). | --- ## Return Value * **Type**: `Dict[str, Any]` * **Structure**: * `"year"`: Bikram Sambat year. * `"month"`: Month index. * `"days"`: List of 42 cell dictionaries with keys: * `"date"`: `NepaliDate` instance. * `"isCurrentMonth"`: Boolean indicating if day belongs to requested month. * `"day"`: Day integer. --- ## Examples ```python from nepali_date_library import NepaliDate # Generate grid matrix for Kartik 2081 BS (month index 6) grid = NepaliDate.get_calendar_days(2081, 6) print(f"Total cells: {len(grid['days'])}") # 42 cells # Print each day in the calendar view for cell in grid["days"]: status = "Current" if cell["isCurrentMonth"] else "Neighbor" print(f"Day {cell['day']} ({status})") ``` --- ## Related * [`date.days_in_month()`](/docs/python/methods/days-in-month): Total days in a month. * [`date.get_weeks_in_month()`](/docs/python/methods/get-weeks-in-month): Number of calendar rows needed. --- ## Page: NepaliDate.get_day_name() (PYTHON) (/docs/python/static/get-day-name) Description: [PYTHON] Static utility to retrieve the localized English or Nepali name for any day of the week index. Official API reference and code examples for Python. The `get_day_name` static method converts a numeric weekday index from 0 for Sunday through 6 for Saturday into its localized name. It supports both English and Nepali Devanagari script output, allowing flexible localization across international and local application interfaces. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def get_day_name( day: int, short: bool = False, nepali: bool = False ) -> str: ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `day` | `int` | Yes | - | Weekday index from `0` for Sunday to `6` for Saturday. | | `short` | `bool` | No | `False` | Return abbreviated name. | | `nepali` | `bool` | No | `False` | Return name in Devanagari Nepali script. | --- ## Return Value * **Type**: `str` * **Description**: Localized weekday name string. --- ## Examples ```python from nepali_date_library import NepaliDate # English full name (5 is Friday) print(NepaliDate.get_day_name(5)) # "Friday" # English abbreviation print(NepaliDate.get_day_name(5, short=True)) # "Fri" # Devanagari full name print(NepaliDate.get_day_name(5, nepali=True)) # "शुक्रबार" # Devanagari abbreviation print(NepaliDate.get_day_name(5, short=True, nepali=True)) # "शु" ``` --- ## Related * [`NepaliDate.get_month_name()`](/docs/python/static/get-month-name): Retrieve localized month names. * [`week_en`](/docs/python/constants/week-en): Complete list of English weekday names. --- ## Page: NepaliDate.get_month_name() (PYTHON) (/docs/python/static/get-month-name) Description: [PYTHON] Static utility to retrieve the localized English or Nepali month name for any month index. Official API reference and code examples for Python. The `get_month_name` static method returns the localized name of a Bikram Sambat month given its zero based index from 0 for Baisakh to 11 for Chaitra. It supports full names as well as short abbreviations in both English and Devanagari script. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def get_month_name( month: int, short: bool = False, nepali: bool = False ) -> str: ``` --- ## Parameters | Parameter | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | `month` | `int` | Yes | - | Zero based month index from `0` to `11`. | | `short` | `bool` | No | `False` | Return abbreviated three letter or short string. | | `nepali` | `bool` | No | `False` | Return name in native Devanagari Nepali script. | --- ## Return Value * **Type**: `str` * **Description**: Localized month name string. --- ## Examples ```python from nepali_date_library import NepaliDate # English full name (Kartik is index 6) print(NepaliDate.get_month_name(6)) # "Kartik" # English abbreviation print(NepaliDate.get_month_name(6, short=True)) # "Kar" # Devanagari full name print(NepaliDate.get_month_name(6, nepali=True)) # "कार्तिक" # Devanagari abbreviation print(NepaliDate.get_month_name(6, short=True, nepali=True)) # "का" ``` --- ## Related * [`NepaliDate.get_day_name()`](/docs/python/static/get-day-name): Retrieve localized weekday names. * [`month_en`](/docs/python/constants/month-en): Complete list of English month names. --- ## Page: NepaliDate.is_valid() (PYTHON) (/docs/python/static/is-valid) Description: [PYTHON] Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date. Official API reference and code examples for Python. The static `is_valid` method verifies whether a specified Bikram Sambat year, month index, and day number represent a real calendar date. It consults verified historical data tables to confirm that the year falls within the supported range of 1976 through 2100 BS and that the day number does not exceed the actual number of days in that specific month. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def is_valid(year: int, month: int, date: int) -> bool: ``` --- ## Parameters | Parameter | Type | Required | Description | | :--- | :--- | :---: | :--- | | `year` | `int` | Yes | Four digit Bikram Sambat year between `1976` and `2100`. | | `month` | `int` | Yes | Zero based month index from `0` (Baisakh) to `11` (Chaitra). | | `date` | `int` | Yes | Day number of the month from `1` to `32`. | --- ## Return Value * **Type**: `bool` * **Description**: Returns `True` if the date is astronomically and historically valid, otherwise `False`. --- ## Examples ```python from nepali_date_library import NepaliDate # Valid date (Baisakh 1, 2081 BS) print(NepaliDate.is_valid(2081, 0, 1)) # True # Invalid day (Baisakh 32 does not exist in 2080 BS) print(NepaliDate.is_valid(2080, 0, 32)) # False # Out of range year print(NepaliDate.is_valid(1950, 0, 1)) # False ``` --- ## Related * [`date.is_valid_instance()`](/docs/python/methods/is-valid): Instance validation method. * [`NepaliDate.minimum()`](/docs/python/static/minimum): Earliest supported date boundary. --- ## Page: NepaliDate.maximum() (PYTHON) (/docs/python/static/maximum) Description: [PYTHON] Static method returning the maximum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for Python. The `maximum` static method returns a native Python datetime object representing the latest Gregorian date supported by the library calendar engine. This corresponds to the final day of Chaitra in year 2100 BS and serves as an upper bound for date validation and calendar limits. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def maximum() -> datetime: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `datetime` * **Value**: Gregorian UTC datetime corresponding to the last day of Chaitra in year `2100 BS` (mid April 2044 AD). --- ## Examples ```python from nepali_date_library import NepaliDate max_date = NepaliDate.maximum() print(f"Latest supported AD date: {max_date}") # Construct NepaliDate from the maximum boundary nd_max = NepaliDate(max_date) print(f"Latest BS date: {nd_max.format('YYYY-MM-DD')}") ``` --- ## Related * [`NepaliDate.minimum()`](/docs/python/static/minimum): Earliest supported date boundary. * [`NepaliDate.is_valid()`](/docs/python/static/is-valid): Check date bounds. --- ## Page: NepaliDate.minimum() (PYTHON) (/docs/python/static/minimum) Description: [PYTHON] Static method returning the minimum supported date boundary for the NepaliDate calendar engine. Official API reference and code examples for Python. The `minimum` static method returns a native Python datetime object representing the earliest Gregorian date supported by the library calendar engine. This corresponds to the first day of Baisakh in year 1976 BS and provides a reliable lower boundary for date pickers and form input validation. --- ## Import ```python from nepali_date_library import NepaliDate ``` --- ## Signature ```python @staticmethod def minimum() -> datetime: ``` --- ## Parameters * None. --- ## Return Value * **Type**: `datetime` * **Value**: Gregorian UTC datetime corresponding to `1976-01-01 BS` (mid April 1919 AD). --- ## Examples ```python from nepali_date_library import NepaliDate min_date = NepaliDate.minimum() print(f"Earliest supported AD date: {min_date}") # Construct NepaliDate from the minimum boundary nd_min = NepaliDate(min_date) print(f"Earliest BS date: {nd_min.format('YYYY-MM-DD')}") # "1976-01-01" ``` --- ## Related * [`NepaliDate.maximum()`](/docs/python/static/maximum): Latest supported date boundary. * [`NepaliDate.is_valid()`](/docs/python/static/is-valid): Validate date coordinates. ---