Click here to Skip to main content
15,881,709 members
Articles / Programming Languages / Javascript
Article

Persian Calendar and Date Picker for Web Applications (JavaScript)

Rate me:
Please Sign up or sign in to vote.
4.81/5 (41 votes)
27 Nov 2007CPOL1 min read 195.7K   9.5K   48   50
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:

HTML
<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:

HTML
<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)


Written By
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

Comments and Discussions

 
GeneralRe: is it possible that the calendar be right to left ? Pin
Vahid_N16-Oct-07 1:30
Vahid_N16-Oct-07 1:30 
AnswerRe: is it possible that the calendar be right to left ? [modified] Pin
poyanfar28-Apr-10 19:38
poyanfar28-Apr-10 19:38 
Generalproblem in FireFox Pin
Afsoon10-Mar-07 22:24
Afsoon10-Mar-07 22:24 
GeneralRe: problem in FireFox Pin
Amin Habibi S.10-Mar-07 23:10
Amin Habibi S.10-Mar-07 23:10 
GeneralRe: problem in FireFox Pin
hooshang Karami1-Sep-07 23:32
hooshang Karami1-Sep-07 23:32 
Generalproblem with the calendar Pin
Afsoon20-Feb-07 23:01
Afsoon20-Feb-07 23:01 
GeneralRe: problem with the calendar Pin
Amin Habibi S.23-Feb-07 21:52
Amin Habibi S.23-Feb-07 21:52 
QuestionNice Code But i have Problem... Pin
barbod_blue18-Feb-07 21:12
barbod_blue18-Feb-07 21:12 
i can't use your code in my project
cause i use AJAX-PopmodalExtender in my project
and your calendar doesn't work at it!!!
how can i use it?(how can i contact with u? and
ask some question?!?!?!)Smile | :)


Barbod
GeneralWell done. Pin
Bahram.M13-Feb-07 0:22
Bahram.M13-Feb-07 0:22 
GeneralRe: Well done. Pin
Amin Habibi S.13-Feb-07 14:00
Amin Habibi S.13-Feb-07 14:00 
GeneralGreat work! Pin
SalarSoft10-Feb-07 23:37
SalarSoft10-Feb-07 23:37 
AnswerRe: Great work! Pin
Amin Habibi S.12-Feb-07 23:20
Amin Habibi S.12-Feb-07 23:20 

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.