Turns out that I'm The Real WTF, since the Code SOD from earlier today was already posted... last week. Whoops; consequences of posting realllly late at night in a hotel room while at The Business of Software conference I suppose. Anyway, here's one that I'm pretty sure wasn't from last week.


"We recently started using a new CRM system," Gavin Watkinson writes, "and wanted to write some custom functionality for it."

"While looking through the sample code, I came across this snippet. I'm assuming they put this in just on the off chance that the number of days in a week is increased."

Public Function DayOfTheWeek(iDay As Integer) As String
    'Mapping of day number to day-of-the-week string.
    Select Case iDay
    Case 1
        DayOfTheWeek = STR_SUNDAY
    Case 2
        DayOfTheWeek = STR_MONDAY
    Case 3
        DayOfTheWeek = STR_TUESDAY
    Case 4
        DayOfTheWeek = STR_WEDNESDAY
    Case 5
        DayOfTheWeek = STR_THURSDAY
    Case 6
        DayOfTheWeek = STR_FRIDAY
    Case 7
        DayOfTheWeek = STR_SATURDAY
    Case 8
        DayOfTheWeek = STR_SUNDAY
    Case 9
        DayOfTheWeek = STR_MONDAY
    Case 10
        DayOfTheWeek = STR_TUESDAY
    Case 11
        DayOfTheWeek = STR_WEDNESDAY
    Case 12
        DayOfTheWeek = STR_THURSDAY
    Case 13
        DayOfTheWeek = STR_FRIDAY
    End Select
End Function
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!