| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/datetime/src/lmbDate.class.php'); 10 lmb_require('limb/core/src/exception/lmbException.class.php'); 11 12 /** 13 * class lmbDatePeriod. 14 * 15 * @package datetime 16 * @version $Id: lmbDatePeriod.class.php 5945 2007-06-06 08:31:43Z pachanga $ 17 */ 18 class lmbDatePeriod 19 { 20 var $start; 21 var $end; 22 23 function __construct($start, $end) 24 { 25 $this->start = (is_object($start)) ? $start : new lmbDate($start); 26 $this->end = (is_object($end)) ? $end : new lmbDate($end); 27 28 if($this->end->isBefore($this->start)) 29 throw new lmbException('wrong period interval', array('start' => $this->start->toString(), 30 'end' => $this->end->toString())); 31 } 32 33 function toString() 34 { 35 return $this->start->toString() . ' - ' . $this->end->toString(); 36 } 37 38 function getDuration() 39 { 40 return $this->end->getStamp() - $this->start->getStamp(); 41 } 42 43 function getStart() 44 { 45 return $this->start; 46 } 47 48 function getEnd() 49 { 50 return $this->end; 51 } 52 53 function isEqual($period) 54 { 55 return $this->start->isEqual($period->getStart()) && 56 $this->end->isEqual($period->getEnd()); 57 } 58 59 function includes($period) 60 { 61 return ($this->start->isBefore($period->getStart()) && 62 $this->end->isAfter($period->getEnd())); 63 } 64 65 function isInside($period) 66 { 67 return $period->includes($this); 68 } 69 70 function intersects($period) 71 { 72 return $this->isEqual($period) 73 || 74 ($this->start->isBefore($period->getStart()) && $this->end->isAfter($period->getStart())) 75 || 76 ($this->start->isAfter($period->getStart()) && $this->start->isBefore($period->getEnd())); 77 } 78 } 79 80 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Oct 14 04:47:40 2008 | Cross-referenced by PHPXref 0.7 |