NepDate 1.1.0

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

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

LogoWhiteCropped

GitHub Repo Stars

Package

Package NuGet Stable Downloads
NepDate NepDate NepDate

Installation

Install NepDate with the package manager console

NuGet\Install-Package NepDate

Install NepDate with the .NET CLI

dotnet add package NepDate

Features

NepDate is a struct based on .NET Standard 2.0 that closely resembles the DateOnly struct in .NET. It stands out due to its easy integration, super-fast and memory-efficient conversions, and built in powerful features related to Nepali date functionality.

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;

// get the name of the month as a NepaliMonths enum
var monthName = nepDate.MonthName;

Additional Functions

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

// get next month as a NepDate object
var nextMonth = nepDate.NextMonth();

// get previous month as a NepDate object
var nextMonth = nepDate.PreviousMonth();

// 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
Package Method Mean (ns) Error (ns) StdDev (ns) Rank Allocated (B)
NepDate BS -> AD 62.59 0.295 0.261 1️⃣ -
NepDate AD -> BS 276.83 0.593 0.526 2️⃣ 120
NepaliDateConverter.NETCORE BS -> AD 63,460.38 54.052 42.201 3️⃣ 20176
NepaliDateConverter.NETCORE AD -> BS 186,610.23 420.217 350.901 7️⃣ 20160
NepaliCalendarBS BS -> AD 99,511.43 247.038 231.080 5️⃣ 159328
NepaliCalendarBS AD -> BS 113,258.50 364.280 340.748 6️⃣ 158760
NepaliDateConverter.Net BS -> AD 75,327.75 269.244 251.851 4️⃣ 20176
NepaliDateConverter.Net AD -> BS 212,478.96 4,192.698 5,877.576 8️⃣ 20160
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
Package Method Mean (ns) Error (ns) StdDev (ns) Rank Allocated (B)
NepDate BS -> AD 121.8 0.15 0.14 1️⃣ -
NepDate AD -> BS 896.6 3.16 2.80 2️⃣ 413
NepaliDateConverter BS -> AD 2,086.9 4.13 3.86 3️⃣ 2948
NepaliDateConverter AD -> BS 3,925.9 32.39 30.30 4️⃣ 3041
NepaliCalendar BS -> AD 169,622.5 377.10 334.29 5️⃣ 230
NepaliCalendar AD -> BS 488,003.8 1,433.94 1,271.15 6️⃣ 312

Contributions

Please view the CONTRIBUTING guide for more information.

Contributors

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 170 11/19/2024
2.0.1 247 9/16/2024
2.0.0 475 3/31/2024
1.2.0 786 4/22/2023
1.1.0 214 4/14/2023
1.0.1 187 4/13/2023
1.0.0 243 4/13/2023