Поделиться через


GregorianCalendarTypes Перечисление

Определение

Определяет разные языковые версии григорианского календаря.

public enum class GregorianCalendarTypes
public enum GregorianCalendarTypes
[System.Serializable]
public enum GregorianCalendarTypes
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum GregorianCalendarTypes
type GregorianCalendarTypes = 
[<System.Serializable>]
type GregorianCalendarTypes = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type GregorianCalendarTypes = 
Public Enum GregorianCalendarTypes
Наследование
GregorianCalendarTypes
Атрибуты

Поля

Arabic 10

Ссылается на арабскую версию григорианского календаря.

Localized 1

Ссылается на локализованную версию григорианского календаря на основе языка CultureInfo, использующего DateTimeFormatInfo.

MiddleEastFrench 9

Ссылается на ближневосточную французскую версию григорианского календаря.

TransliteratedEnglish 11

Ссылается на транслитерированную английскую версию григорианского календаря.

TransliteratedFrench 12

Ссылается на транслитерированную французскую версию григорианского календаря.

USEnglish 2

Ссылается на англо-американскую версию григорианского календаря.

Примеры

В следующем примере кода показано, как определить версию языка GregorianCalendar, поддерживаемую языком и региональными параметрами.

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)

*/
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)

*/
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

End Class


'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)

В следующем примере кода выводится DateTime с помощью локализованного GregorianCalendar .

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes three different CultureInfo.
   CultureInfo^ myCIdeDE = gcnew CultureInfo( "de-DE",false );
   CultureInfo^ myCIenUS = gcnew CultureInfo( "en-US",false );
   CultureInfo^ myCIfrFR = gcnew CultureInfo( "fr-FR",false );
   CultureInfo^ myCIruRU = gcnew CultureInfo( "ru-RU",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,
   myCIruRU->DateTimeFormat->Calendar = myCal;
   
   // Creates a DateTime.
   DateTime myDT = DateTime(2002,1,3,13,30,45);
   
   // Displays the DateTime.
   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 ) );
   Console::WriteLine( "ru-RU: {0}", myDT.ToString( "F", myCIruRU ) );
}

/*
The example displays the following output:
   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
   ru-RU: 3 января 2002 г. 13:30:45
*/
using System;
using System.Globalization;

public class SamplesGregorianCalendar  {

   public static void Main()  {

      // Creates and initializes four different CultureInfo objects.
      CultureInfo myCIdeDE = new CultureInfo("de-DE", false);
      CultureInfo myCIenUS = new CultureInfo("en-US", false);
      CultureInfo myCIfrFR = new CultureInfo("fr-FR", false);
      CultureInfo myCIruRU = new CultureInfo("ru-RU", 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,
      myCIruRU.DateTimeFormat.Calendar = myCal;

      // Creates a DateTime.
      DateTime myDT = new DateTime( 2002, 1, 3, 13, 30, 45 );

      // Displays the DateTime.
      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 ) );
      Console.WriteLine( "ru-RU: {0}", myDT.ToString( "F", myCIruRU ) );
   }
}
/*
The example displays the following output:
   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
   ru-RU: 3 января 2002 г. 13:30:45
*/
Imports System.Globalization

Public Class SamplesGregorianCalendar

   Public Shared Sub Main()
      ' Creates and initializes three different CultureInfo.
      Dim myCIdeDE As New CultureInfo("de-DE", False)
      Dim myCIenUS As New CultureInfo("en-US", False)
      Dim myCIfrFR As New CultureInfo("fr-FR", False)
      Dim myCIruRU As New CultureInfo("ru-RU", 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,
      myCIruRU.DateTimeFormat.Calendar = myCal

      ' Creates a DateTime.
      Dim myDT As New DateTime(2002, 1, 3, 13, 30, 45)

      ' Displays the DateTime.
      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))
      Console.WriteLine("ru-RU: {0}", myDT.ToString("F", myCIruRU))
   End Sub
End Class
' This example displays the following output:
'    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
'    ru-RU: 3 января 2002 г. 13:30:45

Комментарии

Шаблоны даты и времени, связанные с , GregorianCalendar зависят от языка. GregorianCalendar Если в выбран DateTimeFormatInfo.Calendarпараметр , GregorianCalendarTypes можно указать, какие шаблоны даты и времени следует использовать в .DateTimeFormatInfo

Для арабских языков доступны другие языковые версии григорианского календаря. Например, можно использовать французскую версию , GregorianCalendar используя MiddleEastFrench значение .

Язык и региональные параметры, поддерживающие GregorianCalendarTypes , могут поддерживать не все языковые GregorianCalendarверсии . Свойства CultureInfo.Calendar и CultureInfo.OptionalCalendars указывают календари, поддерживаемые этим языком и региональными параметрами. Если GregorianCalendar поддерживается, GregorianCalendar.CalendarType можно использовать для определения поддерживаемых языковых версий GregorianCalendar .

Применяется к