pratie

iCalendar Output

<% dim savepath:savepath = Server.MapPath("/") & "\lab\icalendar\output\" Dim intCounter, timestamp, sEvent timestamp = right(Year(Date),2) & Month(Date) & Day(Date) & Hour(Now) & Minute(Now) & Second(Now) sEvent = trim(request.form("Event_Name")) sCalCheck = trim(request.form("cal_field")) if sCalCheck <> "" then response.write "" response.end end if if sEvent = "" then response.write "

An event name was not entered. Please go back and fill out the form properly.

" response.end else sEvent = Replace(sEvent,"%20"," ") sLoc = trim(request("location")) sDesc = replace(trim(request("description")),VbCrLf," ") sStart = request("start_date") & " " & request("start_time") sEnd = request("end_date") & " " & request("end_time") end if if Len(sStart) > 22 Or Len(sEnd) > 22 Or Len(sDesc) > 300 Or Len(sLoc) > 100 then response.write "

An error occurred. Please go back and fill out the form properly.

" response.end end if %>

Please consider making a donation today.

Calendar Add Event To Your Calendar
(If prompted to OPEN or SAVE, choose OPEN)

You can also right click on the link above, select "Save Target As..." and then open the file in notepad to view the code.

Here are the contents of the .ics file.

<% Function dateToUTC (sValue) ' returns a UTC-formatted string describing the date and time ' The UTC format is YYYYMMDDTHHMMSS plus Z for Greenwich Mean Time Dim iHour, iMin, iYear, iMonth, iDay, tDate, tTime tDate = DateValue(sValue) tTime = TimeValue(sValue) 'iHour = Hour(DateAdd("h", 4, tTime)) 'correction for US Eastern time iHour = Hour(tTime) iMin = Minute(tTime) iYear = Year(tDate) iMonth = Month(tDate) iDay = Day(tDate) Dim s : s = iYear if iMonth < 10 then s = s & "0" s = s & iMonth if iDay < 10 then s = s & "0" s = s & iDay & "T" if iHour < 10 then s = s & "0" s = s & iHour if iMin < 10 then s = s & "0" s = s & iMin & "00" 'removed the Z dateToUTC = s End Function %> <% '' create the .vcs file Set fso = CreateObject("Scripting.FileSystemObject") Set myFile = fso.CreateTextFile(savepath & "event-" & timestamp & ".ics", true) 'prod 'Set myFile = fso.CreateTextFile("d:\inetpub\pratiev5\playground\play\icalendar\output\event-" & timestamp & ".ics", true) 'dev myFile.WriteLine("BEGIN:VCALENDAR") myFile.WriteLine("VERSION:1.0") myFile.WriteLine("BEGIN:VEVENT") myFile.WriteLine("DTSTART:" & dateToUTC(sStart) & "") myFile.WriteLine("DTEND:" & dateToUTC(sEnd) & "") myFile.WriteLine("LOCATION:" & sLoc & "") myFile.WriteLine("DESCRIPTION:" & sDesc & "") myFile.WriteLine("SUMMARY:" & sEvent & "") myFile.WriteLine("PRIORITY:3") myFile.WriteLine("END:VEVENT") myFile.WriteLine("END:VCALENDAR") myFile.Close Set myFile = Nothing Set fso = Nothing response.write "
" & _
"BEGIN:VCALENDAR" & vbcrlf & _
"VERSION:1.0" & vbcrlf & _
"BEGIN:VEVENT" & vbcrlf & _
"DTSTART:" & dateToUTC(sStart) & "" & vbcrlf & _
"DTEND:" & dateToUTC(sEnd) & "" & vbcrlf & _
"SUMMARY:" & sEvent & "" & vbcrlf & _
"LOCATION:" & sLoc & "" & vbcrlf & _
"DESCRIPTION:" & sDesc & "" & vbcrlf & _
"PRIORITY:3" & vbcrlf & _
"END:VEVENT" & vbcrlf & _
"END:VCALENDAR" & vbcrlf & _
"
" %>

« Create another event (.ics) file