GregorianCalendarTypes Enumeration

Defines the different language versions of the Gregorian calendar.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public Enumeration GregorianCalendarTypes
[ComVisibleAttribute(true)]
public enum GregorianCalendarTypes

Members

Member name Description
Supported by Silverlight for Windows PhoneSupported by Xbox 360 Localized Refers to the localized version of the Gregorian calendar, based on the language of the CultureInfo object that uses the DateTimeFormatInfo object.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 USEnglish Refers to the U.S. English version of the Gregorian calendar.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 MiddleEastFrench Refers to the Middle East French version of the Gregorian calendar.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 Arabic Refers to the Arabic version of the Gregorian calendar.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 TransliteratedEnglish Refers to the transliterated English version of the Gregorian calendar.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 TransliteratedFrench Refers to the transliterated French version of the Gregorian calendar.

Remarks

The date and time patterns associated with the GregorianCalendar vary depending on the culture. If the value of the CultureInfo.Calendar property of a particular culture is GregorianCalendar, or if the value of one of the calendars in a culture’s CultureInfo.OptionalCalendars property array is GregorianCalendar, that object’s GregorianCalendar.CalendarType property is a GregorianCalendarTypes enumeration value that specifies which date and time patterns that culture uses.

For example, most of the Arabic cultures support the following versions of the Gregorian calendar:

A culture that supports GregorianCalendar might not support all language versions of GregorianCalendar. The CultureInfo.Calendar and CultureInfo.OptionalCalendars properties specify the calendars supported by that culture. If GregorianCalendar is supported, CalendarType can be used to determine which language versions of GregorianCalendar are supported.

Examples

The following example demonstrates how to determine the GregorianCalendar language version supported by the culture.

Imports System.Globalization

Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

      ' 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.
      outputBlock.Text &= "The ar-SA culture supports the following calendars:" & vbCrLf
      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
            outputBlock.Text += String.Format("   {0} ({1})", cal, calType) & vbCrLf
         Else
            outputBlock.Text += String.Format("   {0}", cal) & vbCrLf
         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 Example
{

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      // 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.
      outputBlock.Text += "The ar-SA culture supports the following calendars:" + "\n";
      foreach (Calendar cal in myOptCals)
      {
         if (cal.GetType() == typeof(GregorianCalendar))
         {
            GregorianCalendar myGreCal = (GregorianCalendar)cal;
            GregorianCalendarTypes calType = myGreCal.CalendarType;
            outputBlock.Text += String.Format("   {0} ({1})", cal, calType) + "\n";
         }
         else
         {
            outputBlock.Text += String.Format("   {0}", cal) + "\n";
         }
      }

   }

}

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

*/

The following example displays a DateTime value using a localized GregorianCalendar object.

Imports System.Globalization

Public Class Example
   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      ' Creates and initializes four different CultureInfo objects.
      Dim myCIdeDE As New CultureInfo("de-DE")
      Dim myCIenUS As New CultureInfo("en-US")
      Dim myCIfrFR As New CultureInfo("fr-FR")
      Dim myCIruRU As New CultureInfo("ru-RU")

      ' 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.
      outputBlock.Text += String.Format("de-DE: {0}", myDT.ToString("F", myCIdeDE)) & vbCrLf
      outputBlock.Text += String.Format("en-US: {0}", myDT.ToString("F", myCIenUS)) & vbCrLf
      outputBlock.Text += String.Format("fr-FR: {0}", myDT.ToString("F", myCIfrFR)) & vbCrLf
      outputBlock.Text += String.Format("ru-RU: {0}", myDT.ToString("F", myCIruRU)) & vbCrLf
   End Sub 
End Class
' 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 Example
{

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      // Creates and initializes four different CultureInfo.
      CultureInfo myCIdeDE = new CultureInfo("de-DE");
      CultureInfo myCIenUS = new CultureInfo("en-US");
      CultureInfo myCIfrFR = new CultureInfo("fr-FR");
      CultureInfo myCIruRU = new CultureInfo("ru-RU");

      // 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.
      outputBlock.Text += String.Format("de-DE: {0}", myDT.ToString("F", myCIdeDE)) + "\n";
      outputBlock.Text += String.Format("en-US: {0}", myDT.ToString("F", myCIenUS)) + "\n";
      outputBlock.Text += String.Format("fr-FR: {0}", myDT.ToString("F", myCIfrFR)) + "\n";
      outputBlock.Text += String.Format("ru-RU: {0}", myDT.ToString("F", myCIruRU)) + "\n";

   }

}

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

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference