GregorianCalendar.IsLeapMonth(Int32, Int32, Int32) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Bestimmt, ob der angegebene Monat des angegebenen Jahres im angegebenen Zeitraum ein Schaltmonat ist.
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
Eine ganze Zahl, die das Jahr darstellt.
- month
- Int32
Eine ganze Zahl zwischen 1 und 12, die den Monat darstellt.
- era
- Int32
Eine ganze Zahl, die den Zeitraum darstellt.
Gibt zurück
Diese Methode gibt immer false
zurück, sofern sie nicht von einer abgeleiteten Klasse überschrieben wurde.
Ausnahmen
era
liegt außerhalb des Bereichs, der vom Kalender unterstützt wird.
oder -
year
liegt außerhalb des Bereichs, der vom Kalender unterstützt wird.oder -
month
liegt außerhalb des Bereichs, der vom Kalender unterstützt wird.
Beispiele
Im folgenden Codebeispiel wird IsLeapMonth für alle Monate in fünf Jahren in der aktuellen Ära aufgerufen.
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
Hinweise
Ein Schaltjahr im gregorianischen Kalender wird als Jahr definiert, das sogar von vier teilbar ist, außer wenn es um 100 teilbar ist. Jahre, die von 400 teilbar sind, sind jedoch Sprungjahre. Das Jahr 1900 war beispielsweise kein Schaltjahr, aber das Jahr 2000 war. Ein allgemeines Jahr verfügt über 365 Tage und ein Schaltjahr hat 366 Tage.
Ein Schaltmonat ist ein ganzes Monat, der nur in einem Schaltjahr auftritt. Der gregorianische Kalender hat keine Sprungmonate.