Click here to Skip to main content
11,576,667 members (61,026 online)
Click here to Skip to main content

Persian Calendar and Date Picker for Web Applications (JavaScript)

, 27 Nov 2007 CPOL 117.8K 7.9K 46
Rate this:
Please Sign up or sign in to vote.
A library to work with "Persian Calendar", "Hijri Calendar", "Jalali Calendar", and "Gregorian Calendar" with WebForms GUI controls designed for Persian (Farsi) or Arabic language applications in mind, but usable in any web application that makes use of a calendar.

Sample Image - Persian_Date_Picker.jpg

Introduction

The Persian Calendar is used in most countries where Persian is spoken, although some regions use different month names. The Persian calendar is the official calendar of Iran and Afghanistan, and is one of the alternative calendars in regions such as Kazakhstan and Tajikistan. The Persian calendar is based on a solar year, and is approximately 365 days long. A year cycles through four seasons, and a new year begins when the sun appears to cross the equator from the southern hemisphere to the northern hemisphere as viewed from the center of the Earth. The new year marks the first day of the month of Farvardin, which is the first day of spring in the northern hemisphere. Each of the first six months in the Persian calendar has 31 days, each of the next five months has 30 days, and the last month has 29 days in a common year and 30 days in a leap year. A leap year is a year that, when divided by 33, has a remainder of 1, 5, 9, 13, 17, 22, 26, or 30. For example, the year 1370 is a leap year because dividing it by 33 yields a remainder of 17. There are approximately 8 leap years in every 33-year cycle.

Using the code

This example demonstrates how to use the Persian Calendar. You should add the required references to the head section of your page:

<script type="text/javascript" language="JavaScript" src="JScripts/amin.js">
</script>
<script type="text/javascript" language="JavaScript" src="JScripts/calendar.js">
</script>
<link rel="stylesheet" type="text/css" href="CSS/calendar.css">

And call the 'displayDatePicker' function where you want the calendar to appear:

<form style="text-align:center ">
  <input name="AnotherDate">
  <input value="select" onclick="displayDatePicker('AnotherDate', this);" type="button">
</form>

License

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

Share

About the Author

Amin Habibi S.
Web Developer
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
I was born in Gonabad (1984).
I spent there my whole life until I was accepted in national university entrance exam. Then I migrated to Tehran.
Now I live in Tehran

You can see my CV at: http://habibiamin.googlepages.com

You may also be interested in...

Comments and Discussions

 
Questionراهنمایی Pin
SamiraProgrammer5-Jun-15 0:13
memberSamiraProgrammer5-Jun-15 0:13 
Suggestionتولید user control Pin
Hadi Zaker13-Oct-14 11:15
memberHadi Zaker13-Oct-14 11:15 
Questionتشکر Pin
monanini25-Feb-14 0:14
membermonanini25-Feb-14 0:14 
Questionایمیل Pin
abollfazl8-Jun-13 3:29
memberabollfazl8-Jun-13 3:29 
GeneralMy vote of 5 Pin
Arash Farahani1-Apr-13 4:54
memberArash Farahani1-Apr-13 4:54 
Questionسلام Pin
abollfazl9-Jan-13 22:36
memberabollfazl9-Jan-13 22:36 
Generalمرسی Pin
e.rabiei6825-Aug-12 19:52
membere.rabiei6825-Aug-12 19:52 
خوشحالم که یک ایرانی هم تو این سایت فعالیت داشته.
مرسییییییی
Questiontanks Pin
s_ahmadneya18-Feb-12 3:01
members_ahmadneya18-Feb-12 3:01 
Questionwow this nice Pin
javad1121184-Feb-12 1:58
memberjavad1121184-Feb-12 1:58 
Questiontnx Pin
qazale7-Sep-11 3:33
memberqazale7-Sep-11 3:33 
Questionthanks Pin
computec_teh2-Jul-11 0:15
membercomputec_teh2-Jul-11 0:15 
Generalthx Pin
nasrin647-Jun-11 20:14
membernasrin647-Jun-11 20:14 
GeneralMy vote of 5 Pin
Mohammad Dayyan5-Jun-11 4:14
memberMohammad Dayyan5-Jun-11 4:14 
Generaljsf Pin
Morteza Davoodi1-Jun-11 1:17
memberMorteza Davoodi1-Jun-11 1:17 
GeneralMy vote of 5 Pin
Shahin Khorshidnia3-Apr-11 18:36
memberShahin Khorshidnia3-Apr-11 18:36 
GeneralPersianCalendar conflict Pin
M.M.Rezaee23-Sep-10 10:01
memberM.M.Rezaee23-Sep-10 10:01 
GeneralMy vote of 5 Pin
gh_shahabi8-Aug-10 3:06
membergh_shahabi8-Aug-10 3:06 
GeneralpersianCanelndar Pin
camelia11125-Jul-10 0:21
membercamelia11125-Jul-10 0:21 
GeneralNice work. Pin
Reza Jahanbakhshi21-Apr-10 18:31
memberReza Jahanbakhshi21-Apr-10 18:31 
Generalسلام Pin
ali_mahdi29-Sep-09 5:43
memberali_mahdi29-Sep-09 5:43 
GeneralHi Pin
ali_mahdi29-Sep-09 5:38
memberali_mahdi29-Sep-09 5:38 
QuestionHow can i prevent user to modify the choosen date from date picker? Pin
honey.hv13-Jul-09 2:13
memberhoney.hv13-Jul-09 2:13 
GeneralGreat work but bad js code Pin
arash alavi20-May-09 21:25
memberarash alavi20-May-09 21:25 
GeneralThank you Pin
Jinousa7-Mar-09 3:38
memberJinousa7-Mar-09 3:38 
Generalabout Hijri Calender Pin
ibless26-Aug-08 5:09
memberibless26-Aug-08 5:09 
GeneralThanks Pin
shahrzad khorrami12-May-08 0:43
membershahrzad khorrami12-May-08 0:43 
QuestionBUG!!!????!!!! Pin
barbod_blue26-Nov-07 23:33
memberbarbod_blue26-Nov-07 23:33 
QuestionLeap year calculation algorithm Pin
Sasanj4-Nov-07 2:45
memberSasanj4-Nov-07 2:45 
NewsUsing this calendar in ASP.NET Pin
Vahid_Nasiri16-Oct-07 20:24
memberVahid_Nasiri16-Oct-07 20:24 
GeneralRe: Using this calendar in ASP.NET Pin
Vahid_Nasiri8-Feb-08 19:05
memberVahid_Nasiri8-Feb-08 19:05 
GeneralThank You From Iranian Programmer Pin
hooshang Karami1-Sep-07 19:32
memberhooshang Karami1-Sep-07 19:32 
Questionthank u:-) Pin
znarges8027-Aug-07 2:28
memberznarges8027-Aug-07 2:28 
GeneralGregorian Calendar Pin
minoosh12-May-07 23:50
memberminoosh12-May-07 23:50 
GeneralRe: Gregorian Calendar Pin
Amin Habibi S.13-May-07 1:16
memberAmin Habibi S.13-May-07 1:16 
GeneralRe: Gregorian Calendar Pin
minoosh19-May-07 22:18
memberminoosh19-May-07 22:18 
Questionis it possible that the calendar be right to left ? Pin
katty_Dev10-Apr-07 2:25
memberkatty_Dev10-Apr-07 2:25 
AnswerRe: is it possible that the calendar be right to left ? Pin
Amin Habibi S.10-Apr-07 20:57
memberAmin Habibi S.10-Apr-07 20:57 
GeneralRe: is it possible that the calendar be right to left ? Pin
Vahid_Nasiri16-Oct-07 1:30
memberVahid_Nasiri16-Oct-07 1:30 
AnswerRe: is it possible that the calendar be right to left ? [modified] Pin
poyanfar28-Apr-10 19:38
memberpoyanfar28-Apr-10 19:38 
Generalproblem in FireFox Pin
Afsoon10-Mar-07 22:24
memberAfsoon10-Mar-07 22:24 
GeneralRe: problem in FireFox Pin
Amin Habibi S.10-Mar-07 23:10
memberAmin Habibi S.10-Mar-07 23:10 
GeneralRe: problem in FireFox Pin
hooshang Karami1-Sep-07 23:32
memberhooshang Karami1-Sep-07 23:32 
Generalproblem with the calendar Pin
Afsoon20-Feb-07 23:01
memberAfsoon20-Feb-07 23:01 
GeneralRe: problem with the calendar Pin
Amin Habibi S.23-Feb-07 21:52
memberAmin Habibi S.23-Feb-07 21:52 
QuestionNice Code But i have Problem... Pin
Member #307324718-Feb-07 21:12
memberMember #307324718-Feb-07 21:12 
GeneralWell done. Pin
Bahram.M13-Feb-07 0:22
memberBahram.M13-Feb-07 0:22 
GeneralRe: Well done. Pin
Amin Habibi S.13-Feb-07 14:00
memberAmin Habibi S.13-Feb-07 14:00 
GeneralGreat work! Pin
SalarSoft10-Feb-07 23:37
memberSalarSoft10-Feb-07 23:37 
AnswerRe: Great work! Pin
Amin Habibi S.12-Feb-07 23:20
memberAmin Habibi S.12-Feb-07 23:20 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150603.1 | Last Updated 28 Nov 2007
Article Copyright 2007 by Amin Habibi S.
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid