Hi folks:
I've got the Day of the week stored in a database table (that I do not control), and I need to use it in my code.
Problem is, I want to use the System.DayOfWeek enum for representation for this, and the sequences are not the same.
In the database, it's as follows:
1 2 3 4 5 6 7
S M T W T F S
I need it as follows:
0 1 2 3 4 5 6
M T W T F S S
What's the most elegant way to do this?
for example, I could do:
i = dayOfWeek;
i = i - 2;
if (i < 0) {
i = 6;
}
but that's a bit inelegant. Any suggestions?
<EDIT>
Ahem. Apparently (.net reflector says) DayOfWeek is 0 indexed starting with Sunday.
Always read the docs before asking daft questions.
However, I'm still interested in an answer, just to satisfy my own curiosity, so go for it.
</EDIT>