GregorianCalendarTypes-Enumeration
Definiert die verschiedenen Sprachversionen des gregorianischen Kalenders.
Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration GregorianCalendarTypes
'Usage
Dim instance As GregorianCalendarTypes
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum GregorianCalendarTypes
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum class GregorianCalendarTypes
/** @attribute SerializableAttribute() */
/** @attribute ComVisibleAttribute(true) */
public enum GregorianCalendarTypes
SerializableAttribute
ComVisibleAttribute(true)
public enum GregorianCalendarTypes
Member
Membername | Beschreibung | |
---|---|---|
Arabic | Bezieht sich auf die arabische Version des gregorianischen Kalenders. | |
Localized | Bezieht sich auf die lokalisierte Version des gregorianischen Kalenders und beruht auf der Sprache der CultureInfo, die die DateTimeFormatInfo verwendet. | |
MiddleEastFrench | Bezieht sich auf französische Version des gregorianischen Kalenders für den arabischen Sprachraum. | |
TransliteratedEnglish | Bezieht sich auf die transliterierte englische Version des gregorianischen Kalenders. | |
TransliteratedFrench | Bezieht sich auf die transliterierte französische Version des gregorianischen Kalenders. | |
USEnglish | Bezieht sich auf die transliterierte englische Version (US-Version) des gregorianischen Kalenders. |
Hinweise
Die dem GregorianCalendar zugeordneten Muster für Datum und Uhrzeit unterscheiden sich je nach Sprache. Wenn der GregorianCalendar in DateTimeFormatInfo.Calendar ausgewählt ist, kann mithilfe von GregorianCalendarTypes angegeben werden, welche Muster für Datum und Uhrzeit in dieser DateTimeFormatInfo verwendet werden sollen.
Für arabische Kulturen sind mehrere Sprachversionen des gregorianischen Kalenders verfügbar. Sie können z. B. die französische Version von GregorianCalendar mit dem Wert MiddleEastFrench verwenden.
Von einer Kultur, die GregorianCalendar unterstützt, werden evtl. nicht alle Sprachversionen von GregorianCalendar unterstützt. Die von einer bestimmten Kultur unterstützten Kalender werden durch die CultureInfo.Calendar-Eigenschaft und die CultureInfo.OptionalCalendars-Eigenschaft angegeben. Wenn GregorianCalendar unterstützt wird, können mithilfe von CalendarType die unterstützten Sprachversionen von GregorianCalendar bestimmt werden.
Beispiel
In folgendem Codebeispiel wird veranschaulicht, wie die von der Kultur unterstützte Sprachversion des gregorianischen Kalenders bestimmt wird.
Imports System
Imports System.Globalization
Public Class SamplesCultureInfo
Public Shared Sub Main()
' Gets the calendars supported by the ar-SA culture.
Dim myOptCals As Calendar() = New CultureInfo("ar-SA").OptionalCalendars
' Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
Console.WriteLine("The ar-SA culture supports the following calendars:")
Dim cal As Calendar
For Each cal In myOptCals
If cal.GetType() Is GetType(GregorianCalendar) Then
Dim myGreCal As GregorianCalendar = CType(cal, GregorianCalendar)
Dim calType As GregorianCalendarTypes = myGreCal.CalendarType
Console.WriteLine(" {0} ({1})", cal, calType)
Else
Console.WriteLine(" {0}", cal)
End If
Next cal
End Sub 'Main
End Class 'SamplesCultureInfo
'This code produces the following output.
'
'The ar-SA culture supports the following calendars:
' System.Globalization.HijriCalendar
' System.Globalization.GregorianCalendar (USEnglish)
' System.Globalization.GregorianCalendar (MiddleEastFrench)
' System.Globalization.GregorianCalendar (Arabic)
' System.Globalization.GregorianCalendar (Localized)
' System.Globalization.GregorianCalendar (TransliteratedFrench)
using System;
using System.Globalization;
public class SamplesCultureInfo {
public static void Main() {
// Gets the calendars supported by the ar-SA culture.
Calendar[] myOptCals = new CultureInfo("ar-SA").OptionalCalendars;
// Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
Console.WriteLine( "The ar-SA culture supports the following calendars:" );
foreach ( Calendar cal in myOptCals ) {
if ( cal.GetType() == typeof( GregorianCalendar ) ) {
GregorianCalendar myGreCal = (GregorianCalendar) cal;
GregorianCalendarTypes calType = myGreCal.CalendarType;
Console.WriteLine( " {0} ({1})", cal, calType );
}
else {
Console.WriteLine( " {0}", cal );
}
}
}
}
/*
This code produces the following output.
The ar-SA culture supports the following calendars:
System.Globalization.HijriCalendar
System.Globalization.GregorianCalendar (USEnglish)
System.Globalization.GregorianCalendar (MiddleEastFrench)
System.Globalization.GregorianCalendar (Arabic)
System.Globalization.GregorianCalendar (Localized)
System.Globalization.GregorianCalendar (TransliteratedFrench)
*/
using namespace System;
using namespace System::Globalization;
using namespace System::Collections;
int main()
{
// Calendar* myOptCals[] = new CultureInfo(S"ar-SA") -> OptionalCalendars;
CultureInfo^ MyCI = gcnew CultureInfo( "ar-SA" );
array<Calendar^>^myOptCals = MyCI->OptionalCalendars;
// Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
Console::WriteLine( "The ar-SA culture supports the following calendars:" );
IEnumerator^ myEnum = myOptCals->GetEnumerator();
while ( myEnum->MoveNext() )
{
Calendar^ cal = safe_cast<Calendar^>(myEnum->Current);
if ( cal->GetType() == GregorianCalendar::typeid )
{
GregorianCalendar^ myGreCal = dynamic_cast<GregorianCalendar^>(cal);
GregorianCalendarTypes calType = myGreCal->CalendarType;
Console::WriteLine( " {0} ( {1})", cal, calType );
}
else
Console::WriteLine( " {0}", cal );
}
}
/*
This code produces the following output.
The ar-SA culture supports the following calendars:
System.Globalization.HijriCalendar
System.Globalization.GregorianCalendar ( USEnglish)
System.Globalization.GregorianCalendar ( MiddleEastFrench)
System.Globalization.GregorianCalendar ( Arabic)
System.Globalization.GregorianCalendar ( Localized)
System.Globalization.GregorianCalendar ( TransliteratedFrench)
*/
import System.* ;
import System.Globalization.* ;
public class SamplesCultureInfo
{
public static void main(String[] args)
{
// Gets the calendars supported by the ar-SA culture.
Calendar myOptCals[] = (new CultureInfo("ar-SA")).
get_OptionalCalendars();
// Checks which ones are GregorianCalendar then determines the
// GregorianCalendar version.
Console.WriteLine
("The ar-SA culture supports the following calendars:");
for (int iCtr = 0; iCtr < myOptCals.length; iCtr++) {
Calendar cal = myOptCals[iCtr];
if (cal.GetType() == GregorianCalendar.class.ToType()) {
GregorianCalendar myGreCal = ((GregorianCalendar)(cal));
GregorianCalendarTypes calType = myGreCal.get_CalendarType();
Console.WriteLine(" {0} ({1})", cal, calType);
}
else {
Console.WriteLine(" {0}", cal);
}
}
} //main
} //SamplesCultureInfo
/*
This code produces the following output.
The ar-SA culture supports the following calendars:
System.Globalization.HijriCalendar
System.Globalization.GregorianCalendar (USEnglish)
System.Globalization.GregorianCalendar (MiddleEastFrench)
System.Globalization.GregorianCalendar (Arabic)
System.Globalization.GregorianCalendar (Localized)
System.Globalization.GregorianCalendar (TransliteratedFrench)
*/
In folgendem Codebeispiel wird eine DateTime unter Verwendung eines lokalisierten GregorianCalendar ausgegeben.
Imports System
Imports System.Globalization
Public Class SamplesGregorianCalendar
Public Shared Sub Main()
' Creates and initializes three different CultureInfo.
Dim myCIarSA As New CultureInfo("ar-SA", False)
Dim myCIdeDE As New CultureInfo("de-DE", False)
Dim myCIenUS As New CultureInfo("en-US", False)
Dim myCIfrFR As New CultureInfo("fr-FR", False)
' Creates a Localized GregorianCalendar.
' GregorianCalendarTypes.Localized is the default when using the GregorianCalendar constructor without parameters.
Dim myCal = New GregorianCalendar()
' Sets the DateTimeFormatInfo.Calendar property to a Localized GregorianCalendar.
' Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR,
myCIarSA.DateTimeFormat.Calendar = myCal
' Creates a DateTime.
Dim myDT As New DateTime(2002, 1, 3, 13, 30, 45)
' Displays the DateTime.
Console.WriteLine("ar-SA: {0}", myDT.ToString("F", myCIarSA))
Console.WriteLine("de-DE: {0}", myDT.ToString("F", myCIdeDE))
Console.WriteLine("en-US: {0}", myDT.ToString("F", myCIenUS))
Console.WriteLine("fr-FR: {0}", myDT.ToString("F", myCIfrFR))
End Sub 'Main
End Class 'SamplesGregorianCalendar
'This code produces the following output. The question marks take the place of native script characters.
'
'ar-SA: 03 ?????, 2002 01:30:45 ?
'de-DE: Donnerstag, 3. Januar 2002 13:30:45
'en-US: Thursday, January 03, 2002 1:30:45 PM
'fr-FR: jeudi 3 janvier 2002 13:30:45
using System;
using System.Globalization;
public class SamplesGregorianCalendar {
public static void Main() {
// Creates and initializes three different CultureInfo.
CultureInfo myCIarSA = new CultureInfo("ar-SA", false);
CultureInfo myCIdeDE = new CultureInfo("de-DE", false);
CultureInfo myCIenUS = new CultureInfo("en-US", false);
CultureInfo myCIfrFR = new CultureInfo("fr-FR", false);
// Creates a Localized GregorianCalendar.
// GregorianCalendarTypes.Localized is the default when using the GregorianCalendar constructor without parameters.
Calendar myCal = new GregorianCalendar();
// Sets the DateTimeFormatInfo.Calendar property to a Localized GregorianCalendar.
// Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR,
myCIarSA.DateTimeFormat.Calendar = myCal;
// Creates a DateTime.
DateTime myDT = new DateTime( 2002, 1, 3, 13, 30, 45 );
// Displays the DateTime.
Console.WriteLine( "ar-SA: {0}", myDT.ToString( "F", myCIarSA ) );
Console.WriteLine( "de-DE: {0}", myDT.ToString( "F", myCIdeDE ) );
Console.WriteLine( "en-US: {0}", myDT.ToString( "F", myCIenUS ) );
Console.WriteLine( "fr-FR: {0}", myDT.ToString( "F", myCIfrFR ) );
}
}
/*
This code produces the following output. The question marks take the place of native script characters.
ar-SA: 03 ?????, 2002 01:30:45 ?
de-DE: Donnerstag, 3. Januar 2002 13:30:45
en-US: Thursday, January 03, 2002 1:30:45 PM
fr-FR: jeudi 3 janvier 2002 13:30:45
*/
using namespace System;
using namespace System::Globalization;
int main()
{
// Creates and initializes three different CultureInfo.
CultureInfo^ myCIarSA = gcnew CultureInfo( "ar-SA",false );
CultureInfo^ myCIdeDE = gcnew CultureInfo( "de-DE",false );
CultureInfo^ myCIenUS = gcnew CultureInfo( "en-US",false );
CultureInfo^ myCIfrFR = gcnew CultureInfo( "fr-FR",false );
// Creates a Localized GregorianCalendar.
// GregorianCalendarTypes::Localized is the default when using the GregorianCalendar constructor with->Item[Out] parameters.
Calendar^ myCal = gcnew GregorianCalendar;
// Sets the DateTimeFormatInfo::Calendar property to a Localized GregorianCalendar.
// Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR,
myCIarSA->DateTimeFormat->Calendar = myCal;
// Creates a DateTime.
DateTime myDT = DateTime(2002,1,3,13,30,45);
// Displays the DateTime.
Console::WriteLine( "ar-SA: {0}", myDT.ToString( "F", myCIarSA ) );
Console::WriteLine( "de-DE: {0}", myDT.ToString( "F", myCIdeDE ) );
Console::WriteLine( "en-US: {0}", myDT.ToString( "F", myCIenUS ) );
Console::WriteLine( "fr-FR: {0}", myDT.ToString( "F", myCIfrFR ) );
}
/*
This code produces the following output. The question marks take the place of native script characters.
ar-SA: 03 ?????, 2002 01:30:45 ?
de-DE: Donnerstag, 3. Januar 2002 13:30:45
en-US: Thursday, January 03, 2002 1:30:45 PM
fr-FR: jeudi 3 janvier 2002 13:30:45
*/
import System.* ;
import System.Globalization.* ;
public class SamplesGregorianCalendar
{
public static void main(String[] args)
{
// Creates and initializes three different CultureInfo.
CultureInfo myCIarSA = new CultureInfo("ar-SA", false);
CultureInfo myCIdeDE = new CultureInfo("de-DE", false);
CultureInfo myCIenUS = new CultureInfo("en-US", false);
CultureInfo myCIfrFR = new CultureInfo("fr-FR", false);
// Creates a Localized GregorianCalendar.
// GregorianCalendarTypes.Localized is the default when using the
// GregorianCalendar constructor without parameters.
Calendar myCal = new GregorianCalendar();
// Sets the DateTimeFormatInfo.Calendar property to a
// Localized GregorianCalendar.
// Localized GregorianCalendar is the default calendar for
// de-DE, en-US, and fr-FR,
myCIarSA.get_DateTimeFormat().set_Calendar( myCal);
// Creates a DateTime.
DateTime myDT = new DateTime(2002, 1, 3, 13, 30, 45);
// Displays the DateTime.
Console.WriteLine("ar-SA: {0}", myDT.ToString("F", myCIarSA));
Console.WriteLine("de-DE: {0}", myDT.ToString("F", myCIdeDE));
Console.WriteLine("en-US: {0}", myDT.ToString("F", myCIenUS));
Console.WriteLine("fr-FR: {0}", myDT.ToString("F", myCIfrFR));
} //main
} //SamplesGregorianCalendar
/*
This code produces the following output. The question marks take the place
of native script characters.
ar-SA: 03 ?????, 2002 01:30:45 ?
de-DE: Donnerstag, 3. Januar 2002 13:30:45
en-US: Thursday, January 03, 2002 1:30:45 PM
fr-FR: jeudi 3 janvier 2002 13:30:45
*/
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0