PersianCalendar 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
페르시아력을 나타냅니다.
public ref class PersianCalendar : System::Globalization::Calendar
public class PersianCalendar : System.Globalization.Calendar
[System.Serializable]
public class PersianCalendar : System.Globalization.Calendar
type PersianCalendar = class
inherit Calendar
[<System.Serializable>]
type PersianCalendar = class
inherit Calendar
Public Class PersianCalendar
Inherits Calendar
- 상속
- 특성
예제
다음 예에서는 속성, 생성자 및 페르시아 달력의 ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) 메서드를 DateTime 사용하여 DateTime.Now 개체를 인스턴스화 DateTime 합니다. 그런 다음 양력과 페르시아 달력 모두에 이러한 날짜를 표시합니다. 또한 페르시아 달력의 날짜 범위도 표시합니다.
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
PersianCalendar pc = new PersianCalendar();
DateTime thisDate = DateTime.Now;
// Display the current date using the Gregorian and Persian calendars.
Console.WriteLine("Today in the Gregorian Calendar: {0:dddd}, {0}", thisDate);
Console.WriteLine("Today in the Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}\n",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate));
// Create a date using the Gregorian calendar.
thisDate = new DateTime(2013, 5, 28, 10, 35, 0);
Console.WriteLine("Gregorian Calendar: {0:D} ", thisDate);
Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}\n",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate));
// Create a date using the Persian calendar.
thisDate = pc.ToDateTime(1395, 4, 22, 12, 30, 0, 0);
Console.WriteLine("Gregorian Calendar: {0:D} ", thisDate);
Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}\n",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate));
// Show the Persian Calendar date range.
Console.WriteLine("Minimum Persian Calendar date (Gregorian Calendar): {0:D} ",
pc.MinSupportedDateTime);
Console.WriteLine("Minimum Persian Calendar date (Persian Calendar): " +
"{0}, {1}/{2}/{3} {4}:{5}:{6}\n",
pc.GetDayOfWeek(pc.MinSupportedDateTime),
pc.GetMonth(pc.MinSupportedDateTime),
pc.GetDayOfMonth(pc.MinSupportedDateTime),
pc.GetYear(pc.MinSupportedDateTime),
pc.GetHour(pc.MinSupportedDateTime),
pc.GetMinute(pc.MinSupportedDateTime),
pc.GetSecond(pc.MinSupportedDateTime));
Console.WriteLine("Maximum Persian Calendar date (Gregorian Calendar): {0:D} ",
pc.MaxSupportedDateTime);
Console.WriteLine("Maximum Persian Calendar date (Persian Calendar): " +
"{0}, {1}/{2}/{3} {4}:{5}:{6}\n",
pc.GetDayOfWeek(pc.MaxSupportedDateTime),
pc.GetMonth(pc.MaxSupportedDateTime),
pc.GetDayOfMonth(pc.MaxSupportedDateTime),
pc.GetYear(pc.MaxSupportedDateTime),
pc.GetHour(pc.MinSupportedDateTime),
pc.GetMinute(pc.MaxSupportedDateTime),
pc.GetSecond(pc.MaxSupportedDateTime));
}
}
// The example displays the following output when run under the .NET Framework 4.6:
// Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM
// Today in the Persian Calendar: Monday, 11/16/1391 9:11:36
//
// Gregorian Calendar: Tuesday, May 28, 2013
// Persian Calendar: Tuesday, 3/7/1392 10:35:0
//
// Gregorian Calendar: Tuesday, July 12, 2016
// Persian Calendar: Tuesday, 4/22/1395 12:30:0
//
// Minimum Persian Calendar date (Gregorian Calendar): Friday, March 22, 0622
// Minimum Persian Calendar date (Persian Calendar): Friday, 1/1/1 0:0:0
//
// Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999
// Maximum Persian Calendar date (Persian Calendar): Friday, 10/13/9378 0:59:59
//
// The example displays the following output when run under versions of
// the .NET Framework before the .NET Framework 4.6:
// Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM
// Today in the Persian Calendar: Monday, 11/16/1391 9:11:36
//
// Gregorian Calendar: Tuesday, May 28, 2013
// Persian Calendar: Tuesday, 3/7/1392 10:35:0
//
// Gregorian Calendar: Tuesday, July 12, 2016
// Persian Calendar: Tuesday, 4/22/1395 12:30:0
//
// Minimum Persian Calendar date (Gregorian Calendar): Thursday, March 21, 0622
// Minimum Persian Calendar date (Persian Calendar): Thursday, 1/1/1 0:0:0
//
// Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999
// Maximum Persian Calendar date (Persian Calendar): Friday, 10/10/9378 0:59:59
Imports System.Globalization
Module Example
Public Sub Main()
Dim pc As New PersianCalendar()
Dim thisDate As Date = Date.Now
' Display the current date using the Gregorian and Persian calendars.
Console.WriteLine("Today in the Gregorian Calendar: {0:dddd}, {0}", thisDate)
Console.WriteLine("Today in the Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate))
Console.WriteLine()
' Create a date using the Gregorian calendar.
thisDate = New DateTime(2013, 5, 28, 10, 35, 0)
Console.WriteLine("Gregorian Calendar: {0:D} ", thisDate)
Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate))
Console.WriteLine()
' Create a date using the Persian calendar.
thisDate = pc.ToDateTime(1395, 4, 22, 12, 30, 0, 0)
Console.WriteLine("Gregorian Calendar: {0:D} ", thisDate)
Console.WriteLine("Persian Calendar: {0}, {1}/{2}/{3} {4}:{5}:{6}",
pc.GetDayOfWeek(thisDate),
pc.GetMonth(thisDate),
pc.GetDayOfMonth(thisDate),
pc.GetYear(thisDate),
pc.GetHour(thisDate),
pc.GetMinute(thisDate),
pc.GetSecond(thisDate))
Console.WriteLine()
' Show the Persian Calendar date range.
Console.WriteLine("Minimum Persian Calendar date (Gregorian Calendar): {0:D} ",
pc.MinSupportedDateTime)
Console.WriteLine("Minimum Persian Calendar date (Persian Calendar): " +
"{0}, {1}/{2}/{3} {4}:{5}:{6}",
pc.GetDayOfWeek(pc.MinSupportedDateTime),
pc.GetMonth(pc.MinSupportedDateTime),
pc.GetDayOfMonth(pc.MinSupportedDateTime),
pc.GetYear(pc.MinSupportedDateTime),
pc.GetHour(pc.MinSupportedDateTime),
pc.GetMinute(pc.MinSupportedDateTime),
pc.GetSecond(pc.MinSupportedDateTime))
Console.WriteLine()
Console.WriteLine("Maximum Persian Calendar date (Gregorian Calendar): {0:D} ",
pc.MaxSupportedDateTime)
Console.WriteLine("Maximum Persian Calendar date (Persian Calendar): " +
"{0}, {1}/{2}/{3} {4}:{5}:{6}",
pc.GetDayOfWeek(pc.MaxSupportedDateTime),
pc.GetMonth(pc.MaxSupportedDateTime),
pc.GetDayOfMonth(pc.MaxSupportedDateTime),
pc.GetYear(pc.MaxSupportedDateTime),
pc.GetHour(pc.MinSupportedDateTime),
pc.GetMinute(pc.MaxSupportedDateTime),
pc.GetSecond(pc.MaxSupportedDateTime))
Console.WriteLine()
End Sub
End Module
' The example displays the following output when run under the .NET Framework 4.6:
' Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM
' Today in the Persian Calendar: Monday, 11/16/1391 9:11:36
'
' Gregorian Calendar: Tuesday, May 28, 2013
' Persian Calendar: Tuesday, 3/7/1392 10:35:0
'
' Gregorian Calendar: Tuesday, July 12, 2016
' Persian Calendar: Tuesday, 4/22/1395 12:30:0
'
' Minimum Persian Calendar date (Gregorian Calendar): Friday, March 22, 0622
' Minimum Persian Calendar date (Persian Calendar): Friday, 1/1/1 0:0:0
'
' Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999
' Maximum Persian Calendar date (Persian Calendar): Friday, 10/13/9378 0:59:59
'
' The example displays the following output when run under versions of
' the .NET Framework before the .NET Framework 4.6:
' Today in the Gregorian Calendar: Monday, 2/4/2013 9:11:36 AM
' Today in the Persian Calendar: Monday, 11/16/1391 9:11:36
'
' Gregorian Calendar: Tuesday, May 28, 2013
' Persian Calendar: Tuesday, 3/7/1392 10:35:0
'
' Gregorian Calendar: Tuesday, July 12, 2016
' Persian Calendar: Tuesday, 4/22/1395 12:30:0
'
' Minimum Persian Calendar date (Gregorian Calendar): Thursday, March 21, 0622
' Minimum Persian Calendar date (Persian Calendar): Thursday, 1/1/1 0:0:0
'
' Maximum Persian Calendar date (Gregorian Calendar): Friday, December 31, 9999
' Maximum Persian Calendar date (Persian Calendar): Friday, 10/10/9378 0:59:59
다음 예에서는 클래스의 필드, 속성 및 메서드 멤버를 보여 줍니다 PersianCalendar .
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
설명
이 API에 대한 자세한 내용은 페르시아어Calendar에 대한 추가 API 설명을 참조하세요.
생성자
PersianCalendar() |
PersianCalendar 클래스의 새 인스턴스를 초기화합니다. |
필드
CurrentEra |
현재 달력의 현재 연대를 나타냅니다. 이 필드의 값은 0입니다. (다음에서 상속됨 Calendar) |
PersianEra |
현재 연대를 나타냅니다. 이 필드는 상수입니다. |
속성
AlgorithmType |
현재 달력이 양력인지, 음력인지 또는 음양력인지를 나타내는 값을 가져옵니다. |
AlgorithmType |
현재 달력이 양력인지, 음력인지 또는 두 가지를 조합한 것인지를 나타내는 값을 가져옵니다. (다음에서 상속됨 Calendar) |
DaysInYearBeforeMinSupportedYear |
MinSupportedDateTime 속성에서 지정한 연도 이전 연도의 일 수를 가져옵니다. (다음에서 상속됨 Calendar) |
Eras |
PersianCalendar 개체에 있는 연대의 목록을 가져옵니다. |
IsReadOnly |
이 Calendar 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다. (다음에서 상속됨 Calendar) |
MaxSupportedDateTime |
PersianCalendar 클래스에서 지원하는 마지막 날짜와 시간을 가져옵니다. |
MinSupportedDateTime |
PersianCalendar 클래스에서 지원하는 시작 날짜와 시간을 가져옵니다. |
TwoDigitYearMax |
두 자릿수 연도로 표시할 수 있는 100년 범위의 마지막 연도를 가져오거나 설정합니다. |
메서드
적용 대상
추가 정보
.NET