Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

GregorianCalendarTypes Enumeration

Defines the different language versions of the Gregorian calendar.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)
'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration GregorianCalendarTypes
Member nameDescription
Supported by the XNA FrameworkArabicRefers to the Arabic version of the Gregorian calendar.
Supported by the XNA FrameworkLocalizedRefers to the localized version of the Gregorian calendar, based on the language of the CultureInfo that uses the DateTimeFormatInfo.
Supported by the XNA FrameworkMiddleEastFrenchRefers to the Middle East French version of the Gregorian calendar.
Supported by the XNA FrameworkTransliteratedEnglishRefers to the transliterated English version of the Gregorian calendar.
Supported by the XNA FrameworkTransliteratedFrenchRefers to the transliterated French version of the Gregorian calendar.
Supported by the XNA FrameworkUSEnglishRefers to the U.S. English version of the Gregorian calendar.

The date and time patterns associated with the GregorianCalendar vary depending on the language. If the GregorianCalendar is selected in DateTimeFormatInfo.Calendar, GregorianCalendarTypes can be used to specify which date and time patterns to use in that DateTimeFormatInfo.

For Arabic cultures, more language versions of the Gregorian calendar are available. For example, you can use the French version of GregorianCalendar using the MiddleEastFrench value.

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.

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

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)

The following code example prints a DateTime using a GregorianCalendar that is localized.

Imports System
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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.