Język

KoreanCalendar.IsLeapDay(Int32, Int32, Int32, Int32) Metoda

Definicja

Określa, czy określona data w określonej erze jest dniem przestępnym.

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

Parametry

year
Int32

Liczba całkowita reprezentująca rok.

month
Int32

Liczba całkowita z zakresu od 1 do 12, która reprezentuje miesiąc.

day
Int32

Liczba całkowita z zakresu od 1 do 31, która reprezentuje dzień.

era
Int32

Liczba całkowita reprezentująca erę.

Zwraca

true jeśli określony dzień jest dniem przestępnym; w przeciwnym razie, false.

Wyjątki

year znajduje się poza zakresem obsługiwanym przez kalendarz.

— lub —

month znajduje się poza zakresem obsługiwanym przez kalendarz.

— lub —

day znajduje się poza zakresem obsługiwanym przez kalendarz.

— lub —

era znajduje się poza zakresem obsługiwanym przez kalendarz.

Przykłady

W poniższym przykładzie jest wywoływany IsLeapDay ostatni dzień drugiego miesiąca (luty) przez pięć lat w każdej z epok.

using System;
using System.Globalization;

public class SamplesKoreanCalendar  {

   public static void Main()  {

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

      // Creates a holder for the last day of the second month (February).
      int iLastDay;

      // Displays the header.
      Console.Write( "YEAR\t" );
      for ( int y = 4334; y <= 4338; y++ )
         Console.Write( "\t{0}", y );
      Console.WriteLine();

      // Checks five years in the current era.
      Console.Write( "CurrentEra:" );
      for ( int y = 4334; y <= 4338; y++ )  {
         iLastDay = myCal.GetDaysInMonth( y, 2, KoreanCalendar.CurrentEra );
         Console.Write( "\t{0}", myCal.IsLeapDay( y, 2, iLastDay, KoreanCalendar.CurrentEra ) );
      }
      Console.WriteLine();

      // Checks five years in each of the eras.
      for ( int i = 0; i < myCal.Eras.Length; i++ )  {
         Console.Write( "Era {0}:\t", myCal.Eras[i] );
         for ( int y = 4334; y <= 4338; y++ )  {
            iLastDay = myCal.GetDaysInMonth( y, 2, myCal.Eras[i] );
            Console.Write( "\t{0}", myCal.IsLeapDay( y, 2, iLastDay, myCal.Eras[i] ) );
         }
         Console.WriteLine();
      }
   }
}

/*
This code produces the following output.

YEAR            4334    4335    4336    4337    4338
CurrentEra:     False   False   False   True    False
Era 1:          False   False   False   True    False

*/
Imports System.Globalization

Public Class SamplesKoreanCalendar   
   
   Public Shared Sub Main()

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

      ' Creates a holder for the last day of the second month (February).
      Dim iLastDay As Integer

      ' Displays the header.
      Console.Write("YEAR" + ControlChars.Tab)
      Dim y As Integer
      For y = 4334 To 4338
         Console.Write(ControlChars.Tab + "{0}", y)
      Next y
      Console.WriteLine()

      ' Checks five years in the current era.
      Console.Write("CurrentEra:")
      For y = 4334 To 4338
         iLastDay = myCal.GetDaysInMonth(y, 2, KoreanCalendar.CurrentEra)
         Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapDay(y, 2, iLastDay, KoreanCalendar.CurrentEra))
      Next y
      Console.WriteLine()

      ' Checks five years in each of the eras.
      Dim i As Integer
      For i = 0 To myCal.Eras.Length - 1
         Console.Write("Era {0}:" + ControlChars.Tab, myCal.Eras(i))
         For y = 4334 To 4338
            iLastDay = myCal.GetDaysInMonth(y, 2, myCal.Eras(i))
            Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapDay(y, 2, iLastDay, myCal.Eras(i)))
         Next y
         Console.WriteLine()
      Next i

   End Sub

End Class


'This code produces the following output.
'
'YEAR            4334    4335    4336    4337    4338
'CurrentEra:     False   False   False   True    False
'Era 1:          False   False   False   True    False

Uwagi

Lata przestępne w kalendarzu koreańskim odpowiadają tym samym latom przestępnym w kalendarzu gregoriańskim. Rok przestępny w kalendarzu gregoriańskim jest definiowany jako rok gregoriański, który jest równomiernie podzielny przez cztery, chyba że jest podzielny przez 100. Jednak lata gregoriański, które są podzielne przez 400 lat przestępnych. Wspólny rok ma 365 dni, a rok przestępny ma 366 dni.

Dzień przestępny to dzień, który występuje tylko w roku przestępnym. Na przykład 29 dzień lutego jest jedynym dniem przestępnym.

Dotyczy

Zobacz też