Rem2ics: Difference between revisions

From Skoll.CA
Jump to navigation Jump to search
remind>Admin
(New page: :''Main article: Remind'' A script that will convert Remind events to iCalendar format is [http://mark.atwood.name/code/rem2ics here]. It correctly handles details of the iCalenda...)
 
remind>Shane
(Fixed the DTEND calculation to work correctly.)
Line 12: Line 12:
# rem2ics by Anthony J. Chivetta <achivetta@gmail.com>
# rem2ics by Anthony J. Chivetta <achivetta@gmail.com>
# version 0.1 - 2006-06-09
# version 0.1 - 2006-06-09
# version 0.2 - 2010-10-27 (one-line patch by Shane Kerr <shane@time-travellers.org>)
# Converts output of remind -s to iCalendar
# Converts output of remind -s to iCalendar
# usage: remind -s | rem2ics
# usage: remind -s | rem2ics
Line 29: Line 30:
if ($5 != "*"){
if ($5 != "*"){
printf("DTSTART:%dT%02d%02d00\n",$1,$5/60,$5%60)
printf("DTSTART:%dT%02d%02d00\n",$1,$5/60,$5%60)
printf("DTEND:%dT%02d%02d00\n",$1,$5/60+$4/60,$5%60+$4%60)
printf("DTEND:%dT%02d%02d00\n",$1,($5+$4)/60,($5+$4)%60)
print "SUMMARY:" substr($0,match($0,$7))
print "SUMMARY:" substr($0,match($0,$7))
} else {
} else {

Revision as of 06:25, 27 October 2010

Main article: Remind

A script that will convert Remind events to iCalendar format is here. It correctly handles details of the iCalendar format, including required properties, character quoting, line folding, correct EOL, and will recognize and handle recurring events.


Or the following simple script can be used to convert Remind events to iCalendar format. The output is suitable as a read-only format, but is not really designed to be edited (a REM statement that generates periodic reminders will be converted to separate iCal entries for every occurrence).

Among other uses, this script could be used to display your reminders via Google Calendar. Click "Manage calendars"->"Import Calendar" to import the ics file.

#!/usr/bin/awk -f
# rem2ics by Anthony J. Chivetta <achivetta@gmail.com>
# version 0.1 - 2006-06-09
# version 0.2 - 2010-10-27 (one-line patch by Shane Kerr <shane@time-travellers.org>)
# Converts output of remind -s to iCalendar
# usage: remind -s | rem2ics
#
# THE FOLLOWING CODE IS RELEASED INTO THE PUBLIC DOMAIN
#
# 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
BEGIN {
print "BEGIN:VCALENDAR"
print "VERSION:2.0"
}
{
gsub("/","",$1)
print "BEGIN:VEVENT"
if ($5 != "*"){
printf("DTSTART:%dT%02d%02d00\n",$1,$5/60,$5%60)
printf("DTEND:%dT%02d%02d00\n",$1,($5+$4)/60,($5+$4)%60)
print "SUMMARY:" substr($0,match($0,$7))
} else {
printf("DTSTART:%d\n",$1)
print "SUMMARY:" substr($0,match($0,$6))
}
print "END:VEVENT"
}
END {print "END:VCALENDAR"}