#!/bin/csh -f
set dtstart=`grep DTSTART $1 |nocr - - |tail -1`
set dttype=`echo $dtstart|grep -c TZID=`

if ( $dttype == 0 ) then
set rawtime=`echo $dtstart |awk -F: '{print $2}' |tr 'Z' ' '|awk -FT '{printf("%s/%s %s:%s:%s %s UTC",substr($1,5,2),substr($1,7,2),substr($2,1,2),substr($2,3,2),substr($2,5,2),substr($1,1,4));}'`
else
set zone=`echo $dtstart |awk '-F;' '{print $2}'|awk -F: '{print $1}'|awk -F= '{print $2}'`
set zonetime=`echo $dtstart |awk '-F;' '{print $2}'|awk -F: '{print $2}'`
set  rawtime=`echo TZ='"'$zone'"';echo $zonetime |awk -FT '{printf("%s/%s %s:%s:%s %s ",substr($1,5,2),substr($1,7,2),substr($2,1,2),substr($2,3,2),substr($2,5,2),substr($1,1,4));}'`
endif

set cookedtime=`date -d "$rawtime"`
set unixtime=`date -d "$rawtime" +%s`
echo -n $unixtime ' '
set summary=`grep SUMMARY $1 |awk -F: '{print $2}'|nocr - -`
set location=`grep LOCATION $1 |awk -F: '{print $2}'|nocr - -`
echo -n $summary ' ' $location ' ' $cookedtime
echo  '   FILE' `basename $1` ' '
