Mistři v programování na #hovnokod

C# #1165

Kalendář pro pokročilé...

DateTime FirstDay = new DateTime(TodayDate.Year, TodayDate.Month, 1);
int FirstDateDay = (int)FirstDay.DayOfWeek;
if (FirstDateDay == 0)
    FirstDateDay = 7;

int StartIndex = 0;
for (int i = 1; i < 43; i++)
{
    HtmlTableCell td = (HtmlTableCell)CalendarTable.FindControl("Td" + i.ToString());

    if (i < FirstDateDay)
    {
        StartIndex++;
        td.InnerHtml = "";
        td.Attributes.Add("class", "day none");
        if (i == 6 || i == 7)
            td.Attributes.Add("class", "wend none");
    }
    else
    {
        try
        {
            DateTime LoopDate = new DateTime(TodayDate.Year, TodayDate.Month, i - StartIndex);

            string dayOfLoopDate = LoopDate.DayOfWeek.ToString().Substring(0, 3).ToUpper();
            string CellText = String.Format("<div class=\"date\"><span>{0}</span>{1}.</div>", dayOfLoopDate, (i - StartIndex).ToString());
            CellText += "<div class=\"time\"></div>";
            td.InnerHtml = CellText;
            if ((int)LoopDate.DayOfWeek == 0 || (int)LoopDate.DayOfWeek == 6)
                td.Attributes.Add("class", "wend");
            else
                td.Attributes.Add("class", "day gray");
        }
        catch
        {
            if (i == 36)
                LastRow.Visible = false;
            td.InnerHtml = "";
            td.Attributes.Add("class", "day none");
            if (i == 34 || i == 35 || i == 41 || i == 42)
                td.Attributes.Add("class", "wend none");
        }
    }
}

Václav Holuša,