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


C# GregorianCalendar.GetMonth方法代码示例

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


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

示例1: EncodeDate

        public static int EncodeDate(DateTime d)
        {
            int day, month, year;
            int c, ya;

            GregorianCalendar calendar = new GregorianCalendar();

            day = calendar.GetDayOfMonth(d);
            month = calendar.GetMonth(d);
            year = calendar.GetYear(d);

            if (month > 2)
            {
                month -= 3;
            }
            else
            {
                month += 9;
                year -= 1;
            }

            c = year / 100;
            ya = year - 100 * c;

            return ((146097 * c) / 4 + (1461 * ya) / 4 + (153 * month + 2) / 5 + day + 1721119 - 2400001);
        }
开发者ID:kingpong,项目名称:NETProvider,代码行数:26,代码来源:TypeEncoder.cs

示例2: PosTest3

 public void PosTest3()
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
     int year, month;
     DateTime time;
     int expectedMonth, actualMonth;
     year = GetACommonYear(myCalendar);
     month = 2;
     time = myCalendar.ToDateTime(year, month, 28, 10, 20, 30, 0);
     expectedMonth = month;
     actualMonth = myCalendar.GetMonth(time);
     Assert.Equal(expectedMonth, actualMonth);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:GregorianCalendarGetMonth.cs

示例3: PosTest4

 public void PosTest4()
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
     int year, month;
     DateTime time;
     int expectedMonth, actualMonth;
     year = GetACommonYear(myCalendar);
     //Get a random value beween 1 and 12 not including 2.
     do
     {
         month = TestLibrary.Generator.GetInt32(-55) % 12 + 1;
     } while (2 == month);
     time = myCalendar.ToDateTime(year, month, 28, 10, 30, 20, 0);
     expectedMonth = month;
     actualMonth = myCalendar.GetMonth(time);
     Assert.Equal(expectedMonth, actualMonth);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:17,代码来源:GregorianCalendarGetMonth.cs

示例4: ShamsiTogregorian

 public DateTime ShamsiTogregorian(DateTime date)
 {
     PersianCalendar pc = new PersianCalendar();
     GregorianCalendar gcalendar = new GregorianCalendar();
     DateTime eDate = pc.ToDateTime(
            gcalendar.GetYear(date),
            gcalendar.GetMonth(date),
            gcalendar.GetDayOfMonth(date),
            gcalendar.GetHour(date),
            gcalendar.GetMinute(date),
            gcalendar.GetSecond(date), 0);
     return eDate;
 }
开发者ID:e-safarzadeh,项目名称:Raybod.MSCRM.KandooWebSite,代码行数:13,代码来源:TuitionRequest.aspx.cs

示例5: PosTest5

 public void PosTest5()
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
     int year, month;
     DateTime time;
     int expectedMonth, actualMonth;
     year = myCalendar.MinSupportedDateTime.Year;
     month = TestLibrary.Generator.GetInt32(-55) % 12 + 1;
     time = myCalendar.ToDateTime(year, month, 20, 8, 20, 30, 0);
     expectedMonth = month;
     actualMonth = myCalendar.GetMonth(time);
     Assert.Equal(expectedMonth, actualMonth);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:GregorianCalendarGetMonth.cs

