hi
I have to use the Scheduler in a farsi(persian) website,to change the calendar from georgian to persian I have written the following codes:
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("fa-IR");System.Globalization.DateTimeFormatInfo info = culture.DateTimeFormat;
info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
info.AbbreviatedMonthNames = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.MonthNames = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AMDesignator = "ق.ظ";
info.PMDesignator = "ب.ظ";
info.ShortDatePattern = "yyyy/MM/dd";
info.FirstDayOfWeek = DayOfWeek.Saturday;
System.Globalization.PersianCalendar cal = new System.Globalization.PersianCalendar();
typeof(System.Globalization.DateTimeFormatInfo).GetField(
"calendar", System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic).SetValue(info, cal);
object obj = typeof(System.Globalization.DateTimeFormatInfo).GetField(
"m_cultureTableRecord", System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic).GetValue(info);
obj.GetType().GetMethod("UseCurrentCalendar",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance).Invoke(obj,
new object[] { cal.GetType().GetProperty("ID",
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic).GetValue(cal, null) });
typeof(System.Globalization.CultureInfo).GetField("calendar",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic).SetValue(culture, cal);
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
RadScheduler1.Culture = culture;
RadScheduler1.SelectedDate = DateTime.Now.Date;
TimeSpan ts = new TimeSpan(3, 30, 00);
RadScheduler1.TimeZoneOffset = ts;
RadScheduler1.FirstDayOfWeek = DayOfWeek.Saturday;
RadScheduler1.Localization.HeaderDay = "روز";
RadScheduler1.Localization.HeaderToday = "امروز";
the result is strange,the dayview & weekview is ok but in the monthview and also in the calendar at the corner of the page(when navigating from current month to next or previuos month ) day conversions are incorrect
I have shown the problems in the picture at the following url
http://upload.iranblog.com/7/1247614585.jpg
can anyone help me chang the calender implemented in aspxScheduler from georgian to persian please??
8 Answers, 1 is accepted
Unfortunately currently the RadScheduler control does not work properly with Arabic cultures. Adding support for this is one of our highest priorities for the control. Please excuse us for any inconveniences we may have caused you.
Greetings,
Paul
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

Please Please Please Do Not consider Persian as an Arabic dependency. there are many differences in calendar, alphabet, and the most important one : the culture...
Thanks a lot.



I need to check for alphabets in date. I don't want alphabet in the textbox of date.. m using this for fist time.. please suggest me.
here is my code
<div class="col-sm-8" >
@Html.TextBoxFor(p => p.Dob, new { @type = "date", @value = "", @id = "txtDOB", @Autocomplete = "off", @placeholder = "DD/MM/YYYY" })
</div>
in< script> am using like:
$("#txtDOB").keyup(function (e) {
if (e.keyCode != 193 && e.keyCode != 111) {
console.log(e.keyCode);
if (e.keyCode != 8) {
if (($(this).val().length == 2)) {
$(this).val($(this).val() + "/");
} else if ($(this).val().length == 5) {
$(this).val($(this).val() + "/");
}
} else {
var temp = $(this).val();
if ($(this).val().length == 5) {
$(this).val(temp.substring(0, 4));
} else if ($(this).val().length == 2) {
$(this).val(temp.substring(0, 1));
}
}
} else {
var temp = $(this).val();
var tam = $(this).val().length;
$(this).val(temp.substring(0, tam - 1));
}
});
$('#txtDOB').click(function () {
var dateformat = /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
var Val_date = $('#txtDOB').val();
var r = /^[a-zA-Z ]+$/;
if (Val_date.match(r)){
alert("ok");
}
else {
alert("pls enter number");
}
if (Val_date.match(dateformat)) {
var seperator1 = Val_date.split('/');
var seperator2 = Val_date.split('-');
if (seperator1.length > 1) {
var splitdate = Val_date.split('/');
}
else if (seperator2.length > 1) {
var splitdate = Val_date.split('-');
}
var dd = parseInt(splitdate[0]);
var mm = parseInt(splitdate[1]);
var yy = parseInt(splitdate[2]);
var ListofDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (mm == 1 || mm > 2) {
if (dd > ListofDays[mm - 1]) {
alert('Invalid date format!');
return false;
}
}
if (mm == 2) {
var lyear = false;
if ((!(yy % 4) && yy % 100) || !(yy % 400)) {
lyear = true;
}
if ((lyear == false) && (dd >= 29)) {
alert('Invalid date format!');
return false;
}
if ((lyear == true) && (dd > 29)) {
alert('Invalid date format!');
return false;
}
}
}
else {
alert("Invalid date format!");
return false;
}
});

