PersianCalendar.TwoDigitYearMax 속성

정의

두 자릿수 연도로 표시할 수 있는 100년 범위의 마지막 연도를 가져오거나 설정합니다.

public:
 virtual property int TwoDigitYearMax { int get(); void set(int value); };
public override int TwoDigitYearMax { get; set; }
member this.TwoDigitYearMax : int with get, set
Public Overrides Property TwoDigitYearMax As Integer

속성 값

Int32

두 자릿수 연도로 표시할 수 있는 100년 범위의 마지막 연도입니다.

예외

이 달력이 읽기 전용인 경우

set 작업의 값이 100보다 작거나 9378보다 큰 경우

예제

다음 코드 예제에서는 TwoDigitYearMax 속성입니다.

using System;
using System.Globalization;

class Sample
{
    public static void Main()
    {
      PersianCalendar jc = new PersianCalendar();
      DateTime thisDate = DateTime.Now;

        //--------------------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------------------
      Console.WriteLine("\n........... Selected Properties .....................\n");
      Console.Write("Eras:");
      foreach (int era in jc.Eras)
      {
         Console.WriteLine(" era = {0}", era);
      }
        //--------------------------------------------------------------------------------
      Console.WriteLine("\nTwoDigitYearMax = {0}", jc.TwoDigitYearMax);
        //--------------------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------------------
      Console.WriteLine("\n............ Selected Methods .......................\n");

        //--------------------------------------------------------------------------------
      Console.WriteLine("GetDayOfYear: day = {0}", jc.GetDayOfYear(thisDate));
        //--------------------------------------------------------------------------------
      Console.WriteLine("GetDaysInMonth: days = {0}",
                        jc.GetDaysInMonth( thisDate.Year, thisDate.Month,
                        PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("GetDaysInYear: days = {0}",
                        jc.GetDaysInYear(thisDate.Year, PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("GetLeapMonth: leap month (if any) = {0}",
                        jc.GetLeapMonth(thisDate.Year, PersianCalendar.PersianEra));
        //-------------------------------------------------------------
      Console.WriteLine("GetMonthsInYear: months in a year = {0}",
                        jc.GetMonthsInYear(thisDate.Year, PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("IsLeapDay: This is a leap day = {0}",
                        jc.IsLeapDay(thisDate.Year, thisDate.Month, thisDate.Day,
                        PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("IsLeapMonth: This is a leap month = {0}",
                        jc.IsLeapMonth(thisDate.Year, thisDate.Month,
                        PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("IsLeapYear: 1370 is a leap year = {0}",
                        jc.IsLeapYear(1370, PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------

        // Get the 4-digit year for a year whose last two digits are 99. The 4-digit year
        // depends on the current value of the TwoDigitYearMax property.

      Console.WriteLine("ToFourDigitYear:");
      Console.WriteLine("  If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}",
                         jc.TwoDigitYearMax, jc.ToFourDigitYear(99));
      jc.TwoDigitYearMax = thisDate.Year;
      Console.WriteLine("  If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}",
                        jc.TwoDigitYearMax, jc.ToFourDigitYear(99));
    }
}
// The example displays the following output:
//       ........... Selected Properties .....................
//
//       Eras: era = 1
//
//       TwoDigitYearMax = 99
//
//       ............ Selected Methods .......................
//
//       GetDayOfYear: day = 1
//       GetDaysInMonth: days = 31
//       GetDaysInYear: days = 365
//       GetLeapMonth: leap month (if any) = 0
//       GetMonthsInYear: months in a year = 12
//       IsLeapDay: This is a leap day = False
//       IsLeapMonth: This is a leap month = False
//       IsLeapYear: 1370 is a leap year = True
//       ToFourDigitYear:
//         If TwoDigitYearMax = 99, ToFourDigitYear(99) = 99
//         If TwoDigitYearMax = 2012, ToFourDigitYear(99) = 1999
Imports System.Globalization

Class Sample
    Public Shared Sub Main()
        '--------------------------------------------------------------------------------
        ' Get today's date.
        '--------------------------------------------------------------------------------
        Dim jc As New PersianCalendar()
        Dim thisDate As Date = Date.Now

        '--------------------------------------------------------------------------------
        ' Properties
        '--------------------------------------------------------------------------------
        Console.WriteLine(vbCrLf & _
                          "........... Selected Properties ....................." & vbCrLf)
        Console.Write("Eras:")
        Dim era As Integer
        For Each era In jc.Eras
            Console.WriteLine(" era = {0}", era)
        Next era
        '--------------------------------------------------------------------------------
        Console.WriteLine("TwoDigitYearMax = {0}", jc.TwoDigitYearMax)
        '--------------------------------------------------------------------------------
        ' Methods
        '--------------------------------------------------------------------------------
        Console.WriteLine(vbCrLf & _
                          "............ Selected Methods ......................." & vbCrLf)

        '--------------------------------------------------------------------------------
        Console.WriteLine("GetDayOfYear: day = {0}", jc.GetDayOfYear(thisDate))
        '--------------------------------------------------------------------------------

        Console.WriteLine("GetDaysInMonth: days = {0}", _
                           jc.GetDaysInMonth(thisDate.Year, _
                                             thisDate.Month, _
                                             PersianCalendar.PersianEra))
        '--------------------------------------------------------------------------------
        Console.WriteLine("GetDaysInYear: days = {0}", _
                          jc.GetDaysInYear(thisDate.Year, PersianCalendar.PersianEra))
        '--------------------------------------------------------------------------------
        Console.WriteLine("GetLeapMonth: leap month (if any) = {0}", _
                           jc.GetLeapMonth(thisDate.Year, PersianCalendar.PersianEra))
        '--------------------------------------------------------------------------------
        Console.WriteLine("GetMonthsInYear: months in a year = {0}", _
                           jc.GetMonthsInYear(thisDate.Year, PersianCalendar.PersianEra))
        '--------------------------------------------------------------------------------
        Console.WriteLine("IsLeapDay: This is a leap day = {0}", _
                           jc.IsLeapDay(thisDate.Year, _
                                        thisDate.Month, thisDate.Day, _
                                        PersianCalendar.PersianEra))
        '--------------------------------------------------------------------------------
        Console.WriteLine("IsLeapMonth: This is a leap month = {0}", _
                           jc.IsLeapMonth(thisDate.Year, _
                                          thisDate.Month, _
                                          PersianCalendar.PersianEra))
        '--------------------------------------------------------------------------------
        Console.WriteLine("IsLeapYear: 1370 is a leap year = {0}", _
                           jc.IsLeapYear(1370, PersianCalendar.PersianEra))
        '--------------------------------------------------------------------------------

        ' Get the 4-digit year for a year whose last two digits are 99. The 4-digit year 
        ' depends on the current value of the TwoDigitYearMax property.

        Console.WriteLine("ToFourDigitYear:")
        Console.WriteLine("  If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", _
                          jc.TwoDigitYearMax, jc.ToFourDigitYear(99))
        jc.TwoDigitYearMax = thisDate.Year
        Console.WriteLine("  If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", _
                          jc.TwoDigitYearMax, jc.ToFourDigitYear(99))
    End Sub
End Class 
' The example displays output like the following: 
'       ........... Seleted Properties .....................
'       
'       Eras: era = 1
'       
'       TwoDigitYearMax = 99
'       
'       ............ Selected Methods .......................
'       
'       GetDayOfYear: day = 1
'       GetDaysInMonth: days = 31
'       GetDaysInYear: days = 365
'       GetLeapMonth: leap month (if any) = 0
'       GetMonthsInYear: months in a year = 12
'       IsLeapDay: This is a leap day = False
'       IsLeapMonth: This is a leap month = False
'       IsLeapYear: 1370 is a leap year = True
'       ToFourDigitYear:
'         If TwoDigitYearMax = 99, ToFourDigitYear(99) = 99
'         If TwoDigitYearMax = 2012, ToFourDigitYear(99) = 1999

설명

이 속성을 사용 하 여 두 자리 연도를 4 자리 연도로 올바르게 변환할 수 있습니다. 예를 들어이 속성이 2029로 설정 된 경우 100 년 범위는 1930에서 2029로 설정 됩니다. 따라서 2 자리 값 30은 1930으로 해석 되 고, 2 자리 값 29는 2029로 해석 됩니다.

이 속성의 초기 값은 제어판의 국가 및 언어 옵션 설정에서 파생 됩니다. 그러나이 정보는의 수명 동안 변경 될 수 있습니다 AppDomain . PersianCalendar클래스는 시스템 설정의 변경 내용을 자동으로 검색 하지 않습니다. 국가 및 언어 옵션에서 달력을 지원 하지 않는 경우이 속성의 초기 값이 calendar 클래스에서 정의한 기본값입니다.

애플리케이션을 99로 문자 그대로 해석 되도록 2 자리 연도이 값을 설정 해야 합니다. 예를 들어이 속성이 99로 설정 된 경우 100 년 범위는 0에서 (대부분의 달력에 대 한 유효한 값이 아님) 99 까지입니다. 따라서 2 자리 값 30은 30으로 해석 됩니다.

적용 대상

추가 정보