3

我有一个测试应用程序,它允许用户从组合框中选择一种文化,并在多行文本框中显示文化特定日期。代码如下:

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);
    }
}

我注意到如果选择“ar-SA”,阿拉伯语(沙特阿拉伯),那么当我在不同的机器上运行应用程序时,我会看到不同的结果。

在 Windows 7 机器上,文本框显示:

我的日期:2012 年 4 月 11 日下午 4:07:09
文化特定日期:19/05/33 04:07:09 م

在 Windows XP 机器上,文本框显示:

我的日期:2012 年 4 月 11 日下午 4:07:09
文化特定日期:20/05/33 04:07:09 م

如您所见,文化特定日期差了一天。什么可能导致这种差异?

4

1 回答 1

6

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:

Only recently has more information become available which now makes it possible to reconstruct the calendar adopted on the Arabian Peninsula in the recent past and to predict its future course for many years in advance.

... so maybe the Windows XP implementation is out of date.

(That page agrees that it's currently the 19th, by the way.)

于 2012-04-11T20:19:36.633 回答