hi
complete persian schaduler . in .Net 4.5
PersianCulture.cs in App_Code
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Reflection;
using
System.Globalization;
public
class
PersianCulture : CultureInfo
{
private
readonly
Calendar cal;
private
readonly
Calendar[] optionals;
public
PersianCulture()
:
this
(
"fa-IR"
,
true
)
{
}
public
PersianCulture(
string
cultureName,
bool
useUserOverride)
:
base
(cultureName, useUserOverride)
{
System.Globalization.CultureInfo newCulture = System.Globalization.CultureInfo.CreateSpecificCulture(
"fa-IR"
);
//Temporary Value for cal.
cal =
base
.OptionalCalendars[0];
//populating new list of optional calendars.
var optionalCalendars =
new
List<Calendar>();
optionalCalendars.AddRange(
base
.OptionalCalendars);
optionalCalendars.Insert(0,
new
PersianCalendar());
Type formatType =
typeof
(DateTimeFormatInfo);
Type calendarType =
typeof
(Calendar);
PropertyInfo idProperty = calendarType.GetProperty(
"ID"
, BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo optionalCalendarfield = formatType.GetField(
"optionalCalendars"
,
BindingFlags.Instance | BindingFlags.NonPublic);
//populating new list of optional calendar ids
var newOptionalCalendarIDs =
new
Int32[optionalCalendars.Count];
for
(
int
i = 0; i < newOptionalCalendarIDs.Length; i++)
newOptionalCalendarIDs[i] = (Int32)idProperty.GetValue(optionalCalendars[i],
null
);
optionalCalendarfield.SetValue(DateTimeFormat, newOptionalCalendarIDs);
optionals = optionalCalendars.ToArray();
cal = optionals[0];
DateTimeFormat.Calendar = optionals[0];
DateTimeFormat.MonthNames =
new
[] {
"فروردین"
,
"اردیبهشت"
,
"خرداد"
,
"تیر"
,
"مرداد"
,
"شهریور"
,
"مهر"
,
"آبان"
,
"آذر"
,
"دی"
,
"بهمن"
,
"اسفند"
,
""
};
DateTimeFormat.MonthGenitiveNames =
new
[] {
"فروردین"
,
"اردیبهشت"
,
"خرداد"
,
"تیر"
,
"مرداد"
,
"شهریور"
,
"مهر"
,
"آبان"
,
"آذر"
,
"دی"
,
"بهمن"
,
"اسفند"
,
""
};
DateTimeFormat.AbbreviatedMonthNames =
new
[] {
"فروردین"
,
"اردیبهشت"
,
"خرداد"
,
"تیر"
,
"مرداد"
,
"شهریور"
,
"مهر"
,
"آبان"
,
"آذر"
,
"دی"
,
"بهمن"
,
"اسفند"
,
""
};
DateTimeFormat.AbbreviatedMonthGenitiveNames =
new
[] {
"فروردین"
,
"اردیبهشت"
,
"خرداد"
,
"تیر"
,
"مرداد"
,
"شهریور"
,
"مهر"
,
"آبان"
,
"آذر"
,
"دی"
,
"بهمن"
,
"اسفند"
,
""
};
DateTimeFormat.AbbreviatedDayNames =
new
string
[] {
"ی"
,
"د"
,
"س"
,
"چ"
,
"پ"
,
"ج"
,
"ش"
};
DateTimeFormat.ShortestDayNames =
new
string
[] {
"ی"
,
"د"
,
"س"
,
"چ"
,
"پ"
,
"ج"
,
"ش"
};
DateTimeFormat.DayNames =
new
string
[] {
"یکشنبه"
,
"دوشنبه"
,
"ﺳﻪشنبه"
,
"چهارشنبه"
,
"پنجشنبه"
,
"جمعه"
,
"شنبه"
};
DateTimeFormat.AMDesignator =
"ق.ظ"
;
DateTimeFormat.PMDesignator =
"ب.ظ"
;
DateTimeFormat.ShortTimePattern =
"HH:mm"
;
/////////////////////////////////////////////////////////////////////////////////////
DateTimeFormat.DateSeparator =
"/"
;
DateTimeFormat.FullDateTimePattern =
"dd/MM/yyyy HH:mm"
;
//////////////////////////////////////////////////////////////////////////////////
DateTimeFormat.FirstDayOfWeek = DayOfWeek.Saturday;
// DateTimeFormat.ShortDatePattern
///////////////////////////////////////////////////////////////////////////////////////////////
DateTimeFormat.ShortDatePattern =
"dd/MM/yyyy"
;
DateTimeFormat.LongDatePattern =
"dd/MM/yyyy HH:mm"
;
DateTimeFormat.SetAllDateTimePatterns(
new
[] {
"dd/MM/yyyy"
},
'd'
);
DateTimeFormat.SetAllDateTimePatterns(
new
[] {
"dddd, dd MMMM yyyy"
},
'D'
);
DateTimeFormat.SetAllDateTimePatterns(
new
[] {
"yyyy MMMM"
},
'y'
);
DateTimeFormat.SetAllDateTimePatterns(
new
[] {
"yyyy MMMM"
},
'Y'
);
/////////////////////////////////////////////////////////////////////////////////////
//System.Globalization.PersianCalendar mycal = new System.Globalization.PersianCalendar();
//typeof(System.Globalization.DateTimeFormatInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(DateTimeFormat, mycal);
////object obj = typeof(System.Globalization.DateTimeFormatInfo).GetField("m_cultureTableRecord", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(info);
////obj.GetType().GetMethod("UseCurrentCalendar", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(obj, new object[] { cal.GetType().GetProperty("ID", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(cal, null) });
//typeof(System.Globalization.CultureInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(DateTimeFormat, mycal);
//typeof(System.Globalization.CultureInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(DateTimeFormat, mycal);
}
public
override
Calendar Calendar
{
get
{
return
cal; }
}
public
override
Calendar[] OptionalCalendars
{
get
{
return
optionals; }
}
public
void
SetMypersianCulture()
{
System.Globalization.CultureInfo newCulture = System.Globalization.CultureInfo.CreateSpecificCulture(
"fa-IR"
);
PersianCulture MyPersianCulture =
new
PersianCulture();
//myPersianCulture.DateTimeFormat.ShortDatePattern;
System.Threading.Thread.CurrentThread.CurrentCulture = MyPersianCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = MyPersianCulture;
//
// System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern
}
}
and
Global.asax
<%@ Application Language=
"C#"
%>
<script runat=
"server"
>
protected
void
Application_BeginRequest(
object
sender, EventArgs e)
{
var persianCulture =
new
PersianCulture();
System.Threading.Thread.CurrentThread.CurrentCulture = persianCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = persianCulture;
}
void
Application_Start(
object
sender, EventArgs e)
{
// Code that runs on application startup
//var persianCulture = new PersianCulture();
//System.Threading.Thread.CurrentThread.CurrentCulture = persianCulture;
//System.Threading.Thread.CurrentThread.CurrentUICulture = persianCulture;
}
void
Application_End(
object
sender, EventArgs e)
{
// Code that runs on application shutdown
}
void
Application_Error(
object
sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void
Session_Start(
object
sender, EventArgs e)
{
// Code that runs when a new session is started
}
void
Session_End(
object
sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>

attention!!!!
the Month and year appointment when you use persian schaduler dont correct work.
you dont should use them.