I have a test application that allows the user to select a culture from a ComboBox and displays the culture specific date in a multiline TextBox. The code is below:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
comboBox1.Items.AddRange(
CultureInfo.GetCultures(CultureTypes.SpecificCultures));
}
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
CultureInfo selectedCulture = comboBox1.SelectedItem as CultureInfo;
DateTime currentDate = DateTime.Now;
textBox1.Text =
"My Date : " + currentDate.ToString() + Environment.NewLine +
"Culture Specific Date: " + currentDate.ToString(selectedCulture);
}
}
I notice that if “ar-SA”, Arabic (Saudi Arabia), is selected, then I see different results when I run the application on different machines.
On a Windows 7 machine, the text box displays:
My Date : 4/11/2012 4:07:09 PM Culture Specific Date: 19/05/33 04:07:09 م
On a Windows XP machine, the text box displays:
My Date : 4/11/2012 4:07:09 PM Culture Specific Date: 20/05/33 04:07:09 م
As you can see, the culture specific date is off by a day. What could be causing this discrepancy?
I suspect this is due to the Windows XP machine not receiving up-to-date adjustments to the Umm al-Qura calendar, whereas presumably the Windows 7 box is kept up to date, although I wouldn’t expect those adjustments to affect the current month. Alternatively, it could be due to this:
… so maybe the Windows XP implementation is out of date.
(That page agrees that it’s currently the 19th, by the way.)