次の方法で共有


TaiwanCalendar.IsLeapDay メソッド (Int32, Int32, Int32, Int32)

指定した時代 (年号) の指定した日付が閏日かどうかを確認します。

Overrides Overloads Public Function IsLeapDay( _
   ByVal year As Integer, _   ByVal month As Integer, _   ByVal day As Integer, _   ByVal era As Integer _) As Boolean
[C#]
public override bool IsLeapDay(intyear,intmonth,intday,intera);
[C++]
public: bool IsLeapDay(intyear,intmonth,intday,intera);
[JScript]
public override function IsLeapDay(
   year : int,month : int,day : int,era : int) : Boolean;

パラメータ

  • year
    年を表す整数。
  • month
    月を表す 1 ~ 12 の整数。
  • day
    日を表す 1 ~ 31 の整数。
  • era
    時代 (年号) を表す整数。

戻り値

指定した日が閏日である場合は true 。それ以外の場合は false

例外

例外の種類 条件
ArgumentOutOfRangeException year が暦でサポートされている範囲外の値です。

または

month が暦でサポートされている範囲外の値です。

または

day が暦でサポートされている範囲外の値です。

または

era が暦でサポートされている範囲外の値です。

解説

台湾暦の閏年は、グレゴリオ暦の同じ閏年に対応しています。グレゴリオ暦の閏年は、100 で割り切れる年を除く、4 で割り切れるグレゴリオ暦年として定義されていますが、400 で割り切れるグレゴリオ暦年は閏年になります。平年の日数は 365 日で、閏年の日数は 366 日です。

閏日は、閏年にだけ訪れる日です。たとえば、2 月 29 日は唯一の閏日です。

使用例

[Visual Basic, C#, C++] 各時代 (年号) の 5 年ごとの 2 番目の月 (2 月) の最後の日の IsLeapDay を呼び出す例を次に示します。

 
Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Public Class SamplesTaiwanCalendar   
   
   Public Shared Sub Main()

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

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

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


'This code produces the following output.

'

'YEAR            90      91      92      93      94

'CurrentEra:     False   False   False   True    False

'Era 1:          False   False   False   True    False



[C#] 
using System;
using System.Globalization;


public class SamplesTaiwanCalendar  {

   public static void Main()  {

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

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

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

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

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

int main()  {

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

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

   // Displays the header.
   Console::Write( S"YEAR\t" );
   for ( int y = 90; y <= 94; y++ )
      Console::Write( S"\t{0}", __box(y));
   Console::WriteLine();

   // Checks five years in the current era.
   Console::Write( S"CurrentEra:" );
   for ( int y = 90; y <= 94; y++ )  {
      iLastDay = myCal->GetDaysInMonth( y, 2, TaiwanCalendar::CurrentEra );
      Console::Write( S"\t{0}", __box(myCal->IsLeapDay( y, 2, iLastDay, TaiwanCalendar::CurrentEra )));
   }
   Console::WriteLine();

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

}

/*
This code produces the following output.

YEAR            90      91      92      93      94
CurrentEra:     False   False   False   True    False
Era 1:          False   False   False   True    False

*/

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

TaiwanCalendar クラス | TaiwanCalendar メンバ | System.Globalization 名前空間 | TaiwanCalendar.IsLeapDay オーバーロードの一覧 | CurrentEra | Eras | GetMonthsInYear | GetDaysInMonth | IsLeapYear | IsLeapMonth