mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-03-13 08:00:15 +00:00
New library for parsing iCalendar RRule and generally dealing with iCal dates
This commit is contained in:
parent
858ce08d1f
commit
a83752f81d
135
inc/RRule.php
Normal file
135
inc/RRule.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Class for parsing RRule and getting us the dates
|
||||
*
|
||||
* @package rscds
|
||||
* @subpackage caldav
|
||||
* @author Andrew McMillan <andrew@catalyst.net.nz>
|
||||
* @copyright Catalyst .Net Ltd
|
||||
* @license http://gnu.org/copyleft/gpl.html GNU GPL v2
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Class for handling dates in iCalendar format. We do make the simplifying assumption
|
||||
* that all date handling in here is normalised to GMT. One day we might provide some
|
||||
* functions to do that, but for now it is done externally.
|
||||
*
|
||||
* @package awl
|
||||
*/
|
||||
class iCalDate {
|
||||
/**#@+
|
||||
* @access private
|
||||
*/
|
||||
|
||||
/** Text version */
|
||||
var $_text;
|
||||
|
||||
/** Epoch version */
|
||||
var $_epoch;
|
||||
|
||||
/** Fragmented parts */
|
||||
var $_yy;
|
||||
var $_mm;
|
||||
var $_dd;
|
||||
var $_hh;
|
||||
var $_mm;
|
||||
var $_ss;
|
||||
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The constructor takes either a text string formatted as an iCalendar date, or
|
||||
* epoch seconds.
|
||||
*/
|
||||
function iCalDate( $input ) {
|
||||
if ( preg_match( '/^\d{8}T\d{6}Z/', $input ) ) {
|
||||
$this->SetICalDate($input);
|
||||
}
|
||||
else if ( intval($input) == 0 ) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->SetEpochDate($input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the date from a text string
|
||||
*/
|
||||
function SetICalDate( $input ) {
|
||||
$this->_text = $input;
|
||||
$this->_PartsFromText();
|
||||
$this->_EpochFromParts();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the date from an epoch
|
||||
*/
|
||||
function SetEpochDate( $input ) {
|
||||
$this->_epoch = intval($input);
|
||||
$this->_TextFromEpoch();
|
||||
$this->_PartsFromText();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given an epoch date, convert it to text
|
||||
*/
|
||||
function _TextFromEpoch() {
|
||||
$this->_text = gmdate('Ymd\THis\Z', $this->_epoch );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given an epoch date, convert it to text
|
||||
*/
|
||||
function _PartsFromText() {
|
||||
$this->_yy = substr($this->_text,0,4);
|
||||
$this->_mo = substr($this->_text,4,2);
|
||||
$this->_dd = substr($this->_text,6,2);
|
||||
$this->_hh = substr($this->_text,9,2);
|
||||
$this->_mi = substr($this->_text,11,2);
|
||||
$this->_ss = substr($this->_text,13,2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given a text date, convert it to an epoch
|
||||
*/
|
||||
function _EpochFromParts() {
|
||||
$this->_epoch = gmmktime ( $this->_hh, $this->_mi, $this->_ss, $this->_mo, $this->_dd, $this->_yy );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A Class for handling Events on a calendar
|
||||
*
|
||||
* @package awl
|
||||
*/
|
||||
class RRule {
|
||||
/**#@+
|
||||
* @access private
|
||||
*/
|
||||
|
||||
/** The first instance */
|
||||
var $_first;
|
||||
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The constructor takes a start & end date and an RRULE definition. All of these
|
||||
* follow the iCalendar standard.
|
||||
*/
|
||||
function RRule( $start, $end, $rrule ) {
|
||||
}
|
||||
|
||||
function GetNext( $after = false ) {
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
10
rscds.webprj
10
rscds.webprj
@ -200,8 +200,6 @@
|
||||
<item url="testing/tests/regression-suite/304-Chandler-PROPFIND-2.result" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/304-Chandler-PROPFIND-2.test" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/304-Chandler-TEST-1.data" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/305-Chandler-OPTIONS-3.result" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/305-Chandler-OPTIONS-3.test" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/3F4CF6227300FD062D9EF3CDFB30D32D-0-modified.ics.data" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/3F4CF6227300FD062D9EF3CDFB30D32D-0.ics.data" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/F56B49B10FC923D20FE2DC92D6580340-0.ics.data" uploadstatus="1" />
|
||||
@ -216,15 +214,15 @@
|
||||
<item url="testing/tests/regression-suite/208-Moz-REPORT-5.data" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/208-Moz-REPORT-5.test" uploadstatus="1" />
|
||||
<item url="docs/website/clients/Other-details.php" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/305-Chandler-PROPFIND-3.test" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/306-Chandler-PUT-1.test" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/307-Chandler-PUT-2.test" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/023-Mulberry-DELETE-3.test" uploadstatus="1" />
|
||||
<item url="testing/tests/regression-suite/022-Mulberry-PUT-5.test" uploadstatus="1" />
|
||||
<item url="dba/patches/1.1.5.sql" uploadstatus="1" />
|
||||
<item url="docs/website/wikiheader.css" uploadstatus="1" />
|
||||
<item url="htdocs/collection.php" uploadstatus="1" />
|
||||
<item url="inc/CalDAVRequest.php" uploadstatus="1" />
|
||||
<item url="po/nl_NL.po" />
|
||||
<item url="po/nl_NL.po" uploadstatus="1" />
|
||||
<item url="dba/patches/1.1.6.sql" uploadstatus="1" />
|
||||
<item url="inc/caldav-LOCK.php" uploadstatus="1" />
|
||||
<item url="inc/RRule.php" />
|
||||
</project>
|
||||
</webproject>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user