#!/bin/awk -f # This script is adapted from Uli Martens vcard2pal script. # http://www.youam.net/devel/vcard2pal/ # # This script converts ical calendar events to pal output. # Usage: vcal2pal ical.ics > personal.pal # Copyright (C) 2009 Juho Rutila # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . BEGIN { FS=":"; print "00 Personal"; } /\r$/ { # skip carriage return at the end of the line $0=substr($0,0,length-1) } /^BEGIN:VEVENT/ { summary = ""; palday=""; year=""; location=""; sdate=""; edate=""; i=""; } /^SUMMARY/ { summary=$2 } /^LOCATION/ { location=$2 } /^DTSTART/ { split($2, arrday, "T"); sdate = arrday[1]; stime = substr(arrday[2], 1, 2) ":" substr(arrday[2], 3, 2); } /^DTEND/ { split($2, arrday, "T"); edate = arrday[1]; etime = substr(arrday[2], 1, 2) ":" substr(arrday[2], 3, 2); } /^END:VEVENT/ { for (i=sdate; i<=edate;) { if (i == sdate) ss = stime; else ss = " "; if (i == edate) ee = etime; else ee = " "; print i " " ss "-" ee " " summary " @ " location cmd = "date --date \"" i " +1 day\" +%Y%m%d" (cmd) | getline i close(cmd) } } # vim: set tabstop=16: