JulianCalendar.IsLeapMonth(Int32, Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷指定紀元的指定年份中指定的月份是否為閏月。
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
參數
- year
- Int32
表示年份的整數。
- month
- Int32
從 1 到 12 的整數,表示月份。
- era
- Int32
表示紀元的整數。
傳回
這個方法永遠傳回 false
,除非被衍生類別 (Derived Class) 所覆寫。
例外狀況
範例
下列範例會呼叫 IsLeapMonth 目前紀元中五年的所有月份。
using namespace System;
using namespace System::Globalization;
int main()
{
// Creates and initializes a JulianCalendar.
JulianCalendar^ myCal = gcnew JulianCalendar;
// 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, JulianCalendar::CurrentEra );
for ( int m = 1; m <= iMonthsInYear; m++ )
Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, JulianCalendar::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 SamplesJulianCalendar {
public static void Main() {
// Creates and initializes a JulianCalendar.
JulianCalendar myCal = new JulianCalendar();
// 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, JulianCalendar.CurrentEra );
for ( int m = 1; m <= iMonthsInYear; m++ )
Console.Write( "\t{0}", myCal.IsLeapMonth( y, m, JulianCalendar.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 SamplesJulianCalendar
Public Shared Sub Main()
' Creates and initializes a JulianCalendar.
Dim myCal As New JulianCalendar()
' 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, JulianCalendar.CurrentEra)
Dim m As Integer
For m = 1 To iMonthsInYear
Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapMonth(y, m, JulianCalendar.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
備註
不同於公曆,Julian 行事歷會將閏年定義為四個平均除法的年份,但沒有任何例外狀況。 因此,行事曆每 128 年一天不正確。 例如,1999 年不是閏年,而是 2000 年。 一般年份有 365 天,而閏年有 366 天。
閏月是只發生在閏年中的整個月份。 Julian 行事曆沒有任何閏月。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應