NepaliCalendarToolkit 1.2.0
dotnet add package NepaliCalendarToolkit --version 1.2.0
NuGet\Install-Package NepaliCalendarToolkit -Version 1.2.0
<PackageReference Include="NepaliCalendarToolkit" Version="1.2.0" />
<PackageVersion Include="NepaliCalendarToolkit" Version="1.2.0" />
<PackageReference Include="NepaliCalendarToolkit" />
paket add NepaliCalendarToolkit --version 1.2.0
#r "nuget: NepaliCalendarToolkit, 1.2.0"
#:package NepaliCalendarToolkit@1.2.0
#addin nuget:?package=NepaliCalendarToolkit&version=1.2.0
#tool nuget:?package=NepaliCalendarToolkit&version=1.2.0
Nepali Calendar Toolkit
This NuGet package provides a comprehensive toolkit for handling Nepali calendar dates, including Nepali public holidays and weekends from 2065 BS - 2082 BS.
Features
- Convert between Nepali (Bikram Sambat) and Gregorian (AD) dates
- Get Nepali public holidays
- Calculate weekends for Nepali dates
- Work with Nepali fiscal years (starts on Shrawan 1st and ends on Ashar end)
- Get date ranges for Nepali months, quarters, and fiscal years
- JSON-based holiday data storage
Installation
Install-Package NepaliCalendarToolkit
Or using the .NET CLI:
dotnet add package NepaliCalendarToolkit
Usage
Get Holidays and Weekends
// Get all holidays and weekends for a specific year
var holidaysAndWeekends = NepaliCalendarConverter.GetHolidaysAndWeekends(2080);
// Get only holidays for a specific month in a year
var holidays = NepaliCalendarConverter.GetHolidaysAndWeekends(2080, 1, HolidayOrWeekendEnum.Holidays);
// Get only weekends for a specific month in a year
var weekends = NepaliCalendarConverter.GetHolidaysAndWeekends(2080, 1, HolidayOrWeekendEnum.Weekends);
Get Available Date Ranges
// 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 Weekend Days
// 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();
Date Conversion
// Convert from Nepali date to Gregorian date
var nepaliDate = new NepaliDate(2080, 1, 1);
var gregorianDate = NepaliCalendarConverter.ConvertToAD(nepaliDate);
// Convert from Gregorian date to Nepali date
var gregorianDate = new DateTime(2023, 4, 14);
var nepaliDate = NepaliCalendarConverter.ConvertToNepali(gregorianDate);
Fiscal Year Operations
// 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);
Data Source
The toolkit now fetches data from a CDN hosted at https://cdn.jsdelivr.net/gh/shoesheill/shiranai-deto/. This includes:
- Holiday data from 2065 BS
- Month lengths data for Nepali calendar calculations
- Year start dates for Nepali calendar
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.
Holiday Data Structure
The holiday data is stored in JSON format with the following structure:
[
{
"month": 1,
"day": 11,
"date": "2008-04-23",
"name": "Loktantra Diwas"
}
// More holidays...
]
Each year has its own JSON file named with the BS year (e.g., "2080.json").
License
This project is licensed under the MIT License - see the LICENSE file for details.
Methods
1. ConvertToNepali
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
}
2. ConvertToAD
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
3. GetStartAndEndDateInAD
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"
}
4. GetQuarterDateRangeInAD
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"
}
5. GetMonthRangeDateInAD
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"
}
6. GetWeekDateInAd
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"
}
7. GetHolidaysAndWeekends
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 2080
8. GetFiscalYearDateRangeInAD
Description: 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"
}
9. GetHolidaysAndWeekendsForFiscalYear
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
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.2)
-
.NETStandard 2.1
- System.Text.Json (>= 8.0.2)
-
net9.0
- System.Text.Json (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release.