# this method exports a new record def exporteventrecord Dir.chdir($progdir) require 'fileutils' require 'extras/icalendar' if ! @a_eventfilename.empty? newname = "%s" % [@a_eventfilename] # grab the new filename to create fullnewname = newname + ".ics" cal = Icalendar::Calendar.new cal.version = "3.2" cal.prodid = "rwdtinker-prodid" event = Icalendar::Event.new newdataText = "" if ! @a_eventyear.empty? temptimedata = @a_eventyear.to_s.strip else temptimedata = "0000" end if ! @a_eventmonth.empty? temptimedata= temptimedata + @a_eventmonth.to_s else temptimedata = temptimedata + "00" end if ! @a_eventday.empty? temptimedata = temptimedata + @a_eventday.to_s else temptimedata = temptimedata + "00" end daydate =temptimedata if ! @a_eventbeginhour.empty? temptimedata= temptimedata + "T" + @a_eventhour.to_s else temptimedata = temptimedata + "T" + "00" end if ! @a_eventbeginminute.empty? temptimedata = temptimedata + @a_eventbeginminute.to_s else temptimedata = temptimedata + "00" end if ! @a_eventendhour.empty? tempendtimedata= daydate + "T" + @a_eventendhour.to_s else tempendtimedata = daydate + "T" + "00" end if ! @a_eventendminute.empty? tempendtimedata = tempendtimedata + @a_eventendminute.to_s else tempendtimedata = tempendtimedata + "00" end if ! @a_eventsummary.empty? summarydataText = @a_eventsummary.to_s else summarydataText = "" end if ! @a_eventdescription.empty? descriptiondataText = @a_eventdescription.to_s else descriptiondataText = "" end if ! @a_eventlocation.empty? locationdataText = @a_eventlocation.to_s else locationdataText = "" end starttime = temptimedata + "00" endtime = tempendtimedata + "00" # Create a new event and add it to the calendar event.dtstart = starttime event.dtend = endtime event.summary = summarydataText event.description = descriptiondataText event.location = locationdataText cal.add(event) # Now generate the string and then parse it so we can verify # that everything was set, generated and parsed correctly. calString = cal.to_s p calString #cals = Icalendar::CalendarParser.new(calString).parse # cal2 = cals.first # begin # exception trapped block fileName = File.join( $rwdschedule_directory, fullnewname ) fd = File.open(fileName,"w") fd.print( calString ) # save the record info to the file fd.close @neweventresult= calString # show the record info in the browser # rescue SystemCallError, StandardError # $stderr.print "system call error: " + $! # end # exception rescue end end