当前位置: 首页>>代码示例>>C#>>正文


C# PersianCalendar.GetYear方法代码示例

本文整理汇总了C#中System.Globalization.PersianCalendar.GetYear方法的典型用法代码示例。如果您正苦于以下问题:C# PersianCalendar.GetYear方法的具体用法?C# PersianCalendar.GetYear怎么用?C# PersianCalendar.GetYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.PersianCalendar的用法示例。


在下文中一共展示了PersianCalendar.GetYear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例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: 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

示例6: 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

示例7: SetYearDropDownList

        public static DropDownList SetYearDropDownList(DropDownList yearDropList, int yearShowNum)
        {
            PersianCalendar pcal = new PersianCalendar();
            DateTime today = DateTime.Today;
            int maxYear = pcal.GetYear(today.AddDays(2));
            for (int i = maxYear; i > maxYear - yearShowNum; i--)
                yearDropList.Items.Add(new ListItem(i.ToString(), i.ToString()));
            return yearDropList;

        }
开发者ID:sinaaslani,项目名称:kids.bmi.ir,代码行数:10,代码来源:Common.cs

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例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");
 }
开发者ID:irania,项目名称:tirax,代码行数:12,代码来源:PersianDate.cs

示例13: ToPersianFullName

		public static string ToPersianFullName(this DateTime date)
		{
			PersianCalendar persianCalendar = new PersianCalendar();
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(date.ToPersianWeekDayName());
			stringBuilder.Append(" ");
			stringBuilder.Append(persianCalendar.GetDayOfMonth(date));
			stringBuilder.Append(" ");
			stringBuilder.Append(date.ToPersianMonthName());
			stringBuilder.Append(" ");
			stringBuilder.Append(persianCalendar.GetYear(date));
			return stringBuilder.ToString();
		}
开发者ID:aminmesbahi,项目名称:BlogEngine.NET,代码行数:13,代码来源:Persian.cs

示例14: 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;
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:22,代码来源:PersianCalendarTest.cs

示例15: TestUpperLimits

        public void TestUpperLimits()
        {
            PersianCalendar cal = new PersianCalendar();

            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                cal.ToDateTime(9378, 10, 14, 0, 0, 0, 0);
            });
            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                cal.GetYear(new DateTime(622, 3, 21));
            });
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:PersianCalendarTest.cs


注:本文中的System.Globalization.PersianCalendar.GetYear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。