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


C# PersianCalendar.IsLeapYear方法代码示例

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


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

示例1: TestLeapYears

        public void TestLeapYears()
        {
            PersianCalendar cal = new PersianCalendar();
            int lastNonLeap = 1;

            foreach (int year in s_leapYears)
            {
                Assert.True(cal.IsLeapYear(year), String.Format("Year {0} is not recognized as leap year", year));
                Assert.False(cal.IsLeapYear(lastNonLeap), String.Format("Year {0} is recognized as leap year", lastNonLeap));
                lastNonLeap = year - 1;
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:12,代码来源:PersianCalendarTest.cs

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

示例3: GenerateData

 public void GenerateData()
 {
     var maxYear = PersianYearMonthDayCalculator.MaxPersianYear;
     var bcl = new PersianCalendar();
     byte[] data = new byte[maxYear / 8 + 1];
     // We don't really care whether IsLeapYear(MaxPersianYear+1) returns true or false,
     // but it must be valid to call it.
     for (int year = 1; year <= maxYear; year++)
     {
         if (bcl.IsLeapYear(year))
         {
             data[year >> 3] |= (byte)(1 << (year & 7));
         }
     }
     var base64 = Convert.ToBase64String(data);
     var lineLength = 80;
     for (int start = 0; start < base64.Length; start += lineLength)
     {
         var line = base64.Substring(start, Math.Min(lineLength, base64.Length - start));
         var last = start + lineLength >= base64.Length;
         Console.WriteLine($"\"{line}\"{(last ? "" : " +")}");
     }
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:23,代码来源:PersianCalendarSystemTest.cs

示例4: IsPersianYearLeap

        public bool IsPersianYearLeap(int persianYear)
        {
            var pc = new PersianCalendar();

            return pc.IsLeapYear(persianYear);
        }
开发者ID:arabsoheyl,项目名称:fardis,代码行数:6,代码来源:DateTimeHelper.cs

示例5: MonthMostmonth

 private static void MonthMostmonth(int D, int M, int Y, int d, int m, int y)
 {
     var pc = new PersianCalendar();
         _mAge = (M - 1) - m;
         _yAge = Y - y;
         if ((pc.IsLeapYear(Y) && !pc.IsLeapYear(y)) || (pc.IsLeapYear(Y) && pc.IsLeapYear(y)) || (!pc.IsLeapYear(Y) && !pc.IsLeapYear(y)))
         {
             if (M >= 1 && M <= 6)
             {
                 _dAge = (D + 31) - d;
                 _dAge += _yAge / 4;
             }
         }
         if (!pc.IsLeapYear(Y) && pc.IsLeapYear(y))
         {
             if (M >= 1 && M <= 6)
             {
                 _dAge = (D + 31) - d;
                 _dAge += (_yAge / 4) + 1;
             }
             else if (M >= 7 && M <= 11)
             {
                 _dAge = (D + 30) - d;
                 _dAge += (_yAge / 4) + 2;
             }
             else if (M == 12)
             {
                 _dAge = (D + 29) - d;
                 _dAge += (_yAge / 4) + 3;
             }
         }
         if ((pc.IsLeapYear(Y) && !pc.IsLeapYear(y)) || (pc.IsLeapYear(Y) && pc.IsLeapYear(y)))
         {
             if (M >= 7 && M <= 12)
             {
                 _dAge = (D + 30) - d;
                 _dAge += (_yAge / 4) + 1;
             }
         }
         if (!pc.IsLeapYear(Y) && !pc.IsLeapYear(y))
         {
             if (M >= 7 && M <= 11)
             {
                 _dAge = (D + 30) - d;
                 _dAge += (_yAge / 4) + 1;
             }
             else if (M == 12)
             {
                 _dAge = (D + 29) - d;
                 _dAge += (_yAge / 4) + 2;
             }
         }
 }
开发者ID:omidnasri,项目名称:Implement-a-Generic-Repository-and-a-Unit-of-Work-Class,代码行数:53,代码来源:KDateTime.cs

示例6: MonthLessmonth

        private static void MonthLessmonth(int D, int M, int Y, int d, int m, int y)
        {
            PersianCalendar pc = new PersianCalendar();
                _mAge = ((M - 1) + 12) - m;
                _yAge = (Y - 1) - y;
                if (pc.IsLeapYear(Y) && pc.IsLeapYear(y))
                {
                    if (M >= 1 && M <= 6)
                    {
                        _dAge = (D + 31) - d;

                        if (m > 1 && m <= 6)
                            _dAge += (_yAge / 4) + 1;

                        else if (m >= 7 && m <= 11)
                            _dAge += (_yAge / 4);

                        if (m == 12)
                            _dAge += (_yAge / 4) - 1;

                    }
                    ///////////////////////
                    if (M >= 7 && M <= 11)
                    {
                        _dAge = (D + 30) - d;

                        if (m > 7 && m <= 11)
                            _dAge += (_yAge / 4) + 1;

                        if (m == 12)
                            _dAge += (_yAge / 4);
                    }

                }
                //////////////////////////////////////////////
                if (!pc.IsLeapYear(Y) && pc.IsLeapYear(y))
                {
                    if (M >= 1 && M <= 6)
                    {
                        _dAge = (D + 31) - d;

                        if (m >= 1 && m <= 6)
                            _dAge += (_yAge / 4) + 1;

                        if (m >= 7 && m <= 12)
                            _dAge += (_yAge / 4);

                    }
                    if (M >= 7 && M <= 11)
                    {
                        _dAge = (D + 30) - d;

                        if (m >= 7 && m <= 11)
                            _dAge += (_yAge / 4) + 1;

                        if (m == 12)
                            _dAge += (_yAge / 4);
                    }
                }
                ///////////////////////////////////////////
                if (!pc.IsLeapYear(Y) && !pc.IsLeapYear(y))
                {
                    if (M >= 1 && M <= 6)
                    {
                        _dAge = (D + 31) - d;

                        if (m >= 1 && m <= 6)
                            _dAge += (_yAge / 4);

                        else if (m >= 7 && m <= 11)
                            _dAge += (_yAge / 4) - 1;

                        else if (m == 12)
                            _dAge += (_yAge / 4) - 2;

                    }
                    else if (M >= 7 && M <= 11)
                    {
                        _dAge = (D + 30) - d;

                        if (m >= 7 && m <= 11)
                            _dAge += _yAge / 4;

                        if (m == 12)
                            _dAge += (_yAge / 4) - 1;

                    }
                }
                //////////////////////////////////////////
                if (pc.IsLeapYear(Y) && !pc.IsLeapYear(y))
                {
                    if (M >= 1 && M <= 6)
                    {
                        _dAge = (D + 31) - d;

                        if (m >= 1 && m <= 6)
                            _dAge += (_yAge / 4);

                        if (m >= 7 && m <= 11)
                            _dAge += (_yAge / 4) - 1;
//.........这里部分代码省略.........
开发者ID:omidnasri,项目名称:Implement-a-Generic-Repository-and-a-Unit-of-Work-Class,代码行数:101,代码来源:KDateTime.cs

示例7: MonthEqualemonth

        private static void MonthEqualemonth(int D, int M, int Y, int d, int m, int y)
        {
            PersianCalendar pc = new PersianCalendar();
                _mAge = ((M - 1) + 12) - m;
                _yAge = (Y - 1) - y;

                if (M >= 1 && M <= 6)
                    _dAge = (D + 31) - d;

                else if (M >= 7 && M <= 11)
                    _dAge = (D + 30) - d;

                else if (M == 12)
                {
                    if (pc.IsLeapYear(Y))
                        _dAge = (D + 30) - d;

                    else
                        _dAge = (D + 29) - d;
                }
                if (pc.IsLeapYear(y) && !pc.IsLeapYear(Y))
                    _dAge += (_yAge / 4) + 1;

                if ((!pc.IsLeapYear(Y) && !pc.IsLeapYear(y)) || (pc.IsLeapYear(Y) && !pc.IsLeapYear(y)))
                    _dAge += (_yAge / 4);

                if (pc.IsLeapYear(Y) && pc.IsLeapYear(y))
                    _dAge += (_yAge / 4) + 1;
        }
开发者ID:omidnasri,项目名称:Implement-a-Generic-Repository-and-a-Unit-of-Work-Class,代码行数:29,代码来源:KDateTime.cs

示例8: GenerateLeapYearData

 /// <summary>
 /// This method is only present to make it simple to generate the data.
 /// </summary>
 /// <returns></returns>
 internal static string GenerateLeapYearData()
 {
     var bcl = new PersianCalendar();
     byte[] data = new byte[MaxPersianYear / 8 + 1];
     // We don't really care whether IsLeapYear(MaxPersianYear+1) returns true or false,
     // but it must be valid to call it.
     for (int year = 1; year <= MaxPersianYear; year++)
     {
         if (bcl.IsLeapYear(year))
         {
             data[year >> 3] |= (byte)(1 << (year & 7));
         }
     }
     return Convert.ToBase64String(data);
 }
开发者ID:nicklbailey,项目名称:nodatime,代码行数:19,代码来源:PersianYearMonthDayCalculator.cs

示例9: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            long s1,s2;
            bool IsLeapYear;
            long year = 0;
            try
            {
                year = Convert.ToInt64(textBox1.Text);
                if (year <= 0)
                {

                    if (radioButton1.Checked || radioButton3.Checked)
                        throw new MinusException();
                }
                if (radioButton2.Checked)
                {
                    IsLeapYear = false;
                    GregorianCalendar gc = new GregorianCalendar(); 
                    if (DateTime.IsLeapYear((int)year)||gc.IsLeapYear((int)year))
                        IsLeapYear = true;
                    else
                        IsLeapYear = false;
                    if (IsLeapYear)
                        MessageBox.Show("Year " + year + " is a leap year", "Leap Year");
                    else
                        MessageBox.Show("Year " + year + " is not a leap year", "Leap Year");
                }
                
                if (radioButton5.Checked && year>0)
                {
                    IsLeapYear = false;
                    if (year % 4 == 0 && year % 100 != 0)
                        IsLeapYear = true;
                    if (year % 400 == 0)
                        IsLeapYear = true;
                    if (IsLeapYear)
                        MessageBox.Show("Year " + year + " is a leap year", "Leap Year");
                    else
                        MessageBox.Show("Year " + year + " is not a leap year", "Leap Year");
                }
                else if (year < 0 && radioButton5.Checked)
                    MessageBox.Show("Year must be positive","Error");
                if (radioButton1.Checked && year > 0)
                {
                    IsLeapYear = false;
                    s1 = (year + 2346) % 2820;
                    if (s1 == 0)
                    {
                        IsLeapYear = true;
                    }
                    else
                    {
                        s2 = s1 % 128;
                        switch (s2)
                        {
                            case 0:
                                IsLeapYear = true;
                                break;
                            case 5:
                                IsLeapYear = true;
                                break;
                            case 9:
                                IsLeapYear = true;
                                break;
                            case 13:
                                IsLeapYear = true;
                                break;
                            case 17:
                                IsLeapYear = true;
                                break;
                            case 21:
                                IsLeapYear = true;
                                break;
                            case 25:
                                IsLeapYear = true;
                                break;
                            case 29:
                                IsLeapYear = true;
                                break;
                            case 34:
                                IsLeapYear = true;
                                break;
                            case 38:
                                IsLeapYear = true;
                                break;
                            case 42:
                                IsLeapYear = true;
                                break;
                            case 46:
                                IsLeapYear = true;
                                break;
                            case 50:
                                IsLeapYear = true;
                                break;
                            case 54:
                                IsLeapYear = true;
                                break;
                            case 58:
                                IsLeapYear = true;
                                break;
//.........这里部分代码省略.........
开发者ID:ssd352,项目名称:Leap-Year-Detector,代码行数:101,代码来源:Form1.cs


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