cccs-website/scripts/tweet-reminders.rb
2014-12-10 12:42:10 +01:00

29 lines
631 B
Ruby
Executable file

#!/usr/bin/env ruby
# encoding: utf-8
require 'date'
require 'ri_cal'
days=ARGV[0].to_i
infotext=ARGV[1]
outputlen=140
urllen=24
RiCal.parse($stdin).each do |calendar|
calendar.events.each do |event|
start = event.dtstart.to_date
if (start-Date.today())==days
output = "#{infotext} #{event.summary}".byteslice(0,outputlen)
if event.url and event.url.length>0
if output.length + urllen + 1 > outputlen
output = "#{output.byteslice(0,outputlen - urllen - 1)} #{event.url}"
else
output = "#{output} #{event.url}"
end
end
puts output
end
end
end