本文整理汇总了C#中System.Globalization.PersianCalendar.GetMonth方法的典型用法代码示例。如果您正苦于以下问题:C# PersianCalendar.GetMonth方法的具体用法?C# PersianCalendar.GetMonth怎么用?C# PersianCalendar.GetMonth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.PersianCalendar
的用法示例。
在下文中一共展示了PersianCalendar.GetMonth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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());
}
示例4: 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");
}
示例5: PersianDate
public PersianDate(DateTime georgianDate)
{
var pc=new PersianCalendar();
Year = pc.GetYear(georgianDate);
Month = pc.GetMonth(georgianDate);
Day = pc.GetDayOfMonth(georgianDate);
}
示例6: 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];
}
示例7: 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;
}
示例8: setDate
public string setDate()
{
PersianCalendar pdate = new PersianCalendar();
DateTime nT = new DateTime();
nT = DateTime.Now;
string mounth = "";
if (pdate.GetMonth(nT).ToString().Length == 1)
mounth = "0" + pdate.GetMonth(nT).ToString();
else
mounth = pdate.GetMonth(nT).ToString();
string day = "";
if (pdate.GetDayOfMonth(nT).ToString().Length == 1)
day = "0" + pdate.GetDayOfMonth(nT).ToString();
else
day = pdate.GetDayOfMonth(nT).ToString();
string date = String.Format("{0}/{1}/{2}", pdate.GetYear(nT), mounth, day);
return date;
}
示例9: 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;
}
示例10: 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 + ""));
}
示例11: 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;
}
示例12: getBeforeMonth
public static string getBeforeMonth()
{
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);
if(month!=1)
return year + "/" + (month-1).ToString("00") + "/" + day.ToString("00");
else
return (year-1) + "/12/" + day.ToString("00");
}
示例13: 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);
}
示例14: ToPersianDateByFirstDayOfMonth
public static string ToPersianDateByFirstDayOfMonth(this DateTime date, string seperator)
{
PersianCalendar persianCalendar = new PersianCalendar();
StringBuilder stringBuilder = new StringBuilder();
int year = persianCalendar.GetYear(date);
stringBuilder.Append(year.ToString("0000"));
stringBuilder.Append(seperator);
int month = persianCalendar.GetMonth(date);
stringBuilder.Append(month.ToString("00"));
stringBuilder.Append(seperator);
stringBuilder.Append("01");
return stringBuilder.ToString();
}
示例15: TestCalendarConversion
public void TestCalendarConversion()
{
PersianCalendar cal = new PersianCalendar();
int i = 0;
while (i < s_dates.Length)
{
DateTime date = new DateTime(s_dates[i + 3], s_dates[i + 4], s_dates[i + 5]);
Assert.True(cal.GetYear(date) == s_dates[i], String.Format("Calculated Persian Year {0} not equal the expected year {1}", cal.GetYear(date), s_dates[i]));
Assert.True(cal.GetMonth(date) == s_dates[i + 1], String.Format("Calculated Persian Month {0} not equal the expected Month {1}", cal.GetMonth(date), s_dates[i + 1]));
Assert.True(cal.GetDayOfMonth(date) == s_dates[i + 2], String.Format("Calculated Persian Day {0} not equal the expected Day {1}", cal.GetDayOfMonth(date), s_dates[i + 2]));
DateTime result = cal.ToDateTime(s_dates[i], s_dates[i + 1], s_dates[i + 2], 0, 0, 0, 0);
Assert.True(result.Year == s_dates[i + 3], String.Format("Calculated Gregorian Year {0} not equal the expected year {1}", result.Year, s_dates[i + 3]));
Assert.True(result.Month == s_dates[i + 4], String.Format("Calculated Gregorian Month {0} not equal the expected Month {1}", result.Month, s_dates[i + 4]));
Assert.True(result.Day == s_dates[i + 5], String.Format("Calculated Gregorian Day {0} not equal the expected Day {1}", result.Day, s_dates[i + 5]));
i += 6;
}
}