PeymanMajdii.HijriPersianCalender 1.0.0

.NET 5.0
dotnet add package PeymanMajdii.HijriPersianCalender --version 1.0.0
NuGet\Install-Package PeymanMajdii.HijriPersianCalender -Version 1.0.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="PeymanMajdii.HijriPersianCalender" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PeymanMajdii.HijriPersianCalender --version 1.0.0
#r "nuget: PeymanMajdii.HijriPersianCalender, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install PeymanMajdii.HijriPersianCalender as a Cake Addin
#addin nuget:?package=PeymanMajdii.HijriPersianCalender&version=1.0.0

// Install PeymanMajdii.HijriPersianCalender as a Cake Tool
#tool nuget:?package=PeymanMajdii.HijriPersianCalender&version=1.0.0

Hijri Persian Calender Initializer

Every usage of DateTime becomes to Hijri simply by initializing the culture


Initilize persian culture means every usage of DateTime becomes to Hijri and there is no any concern and extra job needed. Simply print datetime in Hijri by DateTime.Now or in SQL Server Transactions. Persian Calender as default date/time culture.

Convert every use of DateTime to Persion Culture Even SQL Server Transactions


Persian Hint: تبدیل کلیه تاریخ ها به هجری شمسی با یکبار فراخوانی اولیه این فایل

How it works

ASP.Net Core & ASP.Net 5+

Solution Explorer > Startup.cs

         public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            Cultures.InitializePersianCulture(); // <----------------+ add these lines
            app.UseRequestLocalization();        // <----+


ASP.Net MVC Projects

Solution Explorer > Global.asax.cs

        protected void Application_Start()
            Cultures.InitializePersianCulture(); // <----------------- add this line


C# Console Projects

Solution Explorer > Program.cs

     private static void Main()
            Cultures.InitializePersianCulture(); // <------------------ add this line


Print the current date

      var today = DateTime.Now;
      Console.WriteLine(today.ToLongDateString()); // 1400 شهریور 27, شنبه
      var year = today.Year;  // =1400

Sql Server Queris

  var today_books = _context.Books.Where(p=>p.RegisterDate.Date == DateTime.Now.Date);  // fetch books registered today
  foreach(var book in books)
        print(book.RegisterDate);  // 1400 شهریور 27, شنبه
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

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.0 465 9/18/2021