NuGet Version NuGet Downloads GitHub Stars MIT License

NepDate - Bikram Sambat Nepali Date Conversion for .NET, done right.

NepDate is a zero-dependency, stack-allocated struct that brings nanosecond Bikram Sambat conversions, smart parsing, fiscal year math, and rich calendar metadata to every .NET application.

0.8nsBS → AD
41,800×Faster
0BAllocations
1901–2199Year Range
Installation

Get started in seconds

One command, zero configuration. Works on .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5 and later, Xamarin, Unity, and MAUI.

dotnet add package NepDate
Install-Package NepDate
<PackageReference Include="NepDate" Version="2.1.0" />
Features

Everything you need. Nothing you don't.

One lightweight package with full coverage of Bikram Sambat date operations, built to the same quality bar as System.DateTime.

Blazing Fast

Up to 41,800× faster than other Nepali date libraries. Zero heap allocations on both conversion paths. Under 1 ns BS → AD, under 3 ns AD → BS.

Bidirectional Conversion

Convert between Bikram Sambat and Gregorian in nanoseconds. Both directions, fully supported.

Smart Parsing

Accepts 100+ month-name spellings, Nepali Unicode digits, alternate separators, and short-year inputs.

Rich Formatting

Custom format tokens, Unicode Devanagari digits, long-form Nepali strings, and full IFormattable support.

Fiscal Year Operations

Nepal FY (Shrawan–Ashadh) quarter and boundary calculations, both instance and static.

Calendar Metadata

Built-in Tithi, public holiday flag, and event data in Nepali and English: tithi for 2078-2083 BS, events and holidays for 2077-2083 BS (plus a few days of 2084).

Date Range Operations

Intersection, union, split by month or fiscal quarter, working days, and interval iteration.

Serialization

System.Text.Json, Newtonsoft.Json, and XML. String and object modes. Zero config on .NET 8+.

First-Class .NET Type

IFormattable, IComparable, IEquatable, IParsable, ISpanFormattable, TypeConverter, JsonConverter. Behaves like DateTime.

Zero Dependencies

No external runtime dependencies. Lightweight, self-contained, single-package install.

Bulk Conversion

Converts whole collections in one pass, in input order, at a few nanoseconds per date.

Struct by Design

readonly partial struct keeps instances on the stack and eliminates GC pressure in high-volume workloads.

Performance

Benchmarked, not just advertised

One flat month table for O(1) lookups and zero heap allocations on both conversion paths. Measured with BenchmarkDotNet on NepDate 2.1.0: every call converts a different date, so no result can be precomputed.

BS → AD (NepDate)
0.78 ns
vs 32,665 ns · up to 41,865× faster
AD → BS (NepDate)
2.73 ns
vs 67,715 ns · up to 24,770× faster
Allocations
0 B
on every conversion, both directions

BS → AD Nepali to English

Library Mean Ratio Allocated
NepDate
0.78 ns
1.00× 0 B
NepaliCalendarBS
14.77 µs
18,933× 688 B
NepaliDateConverter.Net
31.84 µs
40,812× 20,016 B
NepaliDateConverter.NETCORE
32.66 µs
41,865× 20,736 B

AD → BS English to Nepali

Library Mean Ratio Allocated
NepDate
2.73 ns
1.00× 0 B
NepaliCalendarBS
183.3 ns
67× 32 B
NepaliDateConverter.Net
65.30 µs
23,888× 20,016 B
NepaliDateConverter.NETCORE
67.72 µs
24,770× 20,736 B

NepDate 2.1.0 vs 2.0.7 Release over release

Operation 2.0.7 2.1.0 Faster Allocated
BS → AD6.05 ns0.80 ns7.5×0 B
AD → BS13.65 ns2.72 ns5.0×0 B
Add 1,000 days14.69 ns2.07 ns7.1×0 B
Add 13 months17.39 ns1.75 ns9.9×0 B
Strict parse19.92 ns5.50 ns3.6×0 B
ToString()13.37 ns11.34 ns1.2×96 B → 48 B
Long Nepali date with weekday145.7 ns27.7 ns5.3×435 B → 69 B
Calendar info for a day109.4 ns13.6 ns8.0×50 B
Bulk convert 1,000 dates36.6 µs4.0 µs9.1×141 KB → 8 KB

BenchmarkDotNet 0.15.8 · NepDate 2.1.0 · .NET 10.0.12 (X64 RyuJIT, AVX2) · 12th Gen Intel Core i5-12500H 3.10 GHz, Windows 11, one pinned core. Each call converts a different date from a pool of 1,024 (2070–2085 BS). Smaller is better. Bars are scaled to the slowest method per category.

Comparison

How NepDate compares

A head-to-head feature matrix against the best-known Nepali date libraries on NuGet.

Feature NepDate NepaliDateConverter NepaliCalendarBS
BS → AD Conversion✓✓✓
AD → BS Conversion✓✓✓
Zero-allocation BS → AD✓✗✗
Smart multi-format parsing✓✗✗
Nepali Unicode digit support✓✗✗
Fiscal year operations✓✗✗
Date range operations✓✗✗
Tithi, holidays & events✓✗✗
Bulk conversion✓✗✗
JSON serialization✓✗✗
XML serialization✓✗✗
IFormattable / IComparable✓✗✗
TypeConverter (model binding)✓✗✗
.NET Standard 2.0✓✓✓
Actively maintained✓~~
FAQ

Frequently asked questions

NepDate targets .NET Standard 2.0, which means it works with .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5 and later, Xamarin, Unity, and MAUI. It also ships a net8.0 target for newer API features like IParsable and ISpanFormattable.

NepDate supports Bikram Sambat dates from 1901/01/01 BS (1844-04-11 AD) to the last day of 2199/12 BS (2143-04-15 AD). Tithi is available for 2078 through 2083 BS, events and public holidays for 2077 through 2083 BS (plus a few days of 2084).

No. NepDate has no NuGet dependencies. Newtonsoft.Json and System.Text.Json are referenced with PrivateAssets=all, so they are not added to your project. To call ConfigureForNepaliDate(), reference Newtonsoft.Json and, outside .NET 8 and later, System.Text.Json 8.0.5 or later; adding a converter class directly needs only its own library.

Yes. NepaliDate is a readonly struct, making it inherently immutable and safe for concurrent access. BulkConvert operations are safe to call from several threads.

Constructors and Parse throw InvalidNepaliDateFormatException or ArgumentOutOfRangeException for invalid input. Use TryParse for non-throwing validation. Each month's day count is enforced per year (29 to 32 days depending on month and year).

Yes. NepaliDate has a registered TypeConverter that enables automatic model binding in ASP.NET MVC/Web API, WPF, and WinForms property grids. It converts to/from string, int (YYYYMMDD), and DateTime.

Calendar data is compiled from authoritative Bikram Sambat calendar references and cross-verified for accuracy. Tithi is available for 2078 through 2083 BS, events and public holidays for 2077 through 2083 BS (plus a few days of 2084). The data is compiled into the library at build time. Properties return empty/default values for other dates without throwing exceptions.

NepaliDate is a readonly partial struct, which means instances live on the stack rather than the heap. This eliminates garbage collection pressure and makes it extremely efficient for high-throughput scenarios like bulk date processing, large LINQ pipelines, and server-side batch jobs.

Community

Built by contributors like you

NepDate is open source and welcomes pull requests, bug reports, and ideas from anyone.