Skip to content

Persian Data Library is a library that can be converted Gregorian (Milady) year to Solar Hijri (Shamsi) year in the simplest way!

Notifications You must be signed in to change notification settings

hootanht/PersianDate

Repository files navigation

Persian Date Library

Persian Date Library

Persian Data Library is a library that can be convert Gregorian (Milady) year to Solar Hijri (Shamsi) year in simplest way!


Target Branch Version
Github master v1.0.5

Persian Date Public Version

Target Branch Version Download link Total downloads CI Build Status CD Build Status
Nuget master v1.0.6 NuGet NuGet downloads Build Status Build Status
Release master v1.0.5 Build Status Build Status Build Status

Cross Platform

Platform Supported Version
.NET 8.0

Code Example

PersianDateShamsi persianDateShamsi = new PersianDateShamsi();
    
    Console.WriteLine(persianDateShamsi.GetShamsiYear(DateTime.Now));
    //Result : 1398
    
    Console.WriteLine(persianDateShamsi.GetShamsiMonthName(DateTime.Now));
    //Result : بهمن
    
    Console.WriteLine(persianDateShamsi.GetShamsiDayString(DateTime.Now));
    //Result : 03
    
    Console.WriteLine(persianDateShamsi.GetShamsiDayName(DateTime.Now));
    //Result : پنجشنبه
    
    Console.WriteLine(persianDateShamsi.GetShamsiDayShortName(DateTime.Now));
    //Result : پ

Extension Method For DateTime

    Console.WriteLine(DateTime.Now.ToShamsiDate());
    //Result : 1398/11/03
    
    Console.WriteLine(DateTime.Now.ToShortShamsiDate());
    //Result : 98/11/03
    
    Console.WriteLine(DateTime.Now.ToLongShamsiDate());
    //Result : پنجشنبه 3 بهمن 1398

Version changes

Version 1.0.6

-Add support for .Net 8.0

Version 1.0.4

-Add support for .Net 5.0 and 6.0

Version 1.0.3

-Change .Net Standard 2.0 To .NET 7.0

Version 1.0.2

-Improve Flexibility

Version 1.0.1

-Change .Net Standard 2.1 To 2.0 To Support More Platforms

CI Pipeline

The CI pipeline is now integrated into the CD pipeline and is defined in .github/workflows/CI.yml. It uses macos-latest as the VM image. The pipeline handles manual triggers, pull requests, and releases. It restores NuGet packages, builds the solution, runs tests, and validates the NuGet package. The pipeline installs .NET version 8.0.x to ensure compatibility with all targeted frameworks.

CD Pipeline

The CD pipeline is defined in .github/workflows/CD.yml and uses macos-latest as the VM image. It includes steps for creating, validating, testing, and deploying the NuGet package. The pipeline handles manual triggers, pull requests, and releases. It uses environment variables for the NuGet directory and the latest versions of GitHub Actions for checkout, setup-dotnet, and upload-artifact. The pipeline installs .NET version 8.0.x to ensure compatibility with all targeted frameworks. Additionally, it includes a step to delete existing tags if they already exist before creating a new release to avoid the 'Validation Failed: already_exists' error. The step now handles the case where the tag deletion fails and ensures the deletion step successfully removes the existing tag before proceeding to create a new release.

Requirements

  • .NET 8.0 SDK

Setup and Run

  1. Install .NET 8.0 SDK: Download and install the .NET 8.0 SDK from the official .NET website.

  2. Restore Dependencies: Open a terminal or command prompt in the project directory and run:

    dotnet restore
  3. Build the Project: Build the project by running:

    dotnet build
  4. Run Tests: Run the tests to ensure everything is working correctly:

    dotnet test