Code Monkey home page Code Monkey logo

persia-.net-core's Introduction

Persia.NET Core

Project Deprecated

Dear developers,

I would like to inform you that this project is now deprecated and will no longer be maintained or updated. We appreciate your support and contributions over the years.

I'm excited to announce that I have a new version of this class library, which includes several enhancements and new features. I encourage you to visit and use the new repository for the latest updates and improvements.

You can access the new repository at this link.

Thank you for your understanding and I look forward to your continued support on my new project.

Github tags

Persia .NET Core is a class library to convert Persian, Gregorian, and Arabic (Hijri) dates to each other. This library has been developed based on .NET Core and it is now compatible with .NET 7.0

License: MIT

Install via NuGet

To install Persia.NET Core, run the following command in the Package Manager Console:

Nuget

PM> Install-Package Persia.NetCore

You can also view the package page on NuGet.

Usage

Converting Gregorian to Shamsi

Persia.SolarDate solarDate = Persia.Calendar.ConvertToPersian(DateTime.Now);
// getting the simple format of persian date
string str = solarDate.ToString();
SolarDate Class Properties
Property Type Description
ArrayType Array of integers an array of 6 elements consisting of year, month, day, hour, minute and second
DayOfWeek int day number in week
DaysPast int days past from the beginning of Shamsi year
DaysRemain int days remain to the end of Shamsi year
IsLeapYear bool is the year is leap

SolarDate can display the date string as follow:

Output ToString param
1389/09/30 ToString()
89/09/30 ToString("L")
۱۳۸۹/۹/۳۰ ToString("D")
۸۹/۹/۳۰ ToString("d")
سی ام آذر ۱۳۸۹ ToString("F")
سی ام آذر ۸۹ ToString("f")
سه شنبه ۱۳۸۹/۹/۳۰ ToString("W")
سه شنبه ۸۹/۹/۳۰ ToString("w")
سه شنبه سی ام آذر ۱۳۸۹ ToString("S")
سه شنبه سی ام آذر ۸۹ ToString("s")
۳۰ آذر ۱۳۸۹ ToString("M")
۳۰ آذر ۸۹ ToString("m")
سه شنبه ۳۰ آذر ۱۳۸۹ ToString("N")
سه شنبه ۳۰ آذر ۸۹ ToString("n")
سه شنبه ۳۰ آذر ToString("g")
آذر ۱۳۸۹ ToString("E")
آذر ۸۹ ToString("e")
۳۰ آذر ToString("Q")
سی ام آذر ToString("q")
۱۹ : ۵۰ ToString("H")
ساعت ۱۹ : ۵۰ ToString("R")
۷ : ۵۰ بعد از ظهر ToString("HH")
۷ : ۵۰ ب. ظ ToString("hh")
ساعت ۷ : ۵۰ بعد از ظهر ToString("T")
ساعت ۷ : ۵۰ ب. ظ ToString("t")

Date and Time can be displayed together:

string str = solarDate.ToString("H,w");

ToRelativeDateString() is another method which display the date as the number of days past from the spesidic date. the following example:

string str = solarDate.c ("D,5");

shows days past from specific date up untill 5 days. The default number of days past is 30 days. Considering above example the complete output format of ToRelativeDateString() method are shown in table bellow.

Output Parameter
X روز پیش (پیش فرض 30 روز) ToRelativeDateString("D")
امروز ToRelativeDateString("T")
امروز، دیروز ToRelativeDateString("Y")
امروز، دیروز، x روز پیش (پیش فرض یک هفته) ToRelativeDateString("TY")
اکنون (کمتر از پنج دقیقه، پیش فرض پنج دقیقه) ToRelativeDateString("N")
X دقیقه پیش (کمتر از 60 دقیقه، پیش فرض 60 دقیقه) ToRelativeDateString("M")
X ساعت پیش (کمتر از 24 ساعت، پیش فرض 24 ساعت) ToRelativeDateString("H")
کمتر از یک ساعت پیش ToRelativeDateString("h")
کمتر از یک دقیقه پیش ToRelativeDateString("m")
اکنون، x دقیقه پیش ToRelativeDateString("n")
اکنون، x دقیقه پیش، x ساعت پیش ToRelativeDateString("p")
اکنون، x دقیقه پیش، امروز ToRelativeDateString("t")

Converting Shamsi to Gregorian

DateTime ConvertToGregorian(SolarDate solarDate)
DateTime ConvertToGregorian(LunarDate lunarDate)
DateTime ConvertToGregorian(int year, int month, int day, DateType dateType)
DateTime ConvertToGregorian(int year, int month, int day, int hour, int minute, int
second, DateType dateType)

Converting Shamsi to Arabic

LunarDate ConvertToIslamic(DateTime date)
LunarDate ConvertToIslamic(SolarDate solarDate)
LunarDate ConvertToIslamic(int year, int month, int day, DateType dateType)

LunarDate class has following properties:

Property Type Description
ArrayType Array of integers an array of 6 elements consisting of year, month, day, hour, minute and second
DayOfWeek int day number in week
IsLeapYear bool is the year is leap

LunarDate can display the date string as follow:

Output ToString param
1432/03/28 ToString()
۲۸ /۱۴۳۲/۳ ToString("H")
۲۸ ربیع الاول ۱۴۳۲ ToString("M")
پنجشنبه ۲۸ ربیع الاول ۱۴۳۲ ToString("D")
الخمیس ۲۸ ربیع الاول ۱۴۳۲ ToString("N")

Converting Latin numbers to Persian

String persianNumber = Persia.PersianWord.ConvertToPersianNumber("12345");

persia-.net-core's People

Contributors

shahabfar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.