NepDate 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NepDate --version 1.0.1                
NuGet\Install-Package NepDate -Version 1.0.1                
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="NepDate" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NepDate --version 1.0.1                
#r "nuget: NepDate, 1.0.1"                
#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.
// Install NepDate as a Cake Addin
#addin nuget:?package=NepDate&version=1.0.1

// Install NepDate as a Cake Tool
#tool nuget:?package=NepDate&version=1.0.1                

LogoWhiteCropped

Nuget GitHub Repo Stars

Features

Initialization

By nepali year, month, and day values
using NepDate;

var nepDate = new NepaliDate(2079, 12, 16);
By Nepali date as a string
using NepDate;

var nepDate = new NepaliDate("2079/12/16");
// or
var nepDate = NepaliDate.Parse("2079/12/16");
By English DateTime
using NepDate;

var nepDate = new NepaliDate(DateTime.Now);
// or
var nepDate = DateTime.Now.ToNepaliDate();
By Nothing
using NepDate;

var nepDate = NepaliDate.Now; // Initializes NepaliDate object with current Nepali date

Properties

using NepDate;

var nepDate = new NepaliDate("2079/12/16");

// get the Nepali year, month, and day values
var year = nepDate.Year;
var month = nepDate.Month;
var day = nepDate.Day;

// get the equivalent English date as a DateTime
var englishDate = nepDate.EnglishDate;

// get the day of the week as a DayOfWeek enum value
var dayOfWeek = nepDate.DayOfWeek;

// get the last day of the month as an integer value
var monthEndDay = nepDate.MonthEndDay;

// get the last day of the month as a NepaliDate object
var monthEndDate = nepDate.MonthEndDate;

Additional Funtions

using NepDate;

var nepDate = DateTime.Now.ToNepaliDate();

// get the equivalent Nepali date as string
var nepDateAsString = nepDate.ToString();

// determine if the Nepali year is a leap year
var isLeapYear = nepDate.IsLeapYear();

// add or subtract days from a Nepali date
var newDate = nepDate.AddDays(10);

// subtract two Nepali dates to get a TimeSpan object
var nepDate2 = new NepaliDate("2080/12/16");
var timeSpan = nepDate2 - nepDate;
// or
var timeSpan = nepDate2.Subtract(nepDate);

// check if a string is a valid Nepali date and convert it to a NepaliDate object
if (NepaliDate.TryParse("2079/13/16", out var result))
{
    // use the result NepaliDate object
}

Comparing NepaliDate objects

using NepDate;

var nepDate = NepaliDate.Parse("2079/12/16");
var nepDate2 = DateTime.Now.ToNepaliDate();

if (nepDate == nepDate2)
{
    // the two NepaliDate objects are equal
}

if (nepDate < nepDate2)
{
    // nepDate is earlier than nepaliDate2
}

if (nepDate > nepDate2)
{
    // nepDate is after nepaliDate2
}

// etc

You just need the conversion?

using NepDate;

// Convert a DateTime directly to a NepaliDate string
var convertedToBS = DateTime.Now.ToNepaliDate().ToString();

// Convert a NepaliDate string directly to a DateTime
var convertedToAD = NepaliDate.Parse("2079/12/16").EnglishDate;

Performance

NepDate is distinguished by its capacity to perform with exceptional speed while utilizing minimal runtime memory resources. The metrics presented below exemplify NepDate's remarkable efficiency and proficiency, while remaining mindful of resource consumption.

The benchmarks can be found in NepDate.Benchmarks & NepDate.DotNetFrameworkBench

Output from latest run is:

BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1413/22H2/2022Update/SunValley2)
Intel Core i5-10400 CPU 2.90GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK=7.0.200
  [Host]     : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
  DefaultJob : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
Method Mean Error StdDev Rank Gen0 Gen1 Allocated
GetEngDate_NepDate 62.59 ns 0.295 ns 0.261 ns 1 - - -
GetNepDate_NepDate 276.83 ns 0.593 ns 0.526 ns 2 0.0191 - 120 B
GetEngDate_NepaliDateConverter_NETCORE 63,460.38 ns 54.052 ns 42.201 ns 3 3.1738 0.1221 20176 B
GetNepDate_NepaliDateConverter_NETCORE 186,610.23 ns 420.217 ns 350.901 ns 7 3.1738 - 20160 B
GetEngDate_NepaliCalendarBS 99,511.43 ns 247.038 ns 231.080 ns 5 25.3906 - 159328 B
GetNepDate_NepaliCalendarBS 113,258.50 ns 364.280 ns 340.748 ns 6 25.2686 - 158760 B
GetEngDate_NepaliDateConverter_Net 75,327.75 ns 269.244 ns 251.851 ns 4 3.1738 0.1221 20176 B
GetNepDate_NepaliDateConverter_Net 212,478.96 ns 4,192.698 ns 5,877.576 ns 8 3.1738 - 20160 B
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1413/22H2/2022Update/SunValley2)
Intel Core i5-10400 CPU 2.90GHz, 1 CPU, 12 logical and 6 physical cores
  [Host]     : .NET Framework 4.8.1 (4.8.9139.0), X86 LegacyJIT
  DefaultJob : .NET Framework 4.8.1 (4.8.9139.0), X86 LegacyJIT
Method_Plugin Mean Error StdDev Rank Gen0 Gen1 Allocated
GetEngDate_NepDate 121.8 ns 0.15 ns 0.14 ns 1 - - -
GetNepDate_NepDate 896.6 ns 3.16 ns 2.80 ns 2 0.0782 - 413 B
GetEngDate_NepaliDateConverter 2,086.9 ns 4.13 ns 3.86 ns 3 0.5608 0.0038 2948 B
GetNepDate_NepaliDateConverter 3,925.9 ns 32.39 ns 30.30 ns 4 0.5798 - 3041 B
GetEngDate_NepaliCalendar 169,622.5 ns 377.10 ns 334.29 ns 5 - - 230 B
GetNepDate_NepaliCalendar 488,003.8 ns 1,433.94 ns 1,271.15 ns 6 - - 312 B
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. 
.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 was computed. 
.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.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NepDate:

Package Downloads
NEAPES.UI.Components

NEAPES UI Components are enterprise-grade, reusable components that help Blazor developers build full-stack applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.2 126 11/19/2024
2.0.1 226 9/16/2024
2.0.0 468 3/31/2024
1.2.0 770 4/22/2023
1.1.0 212 4/14/2023
1.0.1 185 4/13/2023
1.0.0 241 4/13/2023