开发者

Retrieve 'first day of week' and 'CalendarWeekRule' from environment

This should be easy, I think, but I coul开发者_运维百科dn't find it (yet) myself.

I need to know if these two values can be retrieved from the system's environment and/or local settings.

I know that in my country (The Netherlands) these values should be:

  • FirstDayOfWeek = Monday
  • CalendarWeekRule = FirstFullWeek

But I don't want to set a fixed rule for that.


You could retrieve these values from the DateTimeFormat object.

CultureInfo theNetherlands = CultureInfo.GetCultureInfo("nl-nl");
var firstDayOfWeek = theNetherlands.DateTimeFormat.FirstDayOfWeek;
var calendarWeekRule = theNetherlands.DateTimeFormat.CalendarWeekRule;

If you want to get these values for the current culture you could just use CultureInfo.CurrentCulture.DatetimeFormat.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