PersianCultureInitializer 1.0.1

.NET 5.0
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 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 net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.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.1 311 9/19/2021