Behrang
22 Sep 2010, 3:18 AM
Hi,
I've created a plugin for DatePicker, DateMenu and DateField components, which changes their calendar from Gregorian to Jalali (Khorshidi, Persian, Iranian or Shamsi). My company, Tosan Inc, agreed to open source this component and here it is. You can get the code from GitHub at http://github.com/Behrang/Ext.ux.JalaliDatePlugin. This is currently developed for ExtJS 3.2.1.
Usage
First you have to include these files in your html:
<script src="Jalali.js"></script>
<script src="JalaliDate.js"></script>
<script src="JalaliDatePlugin.js"></script>
If you want a Persian localization, you can include this one too:
<script src="JalaliDatePlugin-fa_IR.js"></script>
Then you can add JalaliDatePlugin as a plugin for DatePicker, DateMenu and DateField. Here is an example for a DatePicker:
var datePicker = new Ext.DatePicker({
plugins: [Ext.ux.JalaliDatePlugin]
});
Now your component, in this case datePicker, is working in Jalali calendar.
I have also included an example file which shows the three components in action.Please note that you can use other properties such as minDate, maxDate disabledDays, disabledDates and others just as expected.
About
Jalali.js contains conversion algorithm. This is the algorithm provided by farsiweb at http://www.farsiweb.ir/wiki/Iranian_Calendar for conversion between Gregorian calendar and Jalali calendar. I have changed it a little for better naming conventions and removed a function from it.
JalaliDate.js instruments JavaScript's Date object and adds Jalali functionality to it. Some methods are added to every instance of Date and we are able to use every instance of date as both Jalali and Gregorian. This simplifies things a lot. For example you can use the Date.format and Date.parse functions to display and parse strings. As I have used Ext.apply and Ext.override, you will need Ext for this. If you want to use it in other frameworks, you have to change a few lines.
JalaliDatePlugin.js is a plugin for Ext components. It supports all three date components (DatePicker, DateMenu and DateField). Just add this to the plugins property of those components.
JalaliDatePlugin-fa_IR.js is a localization for Persian language. You can use it if your application's locale is Persian. If you don't include it, everything will be in English.
example.html is an example for showing the usage in action.
License
Jalali.js was distributed under the terms of LGPL, so it is distributed under LGPL. Other files are distributed under the terms of MIT license.
Please feel free to use it and provide feedback.
I've created a plugin for DatePicker, DateMenu and DateField components, which changes their calendar from Gregorian to Jalali (Khorshidi, Persian, Iranian or Shamsi). My company, Tosan Inc, agreed to open source this component and here it is. You can get the code from GitHub at http://github.com/Behrang/Ext.ux.JalaliDatePlugin. This is currently developed for ExtJS 3.2.1.
Usage
First you have to include these files in your html:
<script src="Jalali.js"></script>
<script src="JalaliDate.js"></script>
<script src="JalaliDatePlugin.js"></script>
If you want a Persian localization, you can include this one too:
<script src="JalaliDatePlugin-fa_IR.js"></script>
Then you can add JalaliDatePlugin as a plugin for DatePicker, DateMenu and DateField. Here is an example for a DatePicker:
var datePicker = new Ext.DatePicker({
plugins: [Ext.ux.JalaliDatePlugin]
});
Now your component, in this case datePicker, is working in Jalali calendar.
I have also included an example file which shows the three components in action.Please note that you can use other properties such as minDate, maxDate disabledDays, disabledDates and others just as expected.
About
Jalali.js contains conversion algorithm. This is the algorithm provided by farsiweb at http://www.farsiweb.ir/wiki/Iranian_Calendar for conversion between Gregorian calendar and Jalali calendar. I have changed it a little for better naming conventions and removed a function from it.
JalaliDate.js instruments JavaScript's Date object and adds Jalali functionality to it. Some methods are added to every instance of Date and we are able to use every instance of date as both Jalali and Gregorian. This simplifies things a lot. For example you can use the Date.format and Date.parse functions to display and parse strings. As I have used Ext.apply and Ext.override, you will need Ext for this. If you want to use it in other frameworks, you have to change a few lines.
JalaliDatePlugin.js is a plugin for Ext components. It supports all three date components (DatePicker, DateMenu and DateField). Just add this to the plugins property of those components.
JalaliDatePlugin-fa_IR.js is a localization for Persian language. You can use it if your application's locale is Persian. If you don't include it, everything will be in English.
example.html is an example for showing the usage in action.
License
Jalali.js was distributed under the terms of LGPL, so it is distributed under LGPL. Other files are distributed under the terms of MIT license.
Please feel free to use it and provide feedback.