Calendar-CSA

 view release on metacpan or  search on metacpan

test.pl  view on Meta::CPAN


#    This file is public domain and is not placed under any copyright


# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

use Calendar::CSA;

$user = scalar getpwuid($>);
$host = "localhost";

print "Attempting to open database $user\@$host...\n";

$caladdr = "$user\@$host";

($user, $host) = split(/@/, $caladdr);

print "Logging on...\n";
$session = Calendar::CSA::logon("",
	{	user_name => $caladdr,
		user_type => 'INDIVIDUAL',
		calendar_address => $caladdr
	} );

# Turn long standard names into short non-standard names
$session->short_entry_names(1);

# Turn ISO times into UNIX times
$session->unix_times(1);

print "VER SPEC: ",$session->query_configuration("VER SPEC"),"\n";
print "UI AVAIL: ",$session->query_configuration("UI AVAIL"),"\n";

eval
{
    print "Calendars: ", join(", ", Calendar::CSA::list_calendars($host)),"\n";
};
print ($@) if ($@);

print "Calendar attributes: ",join(", ", $session->list_calendar_attributes),"\n";

print "Number of entries: ", $session->read_calendar_attributes("Number Entries")->{value},"\n";

$entrylist = $session->list_entries(
	'Start Date' => {
    	type => 'DATE TIME',
       value => '19940101T010654Z',
        match => 'GREATER THAN'
    },
	'Start Date' => {
    	type => 'DATE TIME',
        value => '19991230T010654Z',
        match => 'LESS THAN'
    },
);

print "Records starting between January 1st, 1994 and and December 30th, 1990: ",scalar(@entries),"\n";
foreach ($entrylist->entries) {
	print "\tSummary of entry starting on ", scalar(localtime($_->read_entry_attributes('Start Date')->{value}));
	print ": \"", $_->read_entry_attributes('Summary')->{value},"\"\n";
}

print "Logging off.\n";

$session->logoff();

print "The test is done.\n";

__END__;



( run in 0.876 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )