[SOLVED] what is the datetime format for perl/soap sample script
Somebody please help me!
I am trying to migrate our institute's group calendar to Zimbra calendar and hit some walls here. Our old calendar system uses another program which uses Postgres database to hold all calendar info and there is no way to export the date to zimbra directly. I tried to reformat the data to ical format and used curl command to post data directly to zimbra. For single appointments it is alright. But for meetings I seemed not linking all attendees to the organizer unless I login to zimbra as the organizer, open the meeting and re-save the meeting then all the attendees will get the invitation email After attendee accepted the meeting then it will appear in the attendee's calendar. We have more than 200 people in our institute and this is definitely not the right way to migrate a calendar. My supervisor thinks using soap may help. I have been looking at the examples using perl/soap module on the /ZimbraServer/src/perl/soap/ and have some difficulty to run the sample script createAppt.pl. I have installed all required modules on the server and run "perl createAppt.pl $meetingTitle $startdate enddate". But no matter what format of startdate and enddate I tried I always get the error
RESPONSE:
--------------
<ns0:Fault xmlns:ns0="http://www.w3.org/2003/05/soap-envelope">
<ns0:Code>
<ns0:Value>soap:Sender</ns0:Value>
</ns0:Code>
<ns0:Reason>
<ns0:Text>invalid request: Caught ParseException: java.text.ParseException: Invalid date/time specified: 2007-09-27T12:00:00</ns0:Text>
...
I have tried "20070927 12:00:00-04", "20070927T120000z", "20070927T120000" and "2007-09-27T12:00:00". Nothing worked. :(
Have any of you tried this successfully and what is the date format you used? Thanks in advance,
Jing
The datetime format for perl/soap
The datetime format is
yyyymmddThhmmss[Z]
The Z at the end is optional. Our original datetime string is "yyyy-mm-dd hh:mm:ss-04", so I wrote a perl subroutine to reformat the time string. If you want it I can email to you.
Good luck,
Jing
perl sub for reformat the datetime
Here is the subroutine. Since our data is only from May 2003 to end of 2008, so I only have one leap year(2008) included. You can add more if you need it.
Hope it helps,
Jing
Code:
###############################################################################
# subroutine formatTime($old_time )
# This subroutine reformat the time string to the time format of ical format
# of "yyyymmddThhmmssZ".
#
##############################################################################
sub formatTime {
my ($old_time) = @_;
my ($new_time, $yr, $mon, $day, $hr, $min, $sec, $tz);
$old_time =~ /(\d{4})\D(\d{2})\D(\d{2})\s(\d{2})\:(\d{2})\:(\d{2})\-(\d{2})/;
$yr = $1;
$mon = $2;
$day = $3;
$hr = $4;
$min = $5;
$sec = $6;
$tz = $7;
$hr += $tz;
#== hour can not larger than 23:
if ($hr> 23) {
$day++;
$hr = $hr - 24;
}
#== month days:
if ($day > 30 && ($mon eq "04" || $mon eq "06" || $mon eq "09" || $mon eq "11")) {
$mon++;
$day = $day - 30;
} elsif ($day > 31 && ($mon eq "01" || $mon eq "03" || $mon eq "05" || $mon eq "07" || $mon eq "08" || $mon eq "10" || $mon eq "12")) {
$mon++;
$day = $day - 31;
} elsif ($day > 28 && $mon eq "02" && $yr ne "2008") {
$mon++;
$day = $day - 28;
} elsif ($day > 29 && $mon eq "02" && $yr eq "2008") {
$mon++;
$day = $day - 29;
}
#== year:
if ($mon > 12) {
$mon = $mon - 12;
$yr++;
}
#== reformat the strings:
if (length($hr) < 2) {
$hr = "0" . $hr;
}
if (length($day) < 2) {
$day = "0" . $day;
}
if (length($mon) < 2) {
$mon = "0" . $mon;
}
#== create the new time string:
$new_time = $yr . $mon . $day . "T" . $hr . $min . $sec . "Z";
return $new_time;
}