NepaliCalendarToolkit 1.0.2

dotnet add package NepaliCalendarToolkit --version 1.0.2
                    
NuGet\Install-Package NepaliCalendarToolkit -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NepaliCalendarToolkit" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NepaliCalendarToolkit" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="NepaliCalendarToolkit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NepaliCalendarToolkit --version 1.0.2
                    
#r "nuget: NepaliCalendarToolkit, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=NepaliCalendarToolkit&version=1.0.2
                    
Install NepaliCalendarToolkit as a Cake Addin
#tool nuget:?package=NepaliCalendarToolkit&version=1.0.2
                    
Install NepaliCalendarToolkit as a Cake Tool

Nepali Calendar Toolkit

This NuGet package provides a comprehensive toolkit for handling Nepali calendar dates, including Nepali public holidays and weekends from 2065 BS - 2081 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

Initialize Holiday JSON Files (Optional)

// Call this once at application startup if you want to use JSON files
NepaliCalendarConverter.InitializeHolidayJsonFiles();

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);

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);

Holiday Data Structure

The toolkit now stores holiday data in JSON files (in the Data/Holidays directory) 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. 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

7. 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"
}

8. 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 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 49 3 days ago
1.0.1 194 2 months ago
1.0.0 109 2 months ago

Initial release.