Is it possible to get the CurrentCulture
\'s weekdays from DateTimeFormatInfo
, but returning Monday as first day of the week instea
I am posting this as a separate answer as it really has nothing to do with my other answer (which may be useful to someone else in the future in another context.)
As an alternative to codeka's solution, you can also do something like this (which would avoid having to hard code the en-us day names.)
string[] dayNamesNormal = culture.DateTimeFormat.DayNames;
string[] dayNamesShifted = Shift(dayNamesNormal, (int)DayOfWeek.Monday);
// you probably wanna add some error checking here.
// this method shifts array left by a specified number
// of positions, wrapping the shifted elements back to
// end of the array
private static T[] Shift(T[] array, int positions) {
T[] copy = new T[array.Length];
Array.Copy(array, 0, copy, array.Length-positions, positions);
Array.Copy(array, positions, copy, 0, array.Length-positions);
return copy;
}
I meant to post this sooner but I am fighting a dying external hard drive...