From 276462d885394e95727977905d8fc7550ad20fa9 Mon Sep 17 00:00:00 2001 From: Bartosz Klonowski Date: Mon, 18 May 2026 20:02:38 +0200 Subject: [PATCH 1/4] Fix the formatting of the ar-SA culture calendar display --- .../conceptual.calendars/cs/changecalendar2.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs index 87a600d442d67..bd520c3933532 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs @@ -18,18 +18,22 @@ public static void Main() // Change the current culture to Arabic (Saudi Arabia). Thread.CurrentThread.CurrentCulture = arSA; + Calendar umAlQura = new UmAlQuraCalendar(); + // Display date and information about the current culture. + arSA.DateTimeFormat.Calendar = umAlQura; DisplayCurrentInfo(); - Console.WriteLine(date1.ToString("d")); + Console.WriteLine(date1.ToString("dd'/'MM'/'yyyy")); Console.WriteLine(); // Change the calendar to Hijri. Calendar hijri = new HijriCalendar(); - if (CalendarExists(arSA, hijri)) { + if (CalendarExists(arSA, hijri)) + { arSA.DateTimeFormat.Calendar = hijri; // Display date and information about the current culture. DisplayCurrentInfo(); - Console.WriteLine(date1.ToString("d")); + Console.WriteLine(date1.ToString("dd'/'MM'/'yyyy")); } } From 2524de34fa2c8811c3da1cc45ad59c1e95310808 Mon Sep 17 00:00:00 2001 From: Bartosz Klonowski Date: Mon, 18 May 2026 20:04:09 +0200 Subject: [PATCH 2/4] Adjust the example output comment --- .../conceptual.calendars/cs/changecalendar2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs index bd520c3933532..e4e4dea68bf3e 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs @@ -59,9 +59,9 @@ private static bool CalendarExists(CultureInfo culture, Calendar cal) // // Current Culture: ar-SA // Current Calendar: System.Globalization.UmAlQuraCalendar -// 18/07/32 +// 18/07/1432 // // Current Culture: ar-SA // Current Calendar: System.Globalization.HijriCalendar -// 19/07/32 +// 19/07/1432 // From 0d462907111c877cfc0dff1cc5a67c3d914773af Mon Sep 17 00:00:00 2001 From: Bartosz Klonowski Date: Mon, 18 May 2026 20:07:28 +0200 Subject: [PATCH 3/4] Briefly mention the fact of setting Calendar for culture change --- docs/standard/datetime/working-with-calendars.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard/datetime/working-with-calendars.md b/docs/standard/datetime/working-with-calendars.md index 6b6c6767852d2..d8b17b46637c3 100644 --- a/docs/standard/datetime/working-with-calendars.md +++ b/docs/standard/datetime/working-with-calendars.md @@ -69,7 +69,7 @@ The following example illustrates the object is defined by the culture's property. A culture's object is returned by the property. When a culture is created, its default value is the same as the value of the property. However, you can change the culture's current calendar to any calendar contained in the array returned by the property. If you try to set the current calendar to a calendar that is not included in the property value, an is thrown. -The following example changes the calendar used by the Arabic (Saudi Arabia) culture. It first instantiates a value and displays it using the current culture - which, in this case, is English (United States) - and the current culture's calendar (which, in this case, is the Gregorian calendar). Next, it changes the current culture to Arabic (Saudi Arabia) and displays the date using its default Um Al-Qura calendar. It then calls the `CalendarExists` method to determine whether the Hijri calendar is supported by the Arabic (Saudi Arabia) culture. Because the calendar is supported, it changes the current calendar to Hijri and again displays the date. Note that in each case, the date is displayed using the current culture's current calendar. +The following example changes the calendar used by the Arabic (Saudi Arabia) culture. It first instantiates a value and displays it using the current culture - which, in this case, is English (United States) - and the current culture's calendar (which, in this case, is the Gregorian calendar). Next, it changes the current culture to Arabic (Saudi Arabia) and displays the date using its default Um Al-Qura calendar. Note that every time the culture is changed, the calendar change follows by setting `arSA.DateTimeFormat.Calendar` to the current calendar. Next, for the Hijri calendar, the code calls the `CalendarExists` method to determine whether the Hijri calendar is supported by the Arabic (Saudi Arabia) culture. Because the calendar is supported, it changes the current calendar to Hijri and again displays the date. Note that in each case, the date is displayed using the current culture's current calendar. [!code-csharp[Conceptual.Calendars#2](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs#2)] [!code-vb[Conceptual.Calendars#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.calendars/vb/changecalendar2.vb#2)] From 152fac48055d5ad99c47af3f1184630332eab4e2 Mon Sep 17 00:00:00 2001 From: Bartosz Klonowski Date: Tue, 19 May 2026 03:08:10 +0200 Subject: [PATCH 4/4] Do not explicitly set the calendar when changing for ar-SA --- docs/standard/datetime/working-with-calendars.md | 2 +- .../VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/standard/datetime/working-with-calendars.md b/docs/standard/datetime/working-with-calendars.md index d8b17b46637c3..6b6c6767852d2 100644 --- a/docs/standard/datetime/working-with-calendars.md +++ b/docs/standard/datetime/working-with-calendars.md @@ -69,7 +69,7 @@ The following example illustrates the object is defined by the culture's property. A culture's object is returned by the property. When a culture is created, its default value is the same as the value of the property. However, you can change the culture's current calendar to any calendar contained in the array returned by the property. If you try to set the current calendar to a calendar that is not included in the property value, an is thrown. -The following example changes the calendar used by the Arabic (Saudi Arabia) culture. It first instantiates a value and displays it using the current culture - which, in this case, is English (United States) - and the current culture's calendar (which, in this case, is the Gregorian calendar). Next, it changes the current culture to Arabic (Saudi Arabia) and displays the date using its default Um Al-Qura calendar. Note that every time the culture is changed, the calendar change follows by setting `arSA.DateTimeFormat.Calendar` to the current calendar. Next, for the Hijri calendar, the code calls the `CalendarExists` method to determine whether the Hijri calendar is supported by the Arabic (Saudi Arabia) culture. Because the calendar is supported, it changes the current calendar to Hijri and again displays the date. Note that in each case, the date is displayed using the current culture's current calendar. +The following example changes the calendar used by the Arabic (Saudi Arabia) culture. It first instantiates a value and displays it using the current culture - which, in this case, is English (United States) - and the current culture's calendar (which, in this case, is the Gregorian calendar). Next, it changes the current culture to Arabic (Saudi Arabia) and displays the date using its default Um Al-Qura calendar. It then calls the `CalendarExists` method to determine whether the Hijri calendar is supported by the Arabic (Saudi Arabia) culture. Because the calendar is supported, it changes the current calendar to Hijri and again displays the date. Note that in each case, the date is displayed using the current culture's current calendar. [!code-csharp[Conceptual.Calendars#2](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs#2)] [!code-vb[Conceptual.Calendars#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.calendars/vb/changecalendar2.vb#2)] diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs index e4e4dea68bf3e..6d9da51ebf1e4 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.calendars/cs/changecalendar2.cs @@ -18,10 +18,8 @@ public static void Main() // Change the current culture to Arabic (Saudi Arabia). Thread.CurrentThread.CurrentCulture = arSA; - Calendar umAlQura = new UmAlQuraCalendar(); // Display date and information about the current culture. - arSA.DateTimeFormat.Calendar = umAlQura; DisplayCurrentInfo(); Console.WriteLine(date1.ToString("dd'/'MM'/'yyyy")); Console.WriteLine();