Elegantissimo codice .net per visualizzare un calendario html: più piccolo di così non saprei come fare…
[code lang=”vb”]
”’
”’
Function getCalendar(mese As Integer, anno As Integer) As String
Dim giorni = Enumerable.Range(1, Date.DaysInMonth(anno, mese)).Select(Function(n) New DateTime(anno, mese, n)).ToList
Dim lunedi As List(Of DateTime) = (From l In giorni Where l.DayOfWeek = DayOfWeek.Monday Select l).ToList
If giorni(0).DayOfWeek <> DayOfWeek.Monday Then lunedi.Insert(0, lunedi(0).AddDays(-7))
Dim s As String = “
“).ToArray) & “
”
s &= Join(lunedi.Select(Function(k) “
“, “
“)).ToArray) & “
“).ToArray)
Return “
”
End Function
[/code]