JapaneseCalendar.IsLeapDay(Int32, Int32, Int32, Int32) Método

Definición

Determina si la fecha especificada de la era especificada es un día bisiesto.

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

Parámetros

year
Int32

Entero que representa el año.

month
Int32

Entero de 1 a 12 que representa el mes.

day
Int32

Entero de 1 a 31 que representa el día.

era
Int32

Entero que representa la era.

Devoluciones

true si el día especificado es un día bisiesto; en caso contrario, false.

Excepciones

year está fuera del intervalo que admite el calendario.

o bien

month está fuera del intervalo que admite el calendario.

o bien

day está fuera del intervalo que admite el calendario.

o bien

era está fuera del intervalo que admite el calendario.

Ejemplos

En el ejemplo siguiente se llama IsLeapDay al último día del segundo mes (febrero) durante cinco años en cada una de las eras. La era actual en la salida de ejemplo es la era Reiwa.


using namespace System;
using namespace System::Globalization;

int main()
{
   // Creates and initializes a JapaneseCalendar.
   JapaneseCalendar^ myCal = gcnew JapaneseCalendar;
   
   // Creates a holder for the last day of the second month (February)->
   int iLastDay;
   
   // Displays the header.
   Console::Write( "YEAR\t" );
   for ( int y = 1; y <= 5; y++ )
      Console::Write( "\t {0}", y );
   Console::WriteLine();
   
   // Checks five years in the current era.
   Console::Write( "CurrentEra:" );
   for ( int y = 1; y <= 5; y++ )
   {
      iLastDay = myCal->GetDaysInMonth( y, 2, JapaneseCalendar::CurrentEra );
      Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, JapaneseCalendar::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 = 1; y <= 5; 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            1       2       3       4       5
CurrentEra:     False   True    False   False   False
Era 5:          False   True    False   False   False
Era 4:          False   False   False   True    False
Era 3:          False   False   True    False   False
Era 2:          True    False   False   False   True
Era 1:          True    False   False   False   True

*/
using System;
using System.Globalization;

public class SamplesJapaneseCalendar
{
   public static void Main()
   {
      // Creates and initializes a JapaneseCalendar.
      JapaneseCalendar myCal = new JapaneseCalendar();

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

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

      // Checks five years in the current era.
      Console.Write( "CurrentEra:" );
      for ( int y = 1; y <= 5; y++ )  {
         iLastDay = myCal.GetDaysInMonth( y, 2, JapaneseCalendar.CurrentEra );
         Console.Write( "\t{0}", myCal.IsLeapDay( y, 2, iLastDay, JapaneseCalendar.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 = 1; y <= 5; 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            1       2       3       4       5
CurrentEra:     False   True    False   False   False
Era 5:          False   True    False   False   False
Era 4:          False   False   False   True    False
Era 3:          False   False   True    False   False
Era 2:          True    False   False   False   True
Era 1:          True    False   False   False   True

*/
Imports System.Globalization

Public Class SamplesJapaneseCalendar   
   Public Shared Sub Main()
      ' Creates and initializes a JapaneseCalendar.
      Dim myCal As New JapaneseCalendar()

      ' 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 = 1 To 5
         Console.Write(ControlChars.Tab + "{0}", y)
      Next y
      Console.WriteLine()

      ' Checks five years in the current era.
      Console.Write("CurrentEra:")
      For y = 1 To 5
         iLastDay = myCal.GetDaysInMonth(y, 2, JapaneseCalendar.CurrentEra)
         Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapDay(y, 2, iLastDay, JapaneseCalendar.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 = 1 To 5
            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            1       2       3       4       5
'      CurrentEra:     False   True    False   False   False
'      Era 5:          False   True    False   False   False
'      Era 4:          False   False   False   True    False
'      Era 3:          False   False   True    False   False
'      Era 2:          True    False   False   False   True
'      Era 1:          True    False   False   False   True

Comentarios

Los años bisiestos del calendario japonés corresponden a los mismos años bisiestos en el calendario gregoriano. Un año bisiesto en el calendario gregoriano se define como un año gregoriano que es divisible uniformemente por cuatro, excepto si es divisible en 100. Sin embargo, los años gregorianos que son divisibles en 400 años son bisiestos. Un año común tiene 365 días y un año bisiesto tiene 366 días.

Un día bisiesto es un día que solo se produce en un año bisiesto. Por ejemplo, el día 29 de Nigatsu (febrero) es el único día bisiesto.

Se aplica a

Consulte también