Beyond conversion: This toolkit made easy – configurable weekends, holidays, and date ranges for months, quarters, fiscal years, or any custom period.
$ dotnet add package NepaliCalendarToolkitBeyond conversion: This toolkit made easy – configurable weekends, holidays, and date ranges for months, quarters, fiscal years, or any custom period.
Install-Package NepaliCalendarToolkit
Or using the .NET CLI:
dotnet add package NepaliCalendarToolkit
// Get all holidays and weekends for a specific year
var holidaysAndWeekends = NepaliCalendarConverter.GetHolidaysAndWeekends(2082);
// Get only holidays for a specific month in a year
var holidays = NepaliCalendarConverter.GetHolidaysAndWeekends(2082, 1, HolidayOrWeekendEnum.Holidays);
// Get only weekends for a specific month in a year
var weekends = NepaliCalendarConverter.GetHolidaysAndWeekends(2082, 1, HolidayOrWeekendEnum.Weekends);
// Get the year range for which holiday data is available
var (minHolidayYear, maxHolidayYear) = NepaliCalendarConverter.GetAvailableHolidayYearsBS();
// Example output: minHolidayYear: 2065, maxHolidayYear: 2083
// Get the supported Nepali calendar year range
var (minCalendarYear, maxCalendarYear) = NepaliCalendarConverter.GetAvailableCalendarYearsBS();
// Example output: minCalendarYear: 2065, maxCalendarYear: 2083
// Configure just Saturday as a weekend day
NepaliCalendarConverter.ConfigureWeekendDays(DayOfWeek.Saturday);
// Configure both Saturday and Sunday as weekend days (default)
NepaliCalendarConverter.ConfigureWeekendDays(DayOfWeek.Saturday, DayOfWeek.Sunday);
// Configure Friday and Saturday as weekend days
NepaliCalendarConverter.ConfigureWeekendDays(DayOfWeek.Friday, DayOfWeek.Saturday);
// Get the currently configured weekend days
DayOfWeek[] weekendDays = NepaliCalendarConverter.GetConfiguredWeekendDays();
// Convert from Nepali date to Gregorian date
var nepaliDate = new NepaliDate(2082, 1, 1);
var gregorianDate = NepaliCalendarConverter.ConvertToAD(nepaliDate);
// Convert from Gregorian date to Nepali date
var gregorianDate = new DateTime(2025, 4, 14);
var nepaliDate = NepaliCalendarConverter.ConvertToNepali(gregorianDate);// Get date range for a Nepali fiscal year
var fiscalYearRange = NepaliCalendarConverter.GetFiscalYearDateRangeInAD(2080);
// Result: StartDate: 2023-07-17, EndDate: 2024-07-15
// Get holidays for a fiscal year
var fiscalYearHolidays = NepaliCalendarConverter.GetHolidaysAndWeekendsForFiscalYear(2080);The toolkit now fetches data from a CDN hosted at Nepali-Calendar-Data. This includes:
The data is automatically fetched when needed and cached for performance. If the CDN is unavailable, the toolkit falls back to hardcoded values for basic functionality.
The holiday data is stored in JSON format with the following structure:
[
{
"month": 1,
"day": 11,
"date": "2008-04-23",
"name": "Loktantra Diwas"
}
]Each year has its own JSON file named with the BS year (e.g., "2080.json").
This project is licensed under the MIT License - see the LICENSE file for details.
Description: Converts date in AD (DateTime) to a Nepali date (NepaliDate).
Implementation:
DateTime dateInAD = new DateTime(2024, 10, 1);
NepaliDate nepaliDate = NepaliCalendarConverter.ConvertToNepali(dateInAD);Response:
{
"Year": 2081,
"Month": 6,
"Day": 15
}Description: Converts a Nepali date (NepaliDate) to a Gregorian date (DateTime).
Implementation:
csharp
NepaliDate nepaliDate = new NepaliDate { Year = 2080, Month = 6, Day = 15 };
DateTime dateInAD = NepaliCalendarConverter.ConvertToAD(nepaliDate);2023-10-01 00:00:00
Description: Retrieves the start and end dates in AD for a given Nepali year and month.
Implementation:
var dateRange = NepaliCalendarConverter.GetStartAndEndDateInAD(2080, 6);Response:
{
"StartDate": "2023-09-17",
"EndDate": "2023-10-16"
}Description: Retrieves the start and end dates in AD for a given Nepali year and quarter.
Implementation:
var quarterRange = NepaliCalendarConverter.GetQuarterDateRangeInAD(2080, 1);Response:
{
"StartDate": "2023-07-01",
"EndDate": "2023-09-30"
}Description: Retrieves the start and end dates in AD for a specified range of Nepali months.
Implementation:
var monthRange = NepaliCalendarConverter.GetMonthRangeDateInAD(2080, 6, 8);Response:
{
"StartDate": "2023-09-17",
"EndDate": "2023-11-15"
}Description: Retrieves the start and end dates in AD for a specific week within a Nepali month.
Implementation:
// Get the date range for the 2nd week of Asoj month, 2080 BS
var weekRange = NepaliCalendarConverter.GetWeekDateInAd(2080, 6, 2);Response:
{
"StartDate": "2023-09-24",
"EndDate": "2023-09-30"
}Description: Retrieves a list of holidays and weekends for a specified year and optional month.
Implementation:
var holidays = NepaliCalendarConverter.GetHolidaysAndWeekends(2080);Response:
List<HolidayInfo> { ... } // Contains holiday information for the year 2080Description: Retrieves the start and end dates in AD for a given Nepali fiscal year.
Implementation:
var fiscalYearRange = NepaliCalendarConverter.GetFiscalYearDateRangeInAD(2080);Response:
{
"StartDate": "2023-07-17",
"EndDate": "2024-07-15"
}Description: Retrieves a list of holidays and weekends for a specified fiscal year.
Implementation:
var fiscalYearHolidays = NepaliCalendarConverter.GetHolidaysAndWeekendsForFiscalYear(2080);Response:
List<HolidayInfo> { ... } // Contains holiday information for the fiscal year 2080-81