Login   Register  
PHP Classes
elePHPant
Icontem

File: cvt_ical.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of CPK Smithies  >  Palm Desktop  >  cvt_ical.php  >  Download  
File: cvt_ical.php
Role: Example script
Content type: text/plain
Description: Demonstrate conversion of Palm Desktop datebook (calendar) to iCalendar format using imcobjects2
Class: Palm Desktop
Convert Palm Desktop files to other formats
Author: By
Last change:
Date: 2012-10-06 22:09
Size: 910 bytes
 

Contents

Class file image Download
<?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();
    }
}