Calculate end dates, show in calendar

This commit is contained in:
Stefan Schlott 2013-08-27 18:57:14 +02:00
parent d980530cb9
commit 1341647c2a
4 changed files with 29 additions and 3 deletions

View file

@ -24,3 +24,20 @@ def get_public_events()
items.select { |i| (i[:kind]=='event') && i[:public] }
end
def calculate_to_dates()
items.select { |i| (i[:kind]=='event') && i[:duration] }.each do |e|
if e[:startdate].instance_of?(Date)
if e[:duration] =~ /(\d+)d/
e[:enddate] = e[:startdate] + ($1.to_i - 1)
end
else
if e[:duration] =~ /(\d+)h/
e[:enddate] = e[:startdate] + 60*60*$1.to_i
end
if e[:duration] =~ /(\d+)m/
e[:enddate] = e[:startdate] + 60*$1.to_i
end
end
end
end