本文整理汇总了C#中System.Globalization.PersianCalendar类的典型用法代码示例。如果您正苦于以下问题:C# PersianCalendar类的具体用法?C# PersianCalendar怎么用?C# PersianCalendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersianCalendar类属于System.Globalization命名空间,在下文中一共展示了PersianCalendar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getMiladiFromPersian
public static System.DateTime getMiladiFromPersian(string perDate)
{
int year = int.Parse(perDate.Substring(0, perDate.IndexOf("/")));
perDate = perDate.Substring(perDate.IndexOf("/") + 1);
int month = int.Parse(perDate.Substring(0, perDate.IndexOf("/")));
perDate = perDate.Substring(perDate.IndexOf("/") + 1);
int day = int.Parse(perDate);
System.Globalization.PersianCalendar persianCalendar = new System.Globalization.PersianCalendar();
return persianCalendar.ToDateTime(year, month, day, 0, 0, 0, 0);
}
示例2: PersianDate
public PersianDate(DateTime georgianDate)
{
var pc=new PersianCalendar();
Year = pc.GetYear(georgianDate);
Month = pc.GetMonth(georgianDate);
Day = pc.GetDayOfMonth(georgianDate);
}
示例3: ToPersianDate
public static string ToPersianDate(DateTime dt)
{
PersianCalendar p = new PersianCalendar();
return p.GetYear(dt).ToString() + "/" + p.GetMonth(dt).ToString("0") + "/" +
p.GetDayOfMonth(dt).ToString("00");
}
示例4: gregorianToShamsi
public string gregorianToShamsi(DateTime date)
{
DateTime gregorian = date;
PersianCalendar pc = new PersianCalendar();
int pcYear = pc.GetYear(gregorian);
int pcMonth = pc.GetMonth(gregorian);
int pcDay = pc.GetDayOfMonth(gregorian);
string convertedDate;
if (pcMonth == 1 || pcMonth == 2 || pcMonth == 3 ||
pcMonth == 4 || pcMonth == 5 || pcMonth == 6)
{
if (pcDay == 31)
convertedDate = string.Format("{0}/{1}/{2}", pcYear, pcMonth + 1, 1);
else
convertedDate = string.Format("{0}/{1}/{2}", pcYear, pcMonth, pcDay + 1);
}
else
{
if (pcDay == 30)
convertedDate = string.Format("{0}/{1}/{2}", pcYear, pcMonth + 1, 1);
else
convertedDate = string.Format("{0}/{1}/{2}", pcYear, pcMonth, pcDay + 1);
}
return convertedDate;
}
示例5: GetMonthName
public static String GetMonthName(this DateTime date)
{
var pc = new PersianCalendar();
var month = pc.GetMonth(date);
var months = DateTimeHelper.Months().ToArray();
return months[month - 1];
}
示例6: getDateInteger
public int getDateInteger(DateTime dt)
{
PersianCalendar pc = new PersianCalendar();
StringBuilder sb = new StringBuilder();
int month = pc.GetMonth(dt);
int day = pc.GetDayOfMonth(dt);
int year = pc.GetYear(dt);
sb.Append(year);
if (month < 10)
{
sb.Append("0" + month);
}
else
{
sb.Append(month);
}
if (day < 10)
{
sb.Append("0" + day);
}
else
{
sb.Append(day);
}
return Convert.ToInt32(sb.ToString());
}
示例7: PersianCultureInfo
/// <summary>
/// Initializes a new instance of the <see cref="PersianCultureInfo"/> class.
/// </summary>
public PersianCultureInfo()
: base("fa-IR", false) {
_calendar = new PersianCalendar();
_format = PersianDateTimeFormatInfo.GetFormatInfo(_calendar);
base.DateTimeFormat = _format;
NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
}
示例8: CreateArrayDate
//ایجاد آرایه ای از تارخ برای مشخص کردن تاریخ های تقویم
public string CreateArrayDate(IQueryable<DateTime> Date, DateTime MinDate, DateTime MaxDate)
{
TimeSpan Compare = (MaxDate).Subtract(MinDate);
Double DiffrentDays = Compare.TotalDays;
string ArrayDate = "";
int Days = Convert.ToInt32(DiffrentDays);
if ((DiffrentDays / Days != 0) && (Days < DiffrentDays))
Days++;
bool Check = false;
for (int i = 1; i <= Days; i++)
{
Check = false;
foreach (var item in Date)
{
if (MinDate.Date == item)
{
Check = true;
break;
}
}
if (Check == false)
{
PersianCalendar pc = new PersianCalendar();
if (ArrayDate != "")
{
ArrayDate = ArrayDate + "-";
}
ArrayDate = ArrayDate + pc.GetDayOfMonth(MinDate).ToString("00") + ", " + pc.GetMonth(MinDate).ToString("00") + ", " + pc.GetYear(MinDate).ToString("0000");
}
MinDate = MinDate.AddDays(1);
}
return ArrayDate;
}
示例9: ConvertToIranTimeString
public string ConvertToIranTimeString(DateTime Date)
{
//string zoneId = "Iran Standard Time";
//TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(zoneId);
//DateTime result = TimeZoneInfo.ConvertTimeFromUtc(Date, tzi);
Date = Date.AddMinutes(-150);
PersianCalendar pc = new PersianCalendar();
string year = pc.GetYear(Date).ToString();
string Month = pc.GetMonth(Date).ToString();
string Day = pc.GetDayOfMonth(Date).ToString();
string Hour = pc.GetHour(Date).ToString();
string Minute = pc.GetMinute(Date).ToString();
if (Month.Length == 1)
{
Month = "0" + Month;
}
if (Day.Length == 1)
{
Day = "0" + Day;
}
if (Hour.Length == 1)
{
Hour = "0" + Hour;
}
if (Minute.Length == 1)
{
Minute = "0" + Minute;
}
return year + "/" + Month + "/" + Day + " " + Hour + ":" + Minute;
}
示例10: InitPersianDateTimeFormat
/// <summary>
/// Represents a method that set persian option to specified instance CultureInfo
/// </summary>
/// <param name="dateTimeFormat">Represents an instance of DateTimeFormatInfo that persian option should be set to it.</param>
public static void InitPersianDateTimeFormat(DateTimeFormatInfo info)
{
if (info == null)
return;
PersianCalendar calendar = new PersianCalendar();
bool readOnly = (bool)dateTimeFormatInfoReadOnly.GetValue(info);
if (readOnly)
{
dateTimeFormatInfoReadOnly.SetValue(info, false);
}
dateTimeFormatInfoCalendar.SetValue(info, calendar);
//object obj2 = dateTimeFormatInfoCultureTableRecord.GetValue(info);
//cultureTableRecordUseCurrentCalendar.Invoke(obj2, new object[] { calendarID.GetValue(calendar, null) });
info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
info.ShortestDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
info.AbbreviatedMonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.MonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AMDesignator = "ق.ظ";
info.PMDesignator = "ب.ظ";
info.FirstDayOfWeek = DayOfWeek.Saturday;
info.FullDateTimePattern = "yyyy MMMM dddd";
info.LongDatePattern = "yyyy MMMM dddd, dd";
info.ShortDatePattern = "yyyy/MM/dd";
if (readOnly)
{
dateTimeFormatInfoReadOnly.SetValue(info, true);
}
}
示例11: SetYearDropDownList
public static DropDownList SetYearDropDownList(DropDownList yearDropList, int startYear, int yearShowNum)
{
PersianCalendar pcal = new PersianCalendar();
for (int i = startYear; i < startYear + yearShowNum; i++)
yearDropList.Items.Add(new ListItem(i.ToString(), i.ToString()));
return yearDropList;
}
示例12: PersianCultureInfo
/// <summary>
/// Initializes a new instance of the <see cref="PersianCultureInfo"/> class.
/// </summary>
public PersianCultureInfo()
: base("fa-IR", false)
{
calendar = new PersianCalendar();
systemCalendar = new System.Globalization.PersianCalendar();
format = CreateDateTimeFormatInfo();
SetCalendar();
}
示例13: setTime
public string setTime()
{
PersianCalendar pdate = new PersianCalendar();
DateTime nT = new DateTime();
nT = DateTime.Now;
string time = "";
time = pdate.GetHour(nT) + ":" + pdate.GetMinute(nT);
return time;
}
示例14: getBeforeYear
public static string getBeforeYear()
{
System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
DateTime date = DateTime.Today;
int year = p.GetYear(date);
int month = p.GetMonth(date);
int day = p.GetDayOfMonth(date);
return (year-1) + "/" + month.ToString("00") + "/" + day.ToString("00");
}
示例15: Timeout
[Test, Timeout(300000)] // Can take a long time under NCrunch.
public void BclThroughHistory()
{
Calendar bcl = new PersianCalendar();
// The "right" BCL equivalent to use depends on the version of .NET... pick it appropriately here.
CalendarSystem noda = bcl.IsLeapYear(1) ? CalendarSystem.PersianSimple : CalendarSystem.PersianAstronomical;
// Note: Noda Time stops in 9377, whereas the BCL goes into the start of 9378. This is because
// Noda Time ensures that the whole year is valid.
BclEquivalenceHelper.AssertEquivalent(bcl, noda, noda.MinYear, noda.MaxYear);
}