Calendar.IsLeapYear 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파생 클래스에 재정의될 때 지정된 연도가 윤년인지 여부를 확인합니다.
오버로드
IsLeapYear(Int32) |
지정된 연대의 지정된 연도가 윤년인지 여부를 확인합니다. |
IsLeapYear(Int32, Int32) |
파생 클래스에 재정의될 때 지정된 연대의 지정된 연도가 윤년인지 여부를 확인합니다. |
IsLeapYear(Int32)
- Source:
- Calendar.cs
- Source:
- Calendar.cs
- Source:
- Calendar.cs
지정된 연대의 지정된 연도가 윤년인지 여부를 확인합니다.
public:
virtual bool IsLeapYear(int year);
public virtual bool IsLeapYear (int year);
abstract member IsLeapYear : int -> bool
override this.IsLeapYear : int -> bool
Public Overridable Function IsLeapYear (year As Integer) As Boolean
매개 변수
- year
- Int32
연도를 나타내는 정수입니다.
반환
지정된 연도가 윤년이면 true
이고, 그렇지 않으면 false
입니다.
예외
year
가 달력에서 지원하는 범위 밖에 있는 경우
예제
다음 코드 예제에서는 클래스의 다양한 구현을 Calendar 비교합니다.
using namespace System;
using namespace System::Globalization;
int main()
{
// Creates an instance of every Calendar type.
array<Calendar^>^myCals = gcnew array<Calendar^>(8);
myCals[ 0 ] = gcnew GregorianCalendar;
myCals[ 1 ] = gcnew HebrewCalendar;
myCals[ 2 ] = gcnew HijriCalendar;
myCals[ 3 ] = gcnew JapaneseCalendar;
myCals[ 4 ] = gcnew JulianCalendar;
myCals[ 5 ] = gcnew KoreanCalendar;
myCals[ 6 ] = gcnew TaiwanCalendar;
myCals[ 7 ] = gcnew ThaiBuddhistCalendar;
// For each calendar, displays the current year, the number of months in that year,
// and the number of days in each month of that year.
int i;
int j;
int iYear;
int iMonth;
int iDay;
DateTime myDT = DateTime::Today;
for ( i = 0; i < myCals->Length; i++ )
{
iYear = myCals[ i ]->GetYear( myDT );
Console::WriteLine();
Console::WriteLine( " {0}, Year: {1}", myCals[ i ]->GetType(), myCals[ i ]->GetYear( myDT ) );
Console::WriteLine( " MonthsInYear: {0}", myCals[ i ]->GetMonthsInYear( iYear ) );
Console::WriteLine( " DaysInYear: {0}", myCals[ i ]->GetDaysInYear( iYear ) );
Console::WriteLine( " Days in each month:" );
Console::Write( " " );
for ( j = 1; j <= myCals[ i ]->GetMonthsInYear( iYear ); j++ )
Console::Write( " {0, -5}", myCals[ i ]->GetDaysInMonth( iYear, j ) );
Console::WriteLine();
iMonth = myCals[ i ]->GetMonth( myDT );
iDay = myCals[ i ]->GetDayOfMonth( myDT );
Console::WriteLine( " IsLeapDay: {0}", myCals[ i ]->IsLeapDay( iYear, iMonth, iDay ) );
Console::WriteLine( " IsLeapMonth: {0}", myCals[ i ]->IsLeapMonth( iYear, iMonth ) );
Console::WriteLine( " IsLeapYear: {0}", myCals[ i ]->IsLeapYear( iYear ) );
}
}
/*
This code produces the following output. The results vary depending on the date.
System::Globalization::GregorianCalendar, Year: 2002
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System::Globalization::HebrewCalendar, Year: 5763
MonthsInYear: 13
DaysInYear: 385
Days in each month:
30 30 30 29 30 30 29 30 29 30 29 30 29
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: True
System::Globalization::HijriCalendar, Year: 1423
MonthsInYear: 12
DaysInYear: 355
Days in each month:
30 29 30 29 30 29 30 29 30 29 30 30
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: True
System::Globalization::JapaneseCalendar, Year: 14
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System::Globalization::JulianCalendar, Year: 2002
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System::Globalization::KoreanCalendar, Year: 4335
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System::Globalization::TaiwanCalendar, Year: 91
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System::Globalization::ThaiBuddhistCalendar, Year: 2545
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
*/
using System;
using System.Globalization;
public class SamplesCalendar {
public static void Main() {
// Creates an instance of every Calendar type.
Calendar[] myCals = new Calendar[8];
myCals[0] = new GregorianCalendar();
myCals[1] = new HebrewCalendar();
myCals[2] = new HijriCalendar();
myCals[3] = new JapaneseCalendar();
myCals[4] = new JulianCalendar();
myCals[5] = new KoreanCalendar();
myCals[6] = new TaiwanCalendar();
myCals[7] = new ThaiBuddhistCalendar();
// For each calendar, displays the current year, the number of months in that year,
// and the number of days in each month of that year.
int i, j, iYear, iMonth, iDay;
DateTime myDT = DateTime.Today;
for ( i = 0; i < myCals.Length; i++ ) {
iYear = myCals[i].GetYear( myDT );
Console.WriteLine();
Console.WriteLine( "{0}, Year: {1}", myCals[i].GetType(), myCals[i].GetYear( myDT ) );
Console.WriteLine( " MonthsInYear: {0}", myCals[i].GetMonthsInYear( iYear ) );
Console.WriteLine( " DaysInYear: {0}", myCals[i].GetDaysInYear( iYear ) );
Console.WriteLine( " Days in each month:" );
Console.Write( " " );
for ( j = 1; j <= myCals[i].GetMonthsInYear( iYear ); j++ )
Console.Write( " {0,-5}", myCals[i].GetDaysInMonth( iYear, j ) );
Console.WriteLine();
iMonth = myCals[i].GetMonth( myDT );
iDay = myCals[i].GetDayOfMonth( myDT );
Console.WriteLine( " IsLeapDay: {0}", myCals[i].IsLeapDay( iYear, iMonth, iDay ) );
Console.WriteLine( " IsLeapMonth: {0}", myCals[i].IsLeapMonth( iYear, iMonth ) );
Console.WriteLine( " IsLeapYear: {0}", myCals[i].IsLeapYear( iYear ) );
}
}
}
/*
This code produces the following output. The results vary depending on the date.
System.Globalization.GregorianCalendar, Year: 2002
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System.Globalization.HebrewCalendar, Year: 5763
MonthsInYear: 13
DaysInYear: 385
Days in each month:
30 30 30 29 30 30 29 30 29 30 29 30 29
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: True
System.Globalization.HijriCalendar, Year: 1423
MonthsInYear: 12
DaysInYear: 355
Days in each month:
30 29 30 29 30 29 30 29 30 29 30 30
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: True
System.Globalization.JapaneseCalendar, Year: 14
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System.Globalization.JulianCalendar, Year: 2002
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System.Globalization.KoreanCalendar, Year: 4335
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System.Globalization.TaiwanCalendar, Year: 91
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
System.Globalization.ThaiBuddhistCalendar, Year: 2545
MonthsInYear: 12
DaysInYear: 365
Days in each month:
31 28 31 30 31 30 31 31 30 31 30 31
IsLeapDay: False
IsLeapMonth: False
IsLeapYear: False
*/
Imports System.Globalization
Public Class SamplesCalendar
Public Shared Sub Main()
' Creates an instance of every Calendar type.
Dim myCals(7) As Calendar
myCals(0) = New GregorianCalendar()
myCals(1) = New HebrewCalendar()
myCals(2) = New HijriCalendar()
myCals(3) = New JapaneseCalendar()
myCals(4) = New JulianCalendar()
myCals(5) = New KoreanCalendar()
myCals(6) = New TaiwanCalendar()
myCals(7) = New ThaiBuddhistCalendar()
' For each calendar, displays the current year, the number of months in that year,
' and the number of days in each month of that year.
Dim i, j, iYear, iMonth, iDay As Integer
Dim myDT As DateTime = DateTime.Today
For i = 0 To myCals.Length - 1
iYear = myCals(i).GetYear(myDT)
Console.WriteLine()
Console.WriteLine("{0}, Year: {1}", myCals(i).GetType(), myCals(i).GetYear(myDT))
Console.WriteLine(" MonthsInYear: {0}", myCals(i).GetMonthsInYear(iYear))
Console.WriteLine(" DaysInYear: {0}", myCals(i).GetDaysInYear(iYear))
Console.WriteLine(" Days in each month:")
Console.Write(" ")
For j = 1 To myCals(i).GetMonthsInYear(iYear)
Console.Write(" {0,-5}", myCals(i).GetDaysInMonth(iYear, j))
Next j
Console.WriteLine()
iMonth = myCals(i).GetMonth(myDT)
iDay = myCals(i).GetDayOfMonth(myDT)
Console.WriteLine(" IsLeapDay: {0}", myCals(i).IsLeapDay(iYear, iMonth, iDay))
Console.WriteLine(" IsLeapMonth: {0}", myCals(i).IsLeapMonth(iYear, iMonth))
Console.WriteLine(" IsLeapYear: {0}", myCals(i).IsLeapYear(iYear))
Next i
End Sub
End Class
'This code produces the following output. The results vary depending on the date.
'
'System.Globalization.GregorianCalendar, Year: 2002
' MonthsInYear: 12
' DaysInYear: 365
' Days in each month:
' 31 28 31 30 31 30 31 31 30 31 30 31
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: False
'
'System.Globalization.HebrewCalendar, Year: 5763
' MonthsInYear: 13
' DaysInYear: 385
' Days in each month:
' 30 30 30 29 30 30 29 30 29 30 29 30 29
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: True
'
'System.Globalization.HijriCalendar, Year: 1423
' MonthsInYear: 12
' DaysInYear: 355
' Days in each month:
' 30 29 30 29 30 29 30 29 30 29 30 30
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: True
'
'System.Globalization.JapaneseCalendar, Year: 14
' MonthsInYear: 12
' DaysInYear: 365
' Days in each month:
' 31 28 31 30 31 30 31 31 30 31 30 31
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: False
'
'System.Globalization.JulianCalendar, Year: 2002
' MonthsInYear: 12
' DaysInYear: 365
' Days in each month:
' 31 28 31 30 31 30 31 31 30 31 30 31
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: False
'
'System.Globalization.KoreanCalendar, Year: 4335
' MonthsInYear: 12
' DaysInYear: 365
' Days in each month:
' 31 28 31 30 31 30 31 31 30 31 30 31
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: False
'
'System.Globalization.TaiwanCalendar, Year: 91
' MonthsInYear: 12
' DaysInYear: 365
' Days in each month:
' 31 28 31 30 31 30 31 31 30 31 30 31
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: False
'
'System.Globalization.ThaiBuddhistCalendar, Year: 2545
' MonthsInYear: 12
' DaysInYear: 365
' Days in each month:
' 31 28 31 30 31 30 31 31 30 31 30 31
' IsLeapDay: False
' IsLeapMonth: False
' IsLeapYear: False
설명
달력 연도와 지구가 태양 주위를 회전하는 실제 시간 또는 달이 지구 주위를 회전하는 실제 시간의 차이를 만회하기 위해 윤년은 표준 달력 연도와 다른 일 수를 줍니다. 각 Calendar 구현은 윤년을 다르게 정의합니다.
추가 정보
적용 대상
IsLeapYear(Int32, Int32)
- Source:
- Calendar.cs
- Source:
- Calendar.cs
- Source:
- Calendar.cs
파생 클래스에 재정의될 때 지정된 연대의 지정된 연도가 윤년인지 여부를 확인합니다.
public:
abstract bool IsLeapYear(int year, int era);
public abstract bool IsLeapYear (int year, int era);
abstract member IsLeapYear : int * int -> bool
Public MustOverride Function IsLeapYear (year As Integer, era As Integer) As Boolean
매개 변수
- year
- Int32
연도를 나타내는 정수입니다.
- era
- Int32
연대를 나타내는 정수입니다.
반환
지정된 연도가 윤년이면 true
이고, 그렇지 않으면 false
입니다.
예외
설명
달력 연도와 지구가 태양 주위를 회전하는 실제 시간 또는 달이 지구 주위를 회전하는 실제 시간의 차이를 만회하기 위해 윤년은 표준 달력 연도와 다른 일 수를 줍니다. 각 Calendar 구현은 윤년을 다르게 정의합니다.
구현자 참고
파생 클래스는 매개 변수로 era
전달될 때 를 지원 CurrentEra 해야 합니다. 지원하는 CurrentEra 한 가지 방법은 달력의 현재 시대에 대한 값인 에 Eras[0]
저장된 값으로 바꾸는 것입니다.
추가 정보
적용 대상
.NET