# this method adds a new record def saveicseventrecord Dir.chdir($progdir) require 'fileutils' require 'lib/icalendar' if ! @a_eventicsfilename.empty? newname = "%s" % [@a_eventicsfilename] # 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_eventicsyear.empty? temptimedata = @a_eventicsyear.to_s.strip else temptimedata = "0000" end if ! @a_eventicsmonth.empty? temptimedata= temptimedata + @a_eventicsmonth.to_s else temptimedata = temptimedata + "00" end if ! @a_eventicsday.empty? temptimedata = temptimedata + @a_eventicsday.to_s else temptimedata = temptimedata + "00" end daydate = temptimedata if ! @a_eventicshour.empty? temptimedata= temptimedata + "T" + @a_eventicshour.to_s else temptimedata = temptimedata + "T" + "00" end if ! @a_eventicsminute.empty? temptimedata = temptimedata + @a_eventicsminute.to_s else temptimedata = temptimedata + "00" end if ! @a_eventendicshour.empty? tempendtimedata= daydate + "T" + @a_eventendicshour.to_s else tempendtimedata = daydate + "T" + "00" end if ! @a_eventendicsminute.empty? tempendtimedata = tempendtimedata + @a_eventendicsminute.to_s else tempendtimedata = tempendtimedata + "00" end if ! @a_eventicssummary.empty? summarydataText = @a_eventicssummary.to_s else summarydataText = "" end if ! @a_eventicsdescription.empty? descriptiondataText = @a_eventicsdescription.to_s else descriptiondataText = "" end if ! @a_eventicslocation.empty? locationdataText = @a_eventicslocation.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 @newicseventresult= calString # show the record info in the browser rescue SystemCallError, StandardError $stderr.print "system call error: " + $! end # exception rescue end end