文化特定日期时间字符串的平台之间不一致 [英] Culture specific DateTime string is inconsistent between platforms

查看:231
本文介绍了文化特定日期时间字符串的平台之间不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试应用程序,允许用户从下拉框中选择一种文化,并显示在一个多行TextBox的文化具体日期。在code是如下:

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

我注意到,如果AR-SA,阿拉伯语(沙特阿拉伯),被选中的话,我看到不同的结果,当我运行在不同机器上的应用程序。

I notice that if "ar-SA", Arabic (Saudi Arabia), is selected, then I see different results when I run the application on different machines.

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

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 م

在Windows XP计算机,显示文本框:

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?

推荐答案

我的犯罪嫌疑人的,这是由于Windows XP的机器没有接收到最新的adjustments的乌姆Qura日历,而presumably在Windows 7中的不断更新,虽然我不会的期望的这些调整会影响到当月。或者,也可能是由于这样的:

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:

最近才变得可用更多信息,使得现在有可能重建在最近的过去和predict其未来走向多年提前通过了阿拉伯半岛上的日历。

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.

...所以也许Windows XP的实现是过时的。

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

(该网页同意,这是目前19,顺便说一句。)

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

这篇关于文化特定日期时间字符串的平台之间不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