Overview

Packages

  • Kronolith
  • None

Classes

  • Kronolith
  • Kronolith_Ajax_Application
  • Kronolith_Ajax_Imple_ContactAutoCompleter
  • Kronolith_Ajax_Imple_Embed
  • Kronolith_Ajax_Imple_TagActions
  • Kronolith_Ajax_Imple_TagAutoCompleter
  • Kronolith_Api
  • Kronolith_Calendar
  • Kronolith_Calendar_External
  • Kronolith_Calendar_External_Tasks
  • Kronolith_Calendar_Holiday
  • Kronolith_Calendar_Internal
  • Kronolith_Calendar_Remote
  • Kronolith_Calendar_Resource
  • Kronolith_Calendars_Base
  • Kronolith_Calendars_Default
  • Kronolith_Calendars_Kolab
  • Kronolith_Day
  • Kronolith_Driver
  • Kronolith_Driver_Holidays
  • Kronolith_Driver_Horde
  • Kronolith_Driver_Ical
  • Kronolith_Driver_Kolab
  • Kronolith_Driver_Mock
  • Kronolith_Driver_Resource
  • Kronolith_Driver_Sql
  • Kronolith_Event
  • Kronolith_Event_Holidays
  • Kronolith_Event_Horde
  • Kronolith_Event_Ical
  • Kronolith_Event_Kolab
  • Kronolith_Event_Resource
  • Kronolith_Event_Sql
  • Kronolith_Exception
  • Kronolith_Factory_Calendars
  • Kronolith_Factory_Geo
  • Kronolith_Form_CreateCalendar
  • Kronolith_Form_CreateResource
  • Kronolith_Form_CreateResourceGroup
  • Kronolith_Form_DeleteCalendar
  • Kronolith_Form_DeleteResource
  • Kronolith_Form_DeleteResourceGroup
  • Kronolith_Form_EditCalendar
  • Kronolith_Form_EditRemoteCalendar
  • Kronolith_Form_EditResource
  • Kronolith_Form_EditResourceGroup
  • Kronolith_Form_SubscribeRemoteCalendar
  • Kronolith_Form_UnsubscribeRemoteCalendar
  • Kronolith_FreeBusy
  • Kronolith_FreeBusy_View
  • Kronolith_FreeBusy_View_Day
  • Kronolith_FreeBusy_View_Month
  • Kronolith_FreeBusy_View_Week
  • Kronolith_FreeBusy_View_Workweek
  • Kronolith_Geo_Base
  • Kronolith_Geo_Mysql
  • Kronolith_Geo_Sql
  • Kronolith_LoginTasks_SystemTask_Upgrade
  • Kronolith_LoginTasks_Task_PurgeEvents
  • Kronolith_Notification_Listener_AjaxStatus
  • Kronolith_Resource
  • Kronolith_Resource_Base
  • Kronolith_Resource_Group
  • Kronolith_Resource_Single
  • Kronolith_Storage
  • Kronolith_Storage_Kolab
  • Kronolith_Storage_Sql
  • Kronolith_Tagger
  • Kronolith_Test
  • Kronolith_View_Day
  • Kronolith_View_DeleteEvent
  • Kronolith_View_EditEvent
  • Kronolith_View_Event
  • Kronolith_View_ExportEvent
  • Kronolith_View_Month
  • Kronolith_View_Week
  • Kronolith_View_WorkWeek
  • Kronolith_View_Year
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Kronolith_Day:: class provides an API for dealing with days.
  4:  *
  5:  * @author  Chuck Hagenbuch <chuck@horde.org>
  6:  * @package Kronolith
  7:  */
  8: class Kronolith_Day extends Horde_Date
  9: {
 10:     /**
 11:      * How many time slots are we dividing each hour into? Set from user
 12:      * preferences.
 13:      *
 14:      * @var integer
 15:      */
 16:     public $slotsPerHour;
 17: 
 18:     /**
 19:      * How many slots do we have per day? Calculated from $_slotsPerHour.
 20:      *
 21:      * @see $_slotsPerHour
 22:      * @var integer
 23:      */
 24:     public $slotsPerDay;
 25: 
 26:     /**
 27:      * How many minutes are in each slot? Calculated from $_slotsPerHour.
 28:      *
 29:      * @see $_slotsPerHour
 30:      * @var integer
 31:      */
 32:     public $slotLength;
 33: 
 34:     /**
 35:      * Array of slots holding hours and minutes for each piece of this day.
 36:      *
 37:      * @var array
 38:      */
 39:     public $slots = array();
 40: 
 41:     /**
 42:      * Constructor.
 43:      *
 44:      * @param integer $month
 45:      * @param integer $day
 46:      * @param integer $year
 47:      */
 48:     public function __construct($month = null, $day = null, $year = null)
 49:     {
 50:         if (is_null($month)) {
 51:             $month = date('n');
 52:         }
 53:         if (is_null($year)) {
 54:             $year = date('Y');
 55:         }
 56:         if (is_null($day)) {
 57:             $day = date('j');
 58:         }
 59:         parent::__construct(array('year' => $year, 'month' => $month, 'mday' => $day));
 60: 
 61:         $this->slotsPerHour = $GLOBALS['prefs']->getValue('slots_per_hour');
 62:         if (!$this->slotsPerHour) {
 63:             $this->slotsPerHour = 1;
 64:         }
 65:         $this->slotsPerDay = $this->slotsPerHour * 24;
 66:         $this->slotLength = 60 / $this->slotsPerHour;
 67: 
 68:         for ($i = 0; $i < $this->slotsPerDay; $i++) {
 69:             $minutes = $i * $this->slotLength;
 70:             $this->slots[$i]['hour'] = (int)($minutes / 60);
 71:             $this->slots[$i]['min'] = $minutes % 60;
 72:         }
 73:     }
 74: 
 75:     public function getTime($format, $offset = 0)
 76:     {
 77:         $date = new Horde_Date(array('month' => $this->month,
 78:                                      'mday' => $this->mday + $offset,
 79:                                      'year' => $this->year));
 80:         return $date->strftime($format);
 81:     }
 82: 
 83:     public function getTomorrow()
 84:     {
 85:         $date = new Horde_Date(array('month' => $this->month,
 86:                                      'mday' => $this->mday + 1,
 87:                                      'year' => $this->year));
 88:         return $date;
 89:     }
 90: 
 91:     public function getYesterday()
 92:     {
 93:         $date = new Horde_Date(array('month' => $this->month,
 94:                                      'mday' => $this->mday - 1,
 95:                                      'year' => $this->year));
 96:         return $date;
 97:     }
 98: 
 99:     public function isToday()
100:     {
101:         return $this->compareDate(new Horde_Date(mktime(0, 0, 0))) == 0;
102:     }
103: 
104:     public function isTomorrow()
105:     {
106:         $date = new Horde_Date(array('month' => $this->month,
107:                                      'mday' => $this->mday - 1,
108:                                      'year' => $this->year));
109:         return $date->compareDate(new Horde_Date(mktime(0, 0, 0))) == 0;
110:     }
111: 
112:     public function diff()
113:     {
114:         $day2 = new Kronolith_Day();
115:         return Date_Calc::dateDiff($this->mday, $this->month, $this->year,
116:                                    $day2->mday, $day2->month, $day2->year);
117:     }
118: 
119: }
120: 
API documentation generated by ApiGen