UmAlQuraCalendar.GetMonth(DateTime) 메서드

정의

지정된 날짜가 나타나는 월을 계산합니다.

public:
 override int GetMonth(DateTime time);
public override int GetMonth (DateTime time);
override this.GetMonth : DateTime -> int
Public Overrides Function GetMonth (time As DateTime) As Integer

매개 변수

time
DateTime

읽을 날짜 값입니다. UmAlQuraCalendar 클래스에서는 1900년 4월 30일 00시 00분 00초(양력 날짜)에서 2077년 11월 16일 23시 59분 59초(양력 날짜) 사이의 날짜만 지원합니다.

반환

Int32

time 매개변수에서 지정하는 날짜의 월을 나타내는 1에서 12 사이의 정수입니다.

예외

time 은 이 달력에서 지원하는 범위를 벗어납니다.

예제

다음 예제에서는 양력 및 Um Al Qura 달력에서 클래스에서 지원하는 UmAlQuraCalendar 날짜 범위를 표시합니다. 이 GetMonth 메서드는 현재 문화권의 현재 달력이 아닌 경우 Um Al Qura 달력에서 지원되는 최소 및 최대 날짜의 월을 검색하는 데 사용됩니다.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      Calendar cal = new UmAlQuraCalendar();
      DateTime minDate = cal.MinSupportedDateTime;
      DateTime maxDate = cal.MaxSupportedDateTime;

      Console.WriteLine("Range of the Um Al Qura calendar:");
      // Is UmAlQuraCalendar the current calendar?
      if (DateTimeFormatInfo.CurrentInfo.Calendar.ToString().Contains("UmAlQura")) {
         Calendar greg = new GregorianCalendar();
         Console.WriteLine("   Minimum: {0:d2}/{1:d2}/{2:d4} {3:HH:mm:ss} Gregorian, {3:MM/dd/yyyy HH:mm:ss} Um Al Qura",
                           greg.GetMonth(minDate), greg.GetDayOfMonth(minDate),
                           greg.GetYear(minDate), minDate);
         Console.WriteLine("   Maximum: {0:d2}/{1:d2}/{2:d4} {3:HH:mm:ss} Gregorian, {3:MM/dd/yyyy HH:mm:ss} Um Al Qura",
                           greg.GetMonth(maxDate), greg.GetDayOfMonth(maxDate),
                           greg.GetYear(maxDate), maxDate);
      }
      // Is Gregorian the current calendar?
      else if (DateTimeFormatInfo.CurrentInfo.Calendar.ToString().Contains("Gregorian")) {
         Console.WriteLine("   Minimum: {0:d} {0:HH:mm:ss} Gregorian, {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} Um Al Qura",
                           minDate, cal.GetMonth(minDate), cal.GetDayOfMonth(minDate),
                           cal.GetYear(minDate));
         Console.WriteLine("   Maximum: {0:d} {0:HH:mm:ss} Gregorian, {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} Um Al Qura",
                           maxDate, cal.GetMonth(maxDate), cal.GetDayOfMonth(maxDate),
                           cal.GetYear(maxDate));
      }
      // Display ranges if some other calendar is current.
      else {
         GregorianCalendar greg = new GregorianCalendar();
         Console.WriteLine("   Minimum: {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} " +
                           "Gregorian, {4:d2}/{5:d2}/{6:d4} {0:HH:mm:ss} Um Al Qura",
                           minDate, greg.GetMonth(minDate), greg.GetDayOfMonth(minDate),
                           greg.GetYear(minDate), cal.GetMonth(minDate), cal.GetDayOfMonth(minDate),
                           cal.GetYear(minDate));
         Console.WriteLine("   Maximum: {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} " +
                           "Gregorian, {4:d2}/{5:d2}/{6:d4} {0:HH:mm:ss} Um Al Qura",
                           maxDate, greg.GetMonth(maxDate), greg.GetDayOfMonth(maxDate),
                           greg.GetYear(maxDate), cal.GetMonth(maxDate), cal.GetDayOfMonth(maxDate),
                           cal.GetYear(maxDate));
      }
   }
}
// The example displays output similar to the following:
//    Range of the Um Al Qura calendar:
//       Minimum: 4/30/1900 00:00:00 Gregorian, 01/01/1318 00:00:00 Um Al Qura
//       Maximum: 5/13/2029 23:59:59 Gregorian, 12/29/1450 23:59:59 Um Al Qura
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim cal As New UmAlQuraCalendar()
      Dim minDate As Date = cal.MinSupportedDateTime
      Dim maxDate As Date = cal.MaxSupportedDateTime
      
      Console.WriteLine("Range of the Um Al Qura calendar:")
      ' Is UmAlQuraCalendar the current calendar?
      If DateTimeFormatInfo.CurrentInfo.Calendar.ToString().Contains("UmAlQura") Then
         Dim greg As New GregorianCalendar()
         Console.WriteLine("   Minimum: {0:d2}/{1:d2}/{2:d4} {3:HH:mm:ss} Gregorian, {3:MM/dd/yyyy HH:mm:ss} Um Al Qura",
                           greg.GetMonth(minDate), greg.GetDayOfMonth(minDate),
                           greg.GetYear(minDate), minDate)
         Console.WriteLine("   Maximum: {0:d2}/{1:d2}/{2:d4} {3:HH:mm:ss} Gregorian, {3:MM/dd/yyyy HH:mm:ss} Um Al Qura",
                           greg.GetMonth(maxDate), greg.GetDayOfMonth(maxDate),
                           greg.GetYear(maxDate), maxDate)
      ' Is Gregorian the current calendar?
      ElseIf DateTimeFormatInfo.CurrentInfo.Calendar.ToString().Contains("Gregorian") Then         
         Console.WriteLine("   Minimum: {0:d} {0:HH:mm:ss} Gregorian, {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} Um Al Qura",
                           minDate, cal.GetMonth(minDate), cal.GetDayOfMonth(minDate),
                           cal.GetYear(minDate))
         Console.WriteLine("   Maximum: {0:d} {0:HH:mm:ss} Gregorian, {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} Um Al Qura",
                           maxDate, cal.GetMonth(maxDate), cal.GetDayOfMonth(maxDate),
                           cal.GetYear(maxDate))
      ' Display ranges if some other calendar is current.
      Else
         Dim greg As New GregorianCalendar()          
         Console.WriteLine("   Minimum: {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} " + 
                           "Gregorian, {4:d2}/{5:d2}/{6:d4} {0:HH:mm:ss} Um Al Qura",
                           minDate, greg.GetMonth(minDate), greg.GetDayOfMonth(minDate), 
                           greg.GetYear(minDate), cal.GetMonth(minDate), cal.GetDayOfMonth(minDate),
                           cal.GetYear(minDate))
         Console.WriteLine("   Maximum: {1:d2}/{2:d2}/{3:d4} {0:HH:mm:ss} " + 
                           "Gregorian, {4:d2}/{5:d2}/{6:d4} {0:HH:mm:ss} Um Al Qura",
                           maxDate, greg.GetMonth(maxDate), greg.GetDayOfMonth(maxDate), 
                           greg.GetYear(maxDate), cal.GetMonth(maxDate), cal.GetDayOfMonth(maxDate),
                           cal.GetYear(maxDate))
      End If
   End Sub
End Module
' The example displays output similar to the following:
'    Range of the Um Al Qura calendar:
'       Minimum: 4/30/1900 00:00:00 Gregorian, 01/01/1318 00:00:00 Um Al Qura
'       Maximum: 5/13/2029 23:59:59 Gregorian, 12/29/1450 23:59:59 Um Al Qura

적용 대상

추가 정보