Er zijn zo van die momenten dat ik bekijk wat ik een maand of twee geleden geschreven heb en dat ik mij afvraag what the drat was I thinking:

function getCalendar(thisDate,beginDay,stopDay) 
  dim ret
  dim startday, endday, prv, nxt, totalTD, dayTmp, calTmp
  
  ret=""
  if (thisDate="") then 
    thisDate=now()
  end if
  
  daysInMonth=day(dateadd("d",-1,dateadd("m",1,dateserial(year(thisdate),month(thisdate),1))))
  startday=Weekday(dateserial(year(thisdate),month(thisdate),1),vbMonday)
  endday=Weekday(dateserial(year(thisdate),month(thisdate),daysInMonth),vbMonday)
  totalTD=daysInMonth+(startday-1)+(7-endday)
    
  prv=DateAdd("m",-1,thisDate)
  nxt=DateAdd("m",1,thisDate)
  
  ret=ret&"<div class=""colbox1""><table id=""calendar"" cellspacing=""0"" cellpadding=""0"" summary="""&pageCalendarSummary&""">"
  ret=ret&"<caption class=""nav""><a href=""events/"&year(prv)&"/"&month(prv)&""" title="""&calendarPrevMonth&""">««</a> "
  ret=ret&"<a href=""events/"&year(thisDate)&"/"&month(thisDate)&""" title="""&MonthName(Month(thisDate))&" "&year(thisDate)&""">"
  ret=ret&MonthName(Month(thisDate))&" "&year(thisDate)
  ret=ret&"</a> <a href=""events/"&year(nxt)&"/"&month(nxt)&""" title="""&calendarNextMonth&""">»»</a></caption>"
  ret=ret&"<tr>"
  for f=1 to 7
    dayname=WeekdayName(f,false,vbMonday)
    ret=ret&"<th scope=""col"" abbr=""&dayname&"" title=""&dayname&"">"&ucase(left(dayname,1))&"</th>"
  next
  ret=ret&"</tr>"
  
  
  qry="select datefrom, case when dateuntil is null then datefrom else dateuntil end dateuntil from vwNewsAll where event=1 and "
  qry=qry&"((month(datefrom)="&month(thisDate)&" or month(dateuntil)="&month(thisDate)&") or "
  qry=qry&"(month(datefrom)< ="&month(thisDate)&" and month(dateuntil)>="&month(thisDate)&")) order by datefrom"
  rs.Open qry, cn
  
  dim eventDays(33)
    
  while (not(rs.EOF))
    'ret=ret&rs.Fields("datefrom")&"--"&rs.Fields("dateuntil")&"<br />"
    'ret=ret&month(rs.Fields("datefrom"))&" "
    
    tmpStartDay=rs.Fields("datefrom")
    tmpEndDay=rs.Fields("dateuntil")
    if (tmpStartDay<dateserial (year(thisDate), month(thisDate), 1)) then
      tmpStartDay=1
    else
      tmpStartDay=day(tmpStartDay)
    end if
    if (tmpEndDay>DateSerial(year(thisDate), month(thisDate), daysInMonth)) then
      tmpEndDay=daysInMonth
    else
      tmpEndDay=day(tmpEndDay)
    end if
    for q=tmpStartDay to tmpEndDay
      eventDays(q)=1
    next 
    
    rs.MoveNext
  wend

  rs.Close
  
  dayTmp=0
  for f=1 to totalTD
    calTmp=f-startday+1
    if (dayTmp=0) then
      ret=ret&"<tr>"
    end if
    if (DateSerial(year(thisDate), month(thisDate), calTmp)=dateserial(year(now()),month(now()),day(now()))) then
      ret=ret&"<td class=""today"">"
    elseif (calTmp< =stopDay and calTmp>=beginDay) then
      ret=ret&"</td><td class=""eventday"">"
    else
      ret=ret&"</td><td>"
    end if
    if ((f<startday ) or (f>(daysInMonth+startday-1))) then
      ret=ret&" "
    else
      if (eventDays(calTmp)=1) then
        ret=ret&"<a href=""events/"&year(thisDate)&"/"&month(thisDate)&"/"&calTmp&""">"&calTmp&"</a>"
      else
        ret=ret&calTmp
      end if
    end if
    ret=ret&"</startday></td>"
    if (dayTmp=6) then
      ret=ret&"</tr>"
    end if
    if (dayTmp=6) then
      dayTmp=0
    else
      dayTmp=dayTmp+1
    end if
  next
  
  ret=ret&"</dateserial></table>"
  ret=ret&"<ul class=""callinks"">"
  ret=ret&"<li><a href=""events/"">Current/upcoming</a></li>"
  ret=ret&"<li><a href=""events/thisweek/"">This week</a></li>"
  ret=ret&"<li><a href=""events/nextweek/"">Next week</a></li>"
  ret=ret&"<li><a href=""events/"&year(now())&"/"&month(now())&""">This month</a></li>"
  ret=ret&"</ul></div>"
  getCalendar=ret

end function

Nope: geen flauw gedacht. Your guess is as good as mine.

Geschreven al luisterend naar: Arbeid Adelt! – Des duivels oorkussen – Nergens heen



Reacties

2 reacties op “Uiyngk?”

  1. Vreemd, als ik uw “over mezelf” lees, vraag ik mij af: waar heeft die mens dat allemaal geleerd? Heb zelf ook in een ver verleden rechten gestudeerd, ondertussen in een half IT half marketing omgeving terechtgekomen… Maar dit soort dingen, nooit aan toegekomen.
    Ook ooit echt goesting voor gehad, eigenlijk.
    (alhoewel, ik herinner mij een cursus “basic voor beginners”, in het middelbaar 🙂

  2. Ook nooit, bedoel ik.