GregorianCalendar.IsLeapDay(Int32, Int32, Int32, Int32) GregorianCalendar.IsLeapDay(Int32, Int32, Int32, Int32) GregorianCalendar.IsLeapDay(Int32, Int32, Int32, Int32) GregorianCalendar.IsLeapDay(Int32, Int32, Int32, Int32) Method

Definición

Determina si la fecha especificada de la era especificada es un día bisiesto.Determines whether the specified date in the specified era is a leap day.

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 Int32 Int32 Int32

Un entero que representa el año.An integer that represents the year.

month
Int32 Int32 Int32 Int32

Entero de 1 a 12 que representa el mes.An integer from 1 to 12 that represents the month.

day
Int32 Int32 Int32 Int32

Entero de 1 a 31 que representa el día.An integer from 1 to 31 that represents the day.

era
Int32 Int32 Int32 Int32

Un entero que representa la era.An integer that represents the era.

Devoluciones

Es true si el día especificado es un día bisiesto; en caso contrario, es false.true if the specified day is a leap day; otherwise, false.

Excepciones

era está fuera del intervalo admitido por el calendario.era is outside the range supported by the calendar.

-o bien--or- year está fuera del intervalo admitido por el calendario.year is outside the range supported by the calendar.

-o bien--or- month está fuera del intervalo admitido por el calendario.month is outside the range supported by the calendar.

-o bien--or- day está fuera del intervalo admitido por el calendario.day is outside the range supported by the calendar.

Ejemplos

En el ejemplo de código siguiente se llama a IsLeapDay para el último día del segundo mes (febrero) durante cinco años en cada una de las eras.The following code example calls IsLeapDay for the last day of the second month (February) for five years in each of the eras.

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

*/
using System;
using System.Globalization;


public class SamplesGregorianCalendar  {

   public static void Main()  {

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

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

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

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

*/
Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Public Class SamplesGregorianCalendar   
   
   Public Shared Sub Main()

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

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

      ' Checks five years in the current era.
      Console.Write("CurrentEra:")
      For y = 2001 To 2005
         iLastDay = myCal.GetDaysInMonth(y, 2, GregorianCalendar.CurrentEra)
         Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapDay(y, 2, iLastDay, GregorianCalendar.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 = 2001 To 2005
            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 'Main 

End Class 'SamplesGregorianCalendar


'This code produces the following output.

'

'YEAR            2001    2002    2003    2004    2005

'CurrentEra:     False   False   False   True    False

'Era 1:          False   False   False   True    False


Comentarios

En el calendario gregoriano un año bisiesto se define como un año divisible por cuatro, excepto si es divisible por 100.A leap year in the Gregorian calendar is defined as a year that is evenly divisible by four, except if it is divisible by 100. Sin embargo, los años que son divisibles por 400 son años bisiestos.However, years that are divisible by 400 are leap years. Por ejemplo, el año 1900 no fue un año bisiesto, pero fue el año 2000.For example, the year 1900 was not a leap year, but the year 2000 was. Un año normal tiene 365 días y un año bisiesto tiene 366 días.A common year has 365 days and a leap year has 366 days.

Un día bisiesto es un día que se produce solo en un año bisiesto.A leap day is a day that occurs only in a leap year. En el calendario gregoriano, el día 29 de febrero es el único día bisiesto.In the Gregorian calendar, the 29th day of February is the only leap day.

Se aplica a

Consulte también: