GregorianCalendar.IsLeapMonth(Int32, Int32, Int32) Metode

Definisi

Menentukan apakah bulan yang ditentukan dalam tahun yang ditentukan di era yang ditentukan adalah bulan kampung.

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

Parameter

year
Int32

Bilangan bulat yang mewakili tahun.

month
Int32

Bilangan bulat dari 1 hingga 12 yang mewakili bulan tersebut.

era
Int32

Bilangan bulat yang mewakili era.

Mengembalikan

Metode ini selalu mengembalikan false, kecuali ditimpa oleh kelas turunan.

Pengecualian

era berada di luar rentang yang didukung oleh kalender.

-atau-

year berada di luar rentang yang didukung oleh kalender.

-atau-

month berada di luar rentang yang didukung oleh kalender.

Contoh

Contoh kode berikut memanggil IsLeapMonth untuk semua bulan dalam lima tahun di era saat ini.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a GregorianCalendar.
   GregorianCalendar^ myCal = gcnew 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

*/
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

Keterangan

Tahun kabut dalam kalender Gregorian didefinisikan sebagai tahun yang dapat dibagi secara merata oleh empat, kecuali jika dapat dibagi dengan 100. Namun, tahun yang terbagi oleh 400 adalah tahun kampung. Misalnya, tahun 1900 bukan tahun kabut asap, tetapi tahun 2000. Tahun umum memiliki 365 hari dan tahun kaap memiliki 366 hari.

Bulan kampung adalah sebulan penuh yang hanya terjadi pada tahun kampung. Kalender Gregorian tidak memiliki bulan kampung.

Berlaku untuk

Lihat juga