Location: PHPKode > scripts > PalmDesktop > cvt_ical.php
<?php
/**
 * Convert palm datebook files to iCalendar files
 * @author CPKS
 * @version 1.0
 * @package palmdata
 */
require 'icalevent.php';

/**
 * Dump file.dat to file.ics
 * @param string $filename
 */
function cvt_datebook($filename) {
  $outfile = pathinfo($filename);
	$outfile = $outfile['dirname'] . '/' . $outfile['filename'] . '.ics';
  $pf = new palmdata\datebookFile($filename);
	$cal = new imc\iCalendar;
  $cal->setVersion();
  $cal->add_simple_prop('PRODID', 'palmfile//CPKS//0.1');
  foreach ($pf as $rec) $cal->addComponent($rec->vevent());
  $cal->writeFile($outfile);
}

palmdata\datebookFile::register_event_class('palmdata\i_event');
$progname = array_shift($argv);

while ($fn = array_shift($argv)) {
  try {
		cvt_datebook($fn);
		echo 'converted ', basename($fn), PHP_EOL;
	}
	catch (\Exception $e) {
	  echo "Exception caught whilst processing $fn:\n";
		echo $e->getMessage();
	}
}
Return current item: PalmDesktop