PersianCultureInitializer 1.0.1

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

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

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

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, شنبه
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
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.1 522 9/19/2021