Click here to Skip to main content
15,392,858 members
Articles / Programming Languages / C# 4.0
Posted 3 Feb 2007


31 bookmarked

Persian DateTime

Rate me:
Please Sign up or sign in to vote.
3.47/5 (25 votes)
25 Apr 2011CPOL
A structure like System.DateTime which is designed to support Persian calendar


After a long time, I updated this article again. (Happy!!!)

Since the time I can remember, lack of a class or struct to support Persian calendar in programming languages was one of my big problems. Up to the language I was using, I tried to solve this problem with different solutions. But none of them is an absolute solution.

This problem was almost solved in .NET 2.0 by a class named PersianCalendar, but it was not the complete way. So I decided to create a class like System.DateTime.


PersianDateTime is a very simple struct which gives us simple support for Persian DateTime. I'm trying to develop and update it. Therefore it would be great if you leave your suggestions to help me complete it.

Using the Code

A few examples can be found in the source code.

PersianDateTime can be used in two ways: Staticly and instanciately. I mean you can use it with/without an instance:



PersianDateTime persianDateTime = new PersianDateTime(DateTime.Now);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mohammad Mir mostafa
Architect Iran
Iran (Islamic Republic of) Iran (Islamic Republic of)
No Biography provided

Comments and Discussions

Questionnice! Pin
Abbas Keshvari1-May-14 0:21
MemberAbbas Keshvari1-May-14 0:21 
QuestionHow to use it in project Pin
Majid Basirati1-Aug-13 10:58
MemberMajid Basirati1-Aug-13 10:58 
AnswerRe: How to use it in project Pin
Mohammad Dayyan27-Dec-14 20:00
MemberMohammad Dayyan27-Dec-14 20:00 
Questionshamsi Date to miladi Pin
Marziyeh Eslampanah20-Oct-12 0:16
MemberMarziyeh Eslampanah20-Oct-12 0:16 
AnswerRe: shamsi Date to miladi Pin
Mohammad Dayyan3-Jan-15 18:48
MemberMohammad Dayyan3-Jan-15 18:48 
QuestionSuggestion: Please use better names! Pin
Flomenol7-Apr-12 3:20
MemberFlomenol7-Apr-12 3:20 
AnswerRe: Suggestion: Please use better names! Pin
Mohammad Mir mostafa8-Apr-12 23:23
MemberMohammad Mir mostafa8-Apr-12 23:23 
QuestionCode Usage Pin
Member 827970830-Sep-11 9:53
MemberMember 827970830-Sep-11 9:53 
AnswerRe: Code Usage Pin
Mohammad Dayyan3-Jan-15 18:50
MemberMohammad Dayyan3-Jan-15 18:50 
Questionthankful for you Pin
amir 21-Aug-11 22:10
Memberamir 21-Aug-11 22:10 
Generalhi Pin
raha_45524-Feb-11 2:53
Memberraha_45524-Feb-11 2:53 
GeneralMy vote of 5 Pin
Sayyed Mostafa Hashemi21-Dec-10 3:50
MemberSayyed Mostafa Hashemi21-Dec-10 3:50 
GeneralMonth names Pin
Kamran Behzad14-Jun-10 19:01
MemberKamran Behzad14-Jun-10 19:01 
GeneralRe: Month names Pin
Mohammad Mir mostafa14-Jun-10 23:37
MemberMohammad Mir mostafa14-Jun-10 23:37 
GeneralAddDays Pin
shervin12-Mar-10 18:20
Membershervin12-Mar-10 18:20 
GeneralRe: AddDays Pin
Mohammad Dayyan3-Jan-15 18:51
MemberMohammad Dayyan3-Jan-15 18:51 
GeneralBut Pin
Member 671450114-Nov-09 23:56
MemberMember 671450114-Nov-09 23:56 
GeneralRe: But Pin
Mohammad Mir mostafa16-Nov-09 2:34
MemberMohammad Mir mostafa16-Nov-09 2:34 
Generaltank you Pin
s_ahmadneya30-Dec-08 1:03
Members_ahmadneya30-Dec-08 1:03 
GeneralThank You Pin
Rf0119-Sep-08 20:40
MemberRf0119-Sep-08 20:40 
GeneralThanks Pin
B.Farivar8-Jul-08 23:54
MemberB.Farivar8-Jul-08 23:54 
GeneralC sharp Code Generator Pin
Hemant.Kamalakar19-Sep-07 4:34
MemberHemant.Kamalakar19-Sep-07 4:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.