有没有更好的方法来重新排列
DateTimeFormat.DayNames
根据
DateTimeFormat.FirstDayOfWeek
所以如果
DateTimeFormat.FirstDayOfWeek = 1
dayNames 包含 mon,tue,wed, ...
insted of son,mon,tue, ...
我目前正在使用:
CultureInfo culture = System.Globalization.CultureInfo.CurrentUICulture;
string[] DayNames = culture.DateTimeFormat.DayNames;
int FirstDayOfWeek = (int)culture.DateTimeFormat.FirstDayOfWeek;
int daysInMonth = DateTime.DaysInMonth(year, month);
string[] tempdays = new string[7];
for (int i = 0; i <= DayNames.GetUpperBound(0); i++)
{
tempdays[i] = DayNames[i == 0 ? FirstDayOfWeek :
(i == 6 - FirstDayOfWeek ? 6 :
i > 6 - FirstDayOfWeek ? 0 != (6 - (i + (FirstDayOfWeek - 1))) ?
(6 - (i + (FirstDayOfWeek - 1))) * -1 :
6 - (i + (FirstDayOfWeek - 1)) : i + FirstDayOfWeek)];
}