Are you tired?
I'm sorry to bother you.Originally posted by sadra
That's ok, you can bother me as much as you want in order to sort it out fortunately have plenty of time at the moment, but that may not be the case next month.نوشته شده توسط HuwR
Posted
Posted
using System;
using System.Globalization;
using System.Reflection;
using System.Threading;
public class Cultures
{
public static void InitializePersianCulture()
{
InitializeCulture("fa-ir", new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" },
new[] { "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" },
new[]
{
"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی",
"بهمن", "اسفند", ""
},
new[]
{
"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی",
"بهمن", "اسفند", ""
}, "ق.ظ. ", "ب.ظ. ", "yyyy/MM/dd", new PersianCalendar());
}
public static void InitializeCulture(string culture, string[] abbreviatedDayNames, string[] dayNames,
string[] abbreviatedMonthNames, string[] monthNames, string amDesignator,
string pmDesignator, string shortDatePattern, Calendar calendar)
{
var calture = new CultureInfo(culture);
var info = calture.DateTimeFormat;
info.AbbreviatedDayNames = abbreviatedDayNames;
info.DayNames = dayNames;
info.AbbreviatedMonthNames = abbreviatedMonthNames;
info.MonthNames = monthNames;
info.AMDesignator = amDesignator;
info.PMDesignator = pmDesignator;
info.ShortDatePattern = shortDatePattern;
info.FirstDayOfWeek = DayOfWeek.Saturday;
var cal = calendar;
var type = typeof(DateTimeFormatInfo);
var fieldInfo = type.GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo != null)
fieldInfo.SetValue(info, cal);
var field = typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
field.SetValue(calture, cal);
Thread.CurrentThread.CurrentCulture = calture;
Thread.CurrentThread.CurrentUICulture = calture;
CultureInfo.CurrentCulture.DateTimeFormat = info;
CultureInfo.CurrentUICulture.DateTimeFormat = info;
}
}
using System.Globalization;
using System.Reflection;
using System.Threading;
public class Cultures
{
public static void InitializePersianCulture()
{
InitializeCulture("fa-ir", new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" },
new[] { "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" },
new[]
{
"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی",
"بهمن", "اسفند", ""
},
new[]
{
"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی",
"بهمن", "اسفند", ""
}, "ق.ظ. ", "ب.ظ. ", "yyyy/MM/dd", new PersianCalendar());
}
public static void InitializeCulture(string culture, string[] abbreviatedDayNames, string[] dayNames,
string[] abbreviatedMonthNames, string[] monthNames, string amDesignator,
string pmDesignator, string shortDatePattern, Calendar calendar)
{
var calture = new CultureInfo(culture);
var info = calture.DateTimeFormat;
info.AbbreviatedDayNames = abbreviatedDayNames;
info.DayNames = dayNames;
info.AbbreviatedMonthNames = abbreviatedMonthNames;
info.MonthNames = monthNames;
info.AMDesignator = amDesignator;
info.PMDesignator = pmDesignator;
info.ShortDatePattern = shortDatePattern;
info.FirstDayOfWeek = DayOfWeek.Saturday;
var cal = calendar;
var type = typeof(DateTimeFormatInfo);
var fieldInfo = type.GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo != null)
fieldInfo.SetValue(info, cal);
var field = typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
field.SetValue(calture, cal);
Thread.CurrentThread.CurrentCulture = calture;
Thread.CurrentThread.CurrentUICulture = calture;
CultureInfo.CurrentCulture.DateTimeFormat = info;
CultureInfo.CurrentUICulture.DateTimeFormat = info;
}
}
Who is Imam Mahdi? Is he the Savior promised by all religions?اللهم عجل لولیک الفرج
Posted
Are you tired?
I'm sorry to bother you.Originally posted by sadra
That's ok, you can bother me as much as you want in order to sort it out fortunately have plenty of time at the moment, but that may not be the case next month.
Posted
Unfortunately the problem is that on the server it is not in the normal list of supported calendars so you can't just use the normal formatting of .net you have to construct the result manually (it's a real pain) however, I think it is good now, the month problem was me, I was getting the month number and then indexing the month name array using that, but I needed to do month-1 for the index as it is a 0 based array.
Posted
Are you tired?
I'm sorry to bother you.
I'm sorry to bother you.
Who is Imam Mahdi? Is he the Savior promised by all religions?اللهم عجل لولیک الفرج
Posted
what should for example 13 May 2020 be in Persian ? just so I can test some dates.
We may need to put the months in as resource, I'll let you know how I get on. It is just difficult to test locally as the calendars behave completely differently and all works fine on my local server, so I suspect it is the server version here that is the issue نوشته شده توسط HuwR
1. 13 May 2020 ==== 24 اردیبهشت 1399
2. I think that the Persian calendar is present in the .NET Framework by default and is probably independent of the server calendar. But I don't know how to use it.
Everything is ok but one, just one step away from the rest of the items. And that is the name of the Persian months.
Who is Imam Mahdi? Is he the Savior promised by all religions?اللهم عجل لولیک الفرج
Posted
what should for example 13 May 2020 be in Persian ? just so I can test some dates.
We may need to put the months in as resource, I'll let you know how I get on. It is just difficult to test locally as the calendars behave completely differently and all works fine on my local server, so I suspect it is the server version here that is the issue
We may need to put the months in as resource, I'll let you know how I get on. It is just difficult to test locally as the calendars behave completely differently and all works fine on my local server, so I suspect it is the server version here that is the issue
Posted
See the above...
Does the table above help?
If we can add the names of the months in the language resources .. maybe the problem will be solved
Does the table above help?
If we can add the names of the months in the language resources .. maybe the problem will be solved
Who is Imam Mahdi? Is he the Savior promised by all religions?اللهم عجل لولیک الفرج
Last edited by
Posted
could you tell me what the date is in English and what it should be in Persian. unfortunately I don't know what they should be so am just taking a stab in the dark
It may not even be possible to fix this on the server unfortunately, the persian calendar does not appear to give me month names just numbers
It may not even be possible to fix this on the server unfortunately, the persian calendar does not appear to give me month names just numbers
Posted
Month names:
Month No
Month Name - Gerigurian
Month Name - Persian
1
January
فروردیدن
2
February
اردیبهشت
3
March
خرداد
4
April
تیر
5
May
مرداد
6
June
شهریور
7
July
مهر
8
August
آبان
9
September
آذر
10
October
دی
11
November
بهمن
12
December
اسفند
Who is Imam Mahdi? Is he the Savior promised by all religions?اللهم عجل لولیک الفرج
Last edited by
FileUpload
If you're having problems uploading, try choosing a smaller image.
Send Topic
Loading...