jcal-unfucker/jcal-unfuck.jq

13 lines
661 B
Text
Executable file

#!/usr/bin/jq -rfc
.[2] # skipping calender header and accessing events
| map( # for each event:
{_type: .[0]} # adding ical type like 'vevent' as ._type property
+ (
.[1] # accessing jCal properties; [1] holds name of iCalendar component, i.e. `vevent`; [2] holds additional components
| map({key: .[0], value: .[3]}) | from_entries # transforming event array structure into object structure
# only tested with vevents. pick() isn't supported in jq on debian bookworm
# | pick(.dtstart, .dtend, .summary, .location, .description, .sequence, .["related-to"]) # allow list of properties
)
)
| sort_by(.dtstart|fromdate) # sorting by event start time