开发者

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

开发者 https://www.devze.com 2023-02-28 15:44 出处:网络
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.

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

精彩评论

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