Fix ical generation

The ical generation failed in some case like report on #343. Now the
ical generation work.

fix #343