faqts : Computers : Programming : Languages : Asp : ASP/VBScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

62 of 71 people (87%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

Do i need a cab file for Calendar control, when I use it in a Web Page.

Jul 19th, 2001 08:33
Steve Evans, Brian Price, iCalendar RFC doc (http://www.imc.org/rfc2445)


If you want to work with iCalendar files on your web site, it's 
possible to build them using a function, as they are text files. The 
function below is a template for creating these files, based on a given 
location, date, and times for an event. You could then post this file 
on a web page for people to add to their calendar.
Function createICS (sRoom, sDate, sStart, sEnd, sOrganizer)
' sRoom: location for this event
' sDate: date of the event
' sStart, sEnd: Start and end times for the event
' sOrganizer is the email address of the event creator
Dim sFile : sFile = "c:\filename.ics" 'make sure to end in .ics
Dim iFile : Set iFile = filesys.CreateTextFile(sFile, TRUE)
'You'll write the ics file using the ICS format
iFile.WriteLine("BEGIN:VCALENDAR")
'I used tag lines from MS Exchange for this, but you could use others
iFile.WriteLine("PRODID:Microsoft CDO for Microsoft Exchange")
iFile.WriteLine("VERSION:2.0")
iFile.WriteLine("METHOD:PUBLISH")
iFile.WriteLine("BEGIN:VEVENT")
'Datestamp is formatted YYYYMMDDTHHMMSS
iFile.WriteLine("DTSTAMP:20010221T000000")
iFile.WriteLine("ORGANIZER:MAILTO:" & sOrganizer)
'You need a function that converts to UTC (Zulu time), see bottom
Dim dtStart, dtEnd
dtStart = "DTSTART:" & dateToUTC (sDate, sStart)
dtEnd = "DTEND:" & dateToUTC (sDate, sEnd)
iFile.WriteLine(dtStart)
iFile.WriteLine(dtEnd)
'This is an Exchange GUID; you can use others, but you MUST have one
iFile.WriteLine("UID:{A6DEF157-DFCE-40F4-AC77-217563191E7B}")
iFile.WriteLine("SUMMARY:" & sTitle)
iFile.WriteLine("LOCATION:" & sRoom)
'More meeting details (see the spec for details on these)
iFile.WriteLine("SEQUENCE:0")
iFile.WriteLine("PRIORITY:5")
iFile.WriteLine("CLASS:Personal")
iFile.WriteLine("STATUS:CONFIRMED")
iFile.WriteLine("TRANSP:OPAQUE")
iFile.WriteLine("X-MICROSOFT-CDO-BUSYSTATUS:BUSY")
iFile.WriteLine("X-MICROSOFT-CDO-INSTTYPE:0")
' The reminder alarm details
iFile.WriteLine("BEGIN:VALARM")
iFile.WriteLine("TRIGGER:PT10M")
iFile.WriteLine("ACTION:DISPLAY")
iFile.WriteLine("DESCRIPTION:Reminder")
iFile.WriteLine("END:VALARM")
iFile.WriteLine("END:VEVENT")
iFile.WriteLine("END:VCALENDAR")
iFile.close()
End Function
Here's the function to convert to UTC (Zulu or GMT time)
Function dateToUTC (sDate, sTime)
' 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(sDate)
tTime = TimeValue(sTime)
iHour = Hour(DateAdd("h", 4, tTime)) 'correction for US Eastern time
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 & "00Z"
dateToUTC = s
End Function



© 1999-2004 Synop Pty Ltd