ar-sa文化的预期日期时间字符串是什么? [英] What is expected datetime string for ar-sa culture?

查看:65
本文介绍了ar-sa文化的预期日期时间字符串是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种方法

DateToString(DateTime datetime, string format, CultureInfo cultrueInfo)
{
    return datetime.ToString(format, cultureInfo);
}

参数:

datetime: {10/1/2016 12:00:00 AM}
format: "ddd, dd MMM"
cultureInfo: {ar-SA}

但是它返回我السبت,30 ذو́الحجة". 10月1日是星期六.为什么似乎在9月30日(星期六)还我?我这边有什么问题吗?

But it returns me "السبت, 30 ذو الحجة". October 1st is Saturday. Why it seems return me September 30, Saturday? Anything wrong at my side?

推荐答案

ar-SA文化使用 UmAlQuraCalendar 日历.

ar-SA culture uses UmAlQuraCalendar a calendar.

new CultureInfo("ar-SA").Calendar.Dump(); // System.Globalization.UmAlQuraCalendar

由于您在ToString方法中使用了该区域性,因此它将基于 that 日历生成字符串表示形式.您不能期望生成"9月",因为您的文化不使用GregorianCalendar.

Since you used that culture in your ToString method, it will generated a string representation based on that calendar. You can't expect to generate "September" since your culture does not use GregorianCalendar.

UmAlQuraCalendar中,您的DateTiem将表示为30-12-1437.

In UmAlQuraCalendar, your DateTiem will be represented as 30-12-1437.

var dt = new DateTime(2016, 10, 1);  // Gregorian

var umAlQura = new UmAlQuraCalendar();

umAlQura.GetYear(dt);       // 1437
umAlQura.GetMonth(dt);      // 12
umAlQura.GetDayOfMonth(dt); // 30

https://www.staff.science.uu. nl/〜gent0113/islam/ummalqura_converter.htm

这就是为什么:

  • ddd format specifier generates السبت ((Yawm) as-Sabt aka Saturday) since it is the abbreviated day name.
  • dd format specifier generates 30 as expected.
  • MMM format specifier generates ذو الحجة (Dhu al-Hijjah) since it is the abbreviated month name.

如您所见,缩写的日期和月份名称切换到结果中.这可能是从右至左的问题.

As you can see, abbreviated day and month name switched in result. This is probably a Right to left issue.

这篇关于ar-sa文化的预期日期时间字符串是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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