Remember, Remember the Thirty-Third of November
by in CodeSOD on 2013-10-28Some say that time is nothing but an illusion. The degree to which some software developers struggle with times and dates certainly suggests mysterious and unknowable forces swirling beyond the brink of human understanding. Consider this code that Ian found while pruning an old application. It's meant to provide the correct suffix for any given day of the month:
string num = "th";
int day = Convert.ToInt16(DateTime.Now.ToString("dd"));
switch(day)
{
case 1:
num = "st";
break;
case 21:
num = "st";
break;
case 31:
num = "st";
break;
case 2:
num = "nd";
break;
case 22:
num = "nd";
break;
case 3:
num = "rd";
break;
case 33:
num = "rd";
break;
default:
num = "th";
break;
}