DtMail translations and improvements of vcal2xampia.awk
dtmail: messages of the 'Mail Retrieval' menu of dtmail were left untranslated. French, Italian, Spanish translations were added. vcal2xapia.awk: capacity to handle UTC+n timezones and TODO items added.
This commit is contained in:
committed by
Jon Trulson
parent
bf3ac1b969
commit
9b1f60a713
@@ -1,8 +1,8 @@
|
||||
Hello,
|
||||
The AWK script converts .vcs files into XAPIA format files that can then
|
||||
be dragged and dropped on the Calendar icon of the front panel to
|
||||
insert an appointment in the CDE calendar.
|
||||
|
||||
I have written a simple AWK program to convert .vcs files into
|
||||
XAPIA format files that can then be dragged and dropped on the Calendar
|
||||
icon of the front panel to insert an appointment in the CDE calendar.
|
||||
Initial version:
|
||||
|
||||
The program has some limitations. For the moment, it ignores ToDo items
|
||||
and only converts appointment items. Also, it has to convert
|
||||
@@ -13,34 +13,31 @@ This is done by using an average duration of 30.44 days for a month
|
||||
and 365.25 days for a year instead of using the correct duration for
|
||||
leap years and for months. So the duration of an appointment can
|
||||
be sometimes calculated incorrectly.
|
||||
Appointments in the local time are not handled very well. The script
|
||||
assumes that the local time is UTC+1.
|
||||
|
||||
If you wish to include it with the CDE sources or to post it on the Wiki
|
||||
documentation, I agree to release it under MIT license.
|
||||
It is released under MIT license.
|
||||
http://opensource.org/licenses/MIT
|
||||
|
||||
Otherwise, there are better programs in Perl by Adam Stein at:
|
||||
Better programs (in Perl) to interact with dtcm by Adam Stein are available at:
|
||||
http://www.csh.rit.edu/~adam/Progs/programs.html
|
||||
but they require to install some extra Perl libraries.
|
||||
They require to install the Calendar-CSA-0.8.tar.gz Perl libraries from CPAN.
|
||||
|
||||
|
||||
I would like to mention that Christian Pélissier (author of a popular
|
||||
textbook on Unix in French) has posted a dtksh program in a french
|
||||
Christian P<EFBFBD>lissier has posted a dtksh program in a french
|
||||
email list on Solaris x86 that also does the vcal to XAPIA
|
||||
conversion. His message is archived here:
|
||||
http://www.mail-archive.com/solaris_fr@x86.sun.com/msg02388.html
|
||||
|
||||
Please add in the comments at the top of my AWK program the links to
|
||||
his dtksh program and to Adam Stein's Perl programs:
|
||||
http://www.csh.rit.edu/~adam/Progs/programs.html
|
||||
|
||||
Version 2.2.4:
|
||||
|
||||
- improvements to the script to handle repeating appointments.
|
||||
|
||||
The script supports appointments that repeat every N week/month/days.
|
||||
- easter.awk: script that creates appointments for (Roman Catholic)
|
||||
Easter, Ascencion Day and Whit Sunday.
|
||||
Easter, Ascension Day and Whit Sunday.
|
||||
|
||||
Best wishes,
|
||||
Current version:
|
||||
|
||||
Edmond Orignac
|
||||
- added support for ToDo items.
|
||||
- added support for numeric timezones (TZ:+NN or TZ:-NN).
|
||||
|
||||
|
||||
@@ -6,12 +6,16 @@
|
||||
BEGIN {FS=":"}
|
||||
|
||||
|
||||
/^BEGIN/ {if ($2~"VEVENT") {appnt=1; rxtype=0; nxr=0; mxday=0; mxmonth=0; runtil=0; xinterval=0}
|
||||
}
|
||||
/^TZ/ {if ($2~"[+-][1-9]*") {timezone=$2} else {timezone=0}}
|
||||
/^BEGIN/ {if ($2~"VEVENT") {appnt=1; rxtype=0; nxr=0; mxday=0; mxmonth=0; runtil=0; xinterval=0} else if ($2~"VTODO") {appnt=2 ; rxtype=0; nxr=0; mxday=0; mxmonth=0; runtil=0;xinterval=0}}
|
||||
/^TZ/ {if ($2~"[+-][1-9]*") {timezone=$2} else {timezone=1}}
|
||||
# Knowing the timezone, we can convert local time to UTC time.
|
||||
# Unfortunately, it is only working if the timezone is indicated by
|
||||
# a number as in "TZ:+03" not in the case of TZ=Europe/Paris.
|
||||
# If we fail to get a numeric value, we assume the timezone is UTC+1
|
||||
/^DTSTART/ {sdate=$2}
|
||||
/^DTEND/ {fdate=$2}
|
||||
/^DTEND/ {fdate=$2}
|
||||
/^DUE/ {ddate=$2; tsksts=2304}
|
||||
/^COMPLETED/ {ddate=$2;tsksts=6}
|
||||
/^DESCRIPTION/ {summary=summary" "substr($0,13)}
|
||||
/^SUMMARY/ {summary=summary" "substr($0,9)}
|
||||
/^LOCATION/ {summary=summary" in "substr($0,10)}
|
||||
@@ -152,14 +156,14 @@ BEGIN {FS=":"}
|
||||
printf("-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Repeat Interval//EN:uinteger:%d\n",rinterval);
|
||||
print "-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Entry Delimiter//EN:string:end";
|
||||
printf("\tDate: %s/%s/%s\n",substr(sdate,5,2),substr(sdate,7,2),substr(sdate,1,4));
|
||||
# The start/end time are in UTC and have to be converted to local time. We assume the local time is UTC+1
|
||||
# The start/end time are in UTC and have to be converted to local time. We assume the local time is UTC+1 unless we know the shift from UTC.
|
||||
shour=substr(sdate,10,2);
|
||||
smin=substr(sdate,12,2);
|
||||
fhour=substr(fdate,10,2);
|
||||
fmin=substr(fdate,12,2);
|
||||
if ((fhour+fmin+shour+smin)==0) {fhour=01;fmin=42;shour=01;smin=41}
|
||||
shour++;
|
||||
fhour++;
|
||||
shour+=timezone;
|
||||
fhour+=timezone;
|
||||
printf("\tStart: %.2d%.2d\n",shour,smin)
|
||||
printf("\tEnd: %.2d%.2d\n",fhour,fmin)
|
||||
if (rxtype==0) {print "\tRepeat: One Time"};
|
||||
@@ -183,6 +187,75 @@ BEGIN {FS=":"}
|
||||
fdate="";
|
||||
appnt=0;
|
||||
summary="";
|
||||
}
|
||||
} else if ($2~"VTODO") {
|
||||
|
||||
# We are reproducing the code for repetition of an event above. This could be refactored as a function to make the program more elegant.
|
||||
|
||||
}
|
||||
if (runtil==1) {
|
||||
uyear=substr(xuntil,1,4)-substr(sdate,1,4);
|
||||
umonth=substr(xuntil,5,2)-substr(sdate,5,2);
|
||||
uday=substr(xuntil,7,2)-substr(sdate,7,2);
|
||||
if (rxtype==1) nxr=int(365.25*uyear+30.44*umonth+uday)+1;
|
||||
if (rxtype==2) nxr=int((365.25*uyear+30.44*umonth+uday)/7.0)+1;
|
||||
if (rxtype==3) nxr=int((365.25*uyear+30.44*umonth+uday)/14.0)+1;
|
||||
if ((rxtype==4)||(rxtype==5)) nxr=12*uyear+umonth+1;
|
||||
if (rxtype==6) nxr=uyear+1;
|
||||
if (rxtype==7) nxr=int((365.25*uyear+30.44*umonth+uday)/xinterval)+1;
|
||||
if (rxtype==8) nxr=int((365.25*uyear+30.44*umonth+uday)/(7*xinterval))+1;
|
||||
if (rxtype==9) nxr=int((12*uyear+umonth)/xinterval)+1;
|
||||
if (rxtype==10) nxr=int(5.0*(365.25*uyear+30.44*umonth+uday)/7.0)+1;
|
||||
if (rxtype==11) nxr=int(3.0*(365.25*uyear+30.44*umounth+uday)/7.0)+1;
|
||||
if (rxtype==12) nxr=int(3.0*(365.25*uyear+30.44*umounth+uday)/7.0)+1;
|
||||
if (nxr<0) nxr=0;
|
||||
};
|
||||
|
||||
# Start hour and End hour have to be converted to UTC first if timezone is defined.
|
||||
|
||||
printf("\n\n")
|
||||
print "\t** Calendar Appointment **"
|
||||
print "-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Entry Delimiter//EN:string:begin";
|
||||
printf("-//XAPIA/CSA/ENTRYATTR//NONSGML Start Date//EN:datetime:%s\n",ddate);
|
||||
print "-//XAPIA/CSA/ENTRYATTR//NONSGML Type//EN:uinteger:1";
|
||||
print "-//XAPIA/CSA/ENTRYATTR//NONSGML Classification//EN:uinteger:0";
|
||||
print "-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Show Time//EN:sinteger:1"
|
||||
print "-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Show Time//EN:sinteger:1";
|
||||
printf("-//XAPIA/CSA/ENTRYATTR//NONSGML Summary//EN:string:%s\n",summary);
|
||||
printf ("-//XAPIA/CSA/ENTRYATTR//NONSGML Status//EN:uinteger:%d\n",tsksts);
|
||||
printf("-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Repeat Type//EN:sinteger:%d\n",rxtype);
|
||||
printf("-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Repeat Times//EN:uinteger:%d\n",nxr);
|
||||
print "-//XAPIA/CSA/ENTRYATTR//NONSGML Audio Reminder//EN:reminder:300:";
|
||||
print "-//XAPIA/CSA/ENTRYATTR//NONSGML Popup Reminder//EN:reminder:300:";
|
||||
print "-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Repeat Occurrence Number//EN:sinteger:-1";
|
||||
printf("-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Repeat Interval//EN:uinteger:%d\n",rinterval);
|
||||
print "-//CDE_XAPIA_PRIVATE/CSA/ENTRYATTR//NONSGML Entry Delimiter//EN:string:end";
|
||||
printf("\tDate: %s/%s/%s\n",substr(ddate,5,2),substr(ddate,7,2),substr(ddate,1,4));
|
||||
# The start/end time are in UTC and have to be converted to local time. We assume the local time is UTC+1 unless we have a numeric value for timezone shift.
|
||||
shour=substr(ddate,10,2);
|
||||
smin=substr(ddate,12,2);
|
||||
if ((shour+smin)==0) {shour=01;smin=41}
|
||||
shour+=timezone;
|
||||
printf("\tStart: %.2d%.2d\n",shour,smin)
|
||||
if (rxtype==0) {print "\tRepeat: One Time"};
|
||||
if (rxtype==1) {print "\tRepeat: Daily"};
|
||||
if (rxtype==2) {print "\tRepeat: Weekly"};
|
||||
if (rxtype==3) {print "\tRepeat: Every Two Weeks"};
|
||||
if (rxtype==4) {print "\tRepeat: Monthly By Weekday"};
|
||||
if (rxtype==5) {print "\tRepeat: Monthly By Date"};
|
||||
if (rxtype==6) {print "\tRepeat: Yearly"}
|
||||
if (rxtype==7) {printf("\t Repeat Every %d days\n",xinterval)}
|
||||
if (rxtype==8) {printf("\t Repeat Every %d weeks\n",xinterval)}
|
||||
if (rxtype==9) {printf("\t Repeat Every %d months\n",xinterval)}
|
||||
if (rxtype==10) {print "\tRepeat: Monday thru Friday"};
|
||||
if (rxtype==11) {print "\tRepeat: Mon, Wed, Fri"};
|
||||
if (rxtype==12) {print "\tRepeat: Tuesday, Thursday"};
|
||||
printf("\tFor: %d\n",nxr);
|
||||
printf("\tWhat: %s\n",summary);
|
||||
printf("\t\n");
|
||||
sdate="";
|
||||
fdate="";
|
||||
appnt=0;
|
||||
summary="";
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user