PeymanMajdii.HijriPersianCalender 1.0.0

Install-Package PeymanMajdii.HijriPersianCalender -Version 1.0.0
dotnet add package PeymanMajdii.HijriPersianCalender --version 1.0.0
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Hijri Persian Calender Initializer

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

Culture_Hijri

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

Screenshot

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

Usage

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, شنبه
  • 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 258 9/18/2021