UmAlQuraCalendar.GetEra(DateTime) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した日付が発生する時代 (年号) を計算します。
public:
override int GetEra(DateTime time);
public override int GetEra (DateTime time);
override this.GetEra : DateTime -> int
Public Overrides Function GetEra (time As DateTime) As Integer
パラメーター
- time
- DateTime
読み取る日付値。
戻り値
常に UmAlQuraEra 値を返します。
例外
time
が、このカレンダーでサポートされている範囲外です。
例
次の例では、Um Al Qura カレンダーの日付の複数のコンポーネントの値を表示します。
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
DateTime date1 = new DateTime(2011, 4, 3, new GregorianCalendar());
Calendar cal = new UmAlQuraCalendar();
Console.WriteLine("{0:MMMM d, yyyy} in the Gregorian calendar is equivalent to:", date1);
DisplayCalendarInfo(cal, date1);
// Add 2 years and 10 months by calling UmAlQuraCalendar methods.
date1 = cal.AddYears(date1, 2);
date1 = cal.AddMonths(date1, 10);
Console.WriteLine("After adding 2 years and 10 months in the {0} calendar,",
GetCalendarName(cal));
Console.WriteLine("{0:MMMM d, yyyy} in the Gregorian calendar is equivalent to:", date1);
DisplayCalendarInfo(cal, date1);
}
private static void DisplayCalendarInfo(Calendar cal, DateTime date1)
{
Console.WriteLine(" Calendar: {0}", GetCalendarName(cal));
Console.WriteLine(" Era: {0}", cal.GetEra(date1));
Console.WriteLine(" Year: {0}", cal.GetYear(date1));
Console.WriteLine(" Month: {0}", cal.GetMonth(date1));
Console.WriteLine(" DayOfYear: {0}", cal.GetDayOfYear(date1));
Console.WriteLine(" DayOfMonth: {0}", cal.GetDayOfMonth(date1));
Console.WriteLine(" DayOfWeek: {0}\n", cal.GetDayOfWeek(date1));
}
private static string GetCalendarName(Calendar cal)
{
return cal.ToString().Replace("System.Globalization.", "").
Replace("Calendar", "");
}
}
// The example displays the following output:
// April 3, 2011 in the Gregorian calendar is equivalent to:
// Calendar: UmAlQura
// Era: 1
// Year: 1432
// Month: 4
// DayOfYear: 118
// DayOfMonth: 29
// DayOfWeek: Sunday
//
// After adding 2 years and 10 months in the UmAlQura calendar,
// January 1, 2014 in the Gregorian calendar is equivalent to:
// Calendar: UmAlQura
// Era: 1
// Year: 1435
// Month: 2
// DayOfYear: 59
// DayOfMonth: 29
// DayOfWeek: Wednesday
Imports System.Globalization
Module Example
Public Sub Main()
Dim date1 As Date = New Date(2011, 4, 3, New GregorianCalendar())
Dim cal As New UmAlQuraCalendar()
Console.WriteLine("{0:MMMM d, yyyy} in the Gregorian calendar is equivalent to:", date1)
DisplayCalendarInfo(cal, date1)
' Add 2 years and 10 months by calling UmAlQuraCalendar methods.
date1 = cal.AddYears(date1, 2)
date1 = cal.AddMonths(date1, 10)
Console.WriteLine("After adding 2 years and 10 months in the {0} calendar,",
GetCalendarName(cal))
Console.WriteLine("{0:MMMM d, yyyy} in the Gregorian calendar is equivalent to:", date1)
DisplayCalendarInfo(cal, date1)
End Sub
Private Sub DisplayCalendarInfo(cal As Calendar, date1 As Date)
Console.WriteLine(" Calendar: {0}", GetCalendarName(cal))
Console.WriteLine(" Era: {0}", cal.GetEra(date1))
Console.WriteLine(" Year: {0}", cal.GetYear(date1))
Console.WriteLine(" Month: {0}", cal.GetMonth(date1))
Console.WriteLine(" DayOfYear: {0}", cal.GetDayOfYear(date1))
Console.WriteLine(" DayOfMonth: {0}", cal.GetDayOfMonth(date1))
Console.WriteLine(" DayOfWeek: {0}", cal.GetDayOfWeek(date1))
Console.WriteLine()
End Sub
Private Function GetCalendarName(cal As Calendar) As String
Return cal.ToString().Replace("System.Globalization.", "").
Replace("Calendar", "")
End Function
End Module
' The example displays the following output:
' April 3, 2011 in the Gregorian calendar is equivalent to:
' Calendar: UmAlQura
' Era: 1
' Year: 1432
' Month: 4
' DayOfYear: 118
' DayOfMonth: 29
' DayOfWeek: Sunday
'
' After adding 2 years and 10 months in the UmAlQura calendar,
' January 1, 2014 in the Gregorian calendar is equivalent to:
' Calendar: UmAlQura
' Era: 1
' Year: 1435
' Month: 2
' DayOfYear: 59
' DayOfMonth: 29
' DayOfWeek: Wednesday
注釈
Um Al Qura カレンダーは、A.H. (ラテン語の "Anno Hegirae" (移行の年) を意味する 1 つの時代を認識します。これは、ムハンマド (PBUH) の移動を参照して、カハマド (PBUH) を表します。
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET