本文整理汇总了C#中System.Globalization.PersianCalendar类的典型用法代码示例。如果您正苦于以下问题:C# PersianCalendar类的具体用法?C# PersianCalendar怎么用?C# PersianCalendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersianCalendar类属于System.Globalization命名空间,在下文中一共展示了PersianCalendar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:sunshinemistery,项目名称:Store,代码行数:10,代码来源:Utilities.cs
示例2: PersianDate
public PersianDate(DateTime georgianDate)
{
var pc=new PersianCalendar();
Year = pc.GetYear(georgianDate);
Month = pc.GetMonth(georgianDate);
Day = pc.GetDayOfMonth(georgianDate);
}
开发者ID:aminmesbahi,项目名称:BlogEngine.NET,代码行数:7,代码来源:PersianDate.cs
示例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");
}
开发者ID:shabnamsadegh,项目名称:UserBasedSystem,代码行数:7,代码来源:ViewNews.aspx.cs
示例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;
}
开发者ID:e-safarzadeh,项目名称:Raybod.MSCRM.KandooWebSite,代码行数:27,代码来源:TuitionList.aspx.cs
示例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];
}
开发者ID:aminsh,项目名称:Backend-Framework,代码行数:7,代码来源:DateTimeExtension.cs
示例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());
}
开发者ID:amin-rahimi,项目名称:EasyAccounting,代码行数:26,代码来源:PersianDateFormatter.cs
示例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;
}
开发者ID:kavand,项目名称:Kavand.Windows.Controls,代码行数:10,代码来源:PersianCultureInfo.cs
示例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;
}
开发者ID:Chitva,项目名称:Ganjine,代码行数:34,代码来源:DateTimeUtility.cs
示例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;
}
开发者ID:farhad85,项目名称:Iranegan,代码行数:34,代码来源:Time.cs
示例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);
}
}
开发者ID:Mahdi-K,项目名称:KCore,代码行数:33,代码来源:PersianCultureHelper.cs
示例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;
}
开发者ID:sinaaslani,项目名称:kids.bmi.ir,代码行数:8,代码来源:Common.cs
示例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();
}
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:11,代码来源:PersianCultureInfo.cs
示例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;
}
开发者ID:saeedehsaneei,项目名称:educationDegree,代码行数:9,代码来源:Main.Master.cs
示例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");
}
开发者ID:irania,项目名称:tirax,代码行数:9,代码来源:PersianDate.cs
示例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);
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:10,代码来源:PersianCalendarSystemTest.cs
示例16: GetPersianCulture
public static CultureInfo GetPersianCulture()
{
//*****************************************************************************
//*****************************2008-04-02 By A. Samarian*****Begin*************
//Modified:2010-09-18
//Modified by: Asad Samarian
//*****************************************************************************
CultureInfo persianCulture = new CultureInfo("fa-IR");
DateTimeFormatInfo info = persianCulture.DateTimeFormat;
info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
info.MonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AbbreviatedMonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
//It Seems .NET 4 use Genitive manes for months.
info.MonthGenitiveNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AbbreviatedMonthGenitiveNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AMDesignator = "ق.ظ";
info.PMDesignator = "ب.ظ";
info.ShortDatePattern = "yyyy/MM/dd";
info.LongDatePattern = "dddd dd MMMM yyyy";
info.FullDateTimePattern = "dddd dd MMMM yyyy, HH:mm:ss";
info.FirstDayOfWeek = DayOfWeek.Saturday;
PersianCalendar cal = new PersianCalendar();
// 2010-07-18 this part throws an error under .NET 4, Asad says it is still needed for 3.5
if (ConfigHelper.GetBoolProperty("UseNet35PersianHelper", false)) //this setting is true in the We.config for 3.5 .NET but not 4.0
{
typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);
object obj = typeof(DateTimeFormatInfo).GetField("m_cultureTableRecord",
BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info);
obj.GetType().GetMethod("UseCurrentCalendar",
BindingFlags.NonPublic | BindingFlags.Instance).Invoke(obj, new object[] { cal.GetType().GetProperty("ID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(cal, null) });
//typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);
//typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(persianCulture, cal);
}
typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);
typeof(CultureInfo).GetField("calendar", (BindingFlags.NonPublic | (BindingFlags.Public | BindingFlags.Instance))).SetValue(persianCulture, cal);
persianCulture.DateTimeFormat = info;
persianCulture.NumberFormat.CurrencyDecimalDigits = 0;
return persianCulture;
//*****************************************************************************
//*************************2008-04-02 By A. Samarian*****End*******************
//Modified:2010-09-18
//Modified by: Asad Samarian
//*****************************************************************************
}
开发者ID:saiesh86,项目名称:TravelBlog,代码行数:56,代码来源:CultureHelper.cs
示例17: 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 = string.Format("{0}/{1}/{2}", pcYear, pcMonth, pcDay);
return convertedDate;
}
开发者ID:e-safarzadeh,项目名称:Raybod.MSCRM.KandooWebSite,代码行数:10,代码来源:MeetingDetail.aspx.cs
示例18: getPersianDate
/// <summary>
/// متد تبدیل تاریخ میلادی به تاریخ شمسی
/// </summary>
/// <param name="dt">تاریخ میلادی</param>
/// <returns>تاریخ شمسی</returns>
public static string getPersianDate(DateTime dt)
{
PersianCalendar per = new PersianCalendar();
return (
"" + per.GetYear(dt) + "/" +
correctDate("" + per.GetMonth(dt)) + "/" +
correctDate("" + per.GetDayOfMonth(dt)) + " " +
correctDate(dt.Hour + "") + ":" +
correctDate(dt.Minute + "") + ":" +
correctDate(dt.Second + ""));
}
开发者ID:sunshinemistery,项目名称:Store,代码行数:16,代码来源:Utilities.cs
示例19: ConvertToPersianDatetime
public static DateTime ConvertToPersianDatetime(DateTime datetime)
{
var per = new PersianCalendar();
var year = per.GetYear(datetime);
var month = per.GetMonth(datetime);
var day = per.GetDayOfMonth(datetime);
var hour = per.GetHour(datetime);
var minute = per.GetMinute(datetime);
return new DateTime(year, month, day, hour, minute, 0);
}
开发者ID:Chitva,项目名称:Ganjine,代码行数:12,代码来源:CommonMethods.cs
示例20: ToPersian
public static string ToPersian(this DateTime date, string format = "yyyy/MM/dd")
{
var pc = new PersianCalendar();
var year = pc.GetYear(date).ToString();
var month = (pc.GetMonth(date) + 100).ToString().Substring(1);
var day = (pc.GetDayOfMonth(date) + 100).ToString().Substring(1);
var strdate = format;
strdate = strdate.Replace("yyyy", year);
strdate = strdate.Replace("MM", month);
strdate = strdate.Replace("dd", day);
return strdate;
}
开发者ID:aminsh,项目名称:Backend-Framework,代码行数:12,代码来源:DateTimeExtension.cs
注:本文中的System.Globalization.PersianCalendar类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论