示例6: PosTest8

 public void PosTest8()
 {
     System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
     int year, month;
     DateTime time;
     int expectedMonth, actualMonth;
     year = myCalendar.MaxSupportedDateTime.Year;
     month = 12;
     time = myCalendar.ToDateTime(year, month, 20, 8, 20, 30, 0);
     expectedMonth = month;
     actualMonth = myCalendar.GetMonth(time);
     Assert.Equal(expectedMonth, actualMonth);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:GregorianCalendarGetMonth.cs

示例7: HijriToGregorian

        /// <summary>
        /// Converts Hijri date To Gregorian date.
        /// </summary>
        public static void HijriToGregorian(
                    int inYear, int inMonth, int inDay,
                    out int outYear, out int outMonth, out int outDay)
        {
            var ys = inYear;
            var ms = inMonth;
            var ds = inDay;

            var sss = new GregorianCalendar();
            outYear = sss.GetYear(new DateTime(ys, ms, ds, new PersianCalendar()));
            outMonth = sss.GetMonth(new DateTime(ys, ms, ds, new PersianCalendar()));
            outDay = sss.GetDayOfMonth(new DateTime(ys, ms, ds, new PersianCalendar()));
        }
开发者ID:VahidN,项目名称:PdfReport,代码行数:16,代码来源:PersianDate.cs

示例8: CompareDatesIgnoringYear

        /// <summary>
        /// Compares two dates ignoring the year.
        /// </summary>
        /// <param name="date1">The first date to compare.</param>
        /// <param name="date2">The second date to compare.</param>
        /// <returns>-1 If the first date is anterior to the second date, 0 if the two dates are identical (to the day).</returns>
        public static int? CompareDatesIgnoringYear(DateTime? date1, DateTime? date2)
        {
            // Compare null dates
            var result = CompareNullDates(date1, date2);

            if (result ==null)
            {
                var calendar = new GregorianCalendar();
                var dateTime1 = (DateTime) date1;
                var dateTime2 = (DateTime) date2;

                if (calendar.GetMonth(dateTime1) < calendar.GetMonth(dateTime2))
                {
                    result = -1;
                }
                else if (calendar.GetMonth(dateTime1) > calendar.GetMonth(dateTime2))
                {
                    result = 1;
                }
                else 
                {
                    // Compare days
                    result = CompareDays(dateTime1, dateTime2);
                }
            }
            return result;
        }
开发者ID:pkubryk,项目名称:SummerBatch,代码行数:33,代码来源:DateUtils.cs

示例9: dateconvert

        public string dateconvert(string date)
        {
            string covertdate="";
            try
            {
                DateTime dt23 = Convert.ToDateTime(date);
                CultureInfo arCI = new CultureInfo("ar-SA");
                string ar = dt23.ToString(new CultureInfo("ar-SA"));
                GregorianCalendar enCalendar = new GregorianCalendar();
                int year = enCalendar.GetYear(dt23);
                int month = enCalendar.GetMonth(dt23);
                int day = enCalendar.GetDayOfMonth(dt23);
                covertdate = (string.Format("{0}-{1}-{2}", year, month, day));
            }
            catch
            {

                IFormatProvider culture = new CultureInfo("en-US", true);
                //DateTime dateVal = DateTime.ParseExact(date, "yyyy-MM-dd", culture);
                DateTime dt1 = DateTime.ParseExact(date, "dd/MM/yyyy", culture);
                CultureInfo arCI = new CultureInfo("en-US");
                string ar = date.ToString(new CultureInfo("en-US"));
                GregorianCalendar enCalendar = new GregorianCalendar();
                int year = enCalendar.GetYear(dt1);
                int month = enCalendar.GetMonth(dt1);
                int day = enCalendar.GetDayOfMonth(dt1);

                covertdate = (string.Format("{0}-{1}-{2}", year, month, day));

               // covertdate = dateVal.ToString("yyyy-MM-dd");

            }

            return (covertdate);
        }
开发者ID:tomasroy2015,项目名称:gbs-angular-html5,代码行数:35,代码来源:PropertyStatisticsController.cs

示例10: GetChristianDateTime

        public static DateTime GetChristianDateTime(string _Fdate)
        {
            _Fdate = _Fdate.Trim().Replace(':', '/').Replace('-', '/').Replace(' ', '/');
            var dateArray = new string[6];
            if (_Fdate.Length <= 10)
            {
                _Fdate = _Fdate + "/0/0/0";
            }
            dateArray = _Fdate.Split('/');

            PersianCalendar pcalendar = new PersianCalendar();
            GregorianCalendar gcalendar = new GregorianCalendar();
            DateTime eDate = pcalendar.ToDateTime(
                    gcalendar.GetYear(new DateTime(int.Parse(dateArray[0]), 1, 1)),
                    gcalendar.GetMonth(new DateTime(1395, int.Parse(dateArray[1]), 1)),
                    gcalendar.GetDayOfMonth(new DateTime(1395, 1, int.Parse(dateArray[2]))),
                    gcalendar.GetHour(new DateTime(1395, 1, 1, int.Parse(dateArray[3]), 0, 0)),
                    gcalendar.GetMinute(new DateTime(1395, 1, 1, 1, int.Parse(dateArray[4]), 0)),
                    gcalendar.GetSecond(new DateTime(1395, 1, 1, 1, 1, int.Parse(dateArray[5]))), 0);
            return eDate;
        }
开发者ID:ehsmohammadi,项目名称:BTE.RMS,代码行数:21,代码来源:MeetingsController.cs


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