Skip to content

Instantly share code, notes, and snippets.

@christoph-frick
Created September 1, 2021 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christoph-frick/dce128ccd6112dc6eac215f66eebdb7a to your computer and use it in GitHub Desktop.
Save christoph-frick/dce128ccd6112dc6eac215f66eebdb7a to your computer and use it in GitHub Desktop.
Convert ICS to PAL
@Grapes([
@Grab('org.slf4j:slf4j-simple:1.7.32'),
@Grab('org.mnode.ical4j:ical4j:3.1.0'),
])
import net.fortuna.ical4j.data.CalendarBuilder
import net.fortuna.ical4j.model.Component
import net.fortuna.ical4j.model.Property
import net.fortuna.ical4j.model.component.CalendarComponent
import net.fortuna.ical4j.model.property.DateProperty
// disable the need for jcache
System.setProperty("net.fortuna.ical4j.timezone.cache.impl", "net.fortuna.ical4j.util.MapTimeZoneCache")
// shut up logging
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "warn")
assert args.length>0
def fileName = args[0]
assert (fileName as File).exists()
println "XX ${args[0]}"
new CalendarBuilder().build(new FileInputStream(fileName)).getComponents(Component.VEVENT).each{
def dtstart = it.getProperty(Property.DTSTART).date
def summary = it.getProperty(Property.SUMMARY).value
println "${dtstart.format('yyyyMMdd')}\t${summary}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment