Click here to Skip to main content
15,880,651 members
Articles / Programming Languages / C# 4.0

Persian DateTime

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

Introduction

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.

Background

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:

C#
Console.WriteLine(PersianDateTime.Now);

or:

C#
PersianDateTime persianDateTime = new PersianDateTime(DateTime.Now);

License

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


Written By
Architect Iran
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionshamsi Date to miladi Pin
Marziyeh Eslampanah20-Oct-12 0:16
Marziyeh Eslampanah20-Oct-12 0:16 
AnswerRe: shamsi Date to miladi Pin
Mohammad Dayyan3-Jan-15 18:48
Mohammad Dayyan3-Jan-15 18:48 

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.