GregorianCalendar.IsLeapMonth(Int32, Int32, Int32) Metod

Definition

Avgör om den angivna månaden under det angivna året i den angivna eran är en skottmånad.

public:
 override bool IsLeapMonth(int year, int month, int era);
public override bool IsLeapMonth(int year, int month, int era);
override this.IsLeapMonth : int * int * int -> bool
Public Overrides Function IsLeapMonth (year As Integer, month As Integer, era As Integer) As Boolean

Parametrar

year
Int32

Ett heltal som representerar året.

month
Int32

Ett heltal från 1 till 12 som representerar månaden.

era
Int32

Ett heltal som representerar eran.

Returer

Den här metoden returnerar falsealltid , om den inte åsidosätts av en härledd klass.

Undantag

era ligger utanför det intervall som stöds av kalendern.

-eller-

year ligger utanför det intervall som stöds av kalendern.

-eller-

month ligger utanför det intervall som stöds av kalendern.

Exempel

I följande kodexempel anropas IsLeapMonth för alla månader under fem år i den aktuella eran.

using System;
using System.Globalization;

public class SamplesGregorianCalendar  {

   public static void Main()  {

      // Creates and initializes a GregorianCalendar.
      GregorianCalendar myCal = new GregorianCalendar();

      // Checks all the months in five years in the current era.
      int iMonthsInYear;
      for ( int y = 2001; y <= 2005; y++ )  {
         Console.Write( "{0}:\t", y );
         iMonthsInYear = myCal.GetMonthsInYear( y, GregorianCalendar.CurrentEra );
         for ( int m = 1; m <= iMonthsInYear; m++ )
            Console.Write( "\t{0}", myCal.IsLeapMonth( y, m, GregorianCalendar.CurrentEra ) );
         Console.WriteLine();
      }
   }
}

/*
This code produces the following output.

2001:           False   False   False   False   False   False   False   False   False   False   False   False
2002:           False   False   False   False   False   False   False   False   False   False   False   False
2003:           False   False   False   False   False   False   False   False   False   False   False   False
2004:           False   False   False   False   False   False   False   False   False   False   False   False
2005:           False   False   False   False   False   False   False   False   False   False   False   False

*/
Imports System.Globalization

Public Class SamplesGregorianCalendar   
   
   Public Shared Sub Main()

      ' Creates and initializes a GregorianCalendar.
      Dim myCal As New GregorianCalendar()

      ' Checks all the months in five years in the current era.
      Dim iMonthsInYear As Integer
      Dim y As Integer
      For y = 2001 To 2005
         Console.Write("{0}:" + ControlChars.Tab, y)
         iMonthsInYear = myCal.GetMonthsInYear(y, GregorianCalendar.CurrentEra)
         Dim m As Integer
         For m = 1 To iMonthsInYear
            Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapMonth(y, m, GregorianCalendar.CurrentEra))
         Next m
         Console.WriteLine()
      Next y

   End Sub

End Class


'This code produces the following output.
'
'2001:           False   False   False   False   False   False   False   False   False   False   False   False
'2002:           False   False   False   False   False   False   False   False   False   False   False   False
'2003:           False   False   False   False   False   False   False   False   False   False   False   False
'2004:           False   False   False   False   False   False   False   False   False   False   False   False
'2005:           False   False   False   False   False   False   False   False   False   False   False   False

Kommentarer

Ett skottår i den gregorianska kalendern definieras som ett år som är jämnt delbart med fyra, förutom om det är delbart med 100. Men år som är delbara med 400 är skottår. År 1900 var till exempel inte ett skottår, men år 2000 var det. Ett vanligt år har 365 dagar och ett skottår har 366 dagar.

En skottmånad är en hel månad som bara inträffar under ett skottår. Den gregorianska kalendern har inga skottmånader.

Gäller för

Se även