.NET全球化IsWeekend?NET、IsWeekend

由网友(上位)分享简介:可能重复: 寻找周末两天以文化 有任何语言环境中的信息在.NET可知道,如果给定的日期落在平日或周末 Is there any locale info available in .NET to know if a given date falls on a weekday or a weekend?我的将会的使...

可能重复:   寻找周末两天以文化

有任何语言环境中的信息在.NET可知道,如果给定的日期落在平日或周末

Is there any locale info available in .NET to know if a given date falls on a weekday or a weekend?

我的将会的使用功能:

public Boolean IsWeekend(DateTime value, CultureInfo cultureInfo)
{
   return (value.DayOfWeek == DayOfWeek.Saturday || value.DayOfWeek == DayOfWeek.Sunday);
}

但它返回无效的结果一些文化。

了.NET已经完成的工作编译哪些天是周末,所有文化?

Has .NET already done the work to compile what days are weekends for all cultures?

推荐答案

这是pretty的有趣的问题,答案似乎是否定的,有是.NET没有这种功能。当然你也可以使用的DateTimeFormatInfo 的 FirstDayOfWeek 属性,但它的的没有的不够好。

It is pretty interesting question and the answer seems to be no, there is no such function in .Net. Of course you can use DateTimeFormatInfo's FirstDayOfWeek Property, but it is not good enough.

这只会告诉你,有很高的机会,preceding一天是周末的一天。然而,这是不是非常有帮助的(那其他之一,...),因为是刚刚的一双休。此外,在穆斯林国家,他们通常周五是周末,但是......他们中有些人也有周四,周六一些,而且我相信我听说过的国家,拥有周五和周日关闭。在这种情况下,这将是十分困难的谈论周末...

It will just tell you that there is high chance that preceding day was the weekend day. However, it is not very helpful (what about the other one and...), as there are countries that have just one day weekend. Also, in Muslim countries, they typically have Friday as a weekend day, but... Some of them have also Thursday, some Saturday, and I am sure I heard about country that has Friday and Sunday off. In this case, it would be quite hard to talk about a weekend...

我看了看 CLDR图表,但我无法找到适当的信息。看来你是你自己。 从理论上讲,你可能会认为使用 ICU 的的 Calendar类具有 isWeekend()方法,但在导入一个dll只是要使用的一个班出了它的声音pretty的不好。

I took a look at CLDR Charts, but I can't find appropriate information. It seems you are on your own. In theory, you may think of using ICU's Calendar class which has isWeekend() method but importing a dll just to use one class out of it sounds pretty bad.

阅读全文

相关推荐

最新文章