当前位置: 首页>>代码示例>>PHP>>正文


PHP Kronolith::parseDate方法代码示例

本文整理汇总了PHP中Kronolith::parseDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::parseDate方法的具体用法?PHP Kronolith::parseDate怎么用?PHP Kronolith::parseDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kronolith的用法示例。


在下文中一共展示了Kronolith::parseDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveTask

 /**
  * TODO
  */
 public function saveTask()
 {
     if (!$GLOBALS['registry']->hasMethod('tasks/updateTask') || !$GLOBALS['registry']->hasMethod('tasks/addTask')) {
         return false;
     }
     $id = $this->vars->task_id;
     $list = $this->vars->old_tasklist;
     $task = $this->vars->task;
     $result = $this->_signedResponse('tasklists|tasks/' . $task['tasklist']);
     $due = trim($task['due_date'] . ' ' . $task['due_time']);
     if (!empty($due)) {
         try {
             $due = Kronolith::parseDate($due);
             $task['due'] = $due->timestamp();
         } catch (Exception $e) {
             $GLOBALS['notification']->push($e, 'horde.error');
             return $result;
         }
     }
     if ($task['alarm']['on']) {
         $value = $task['alarm']['value'];
         $unit = $task['alarm']['unit'];
         if ($value == 0) {
             $value = $unit = 1;
         }
         $task['alarm'] = $value * $unit;
         if (isset($task['alarm_methods']) && isset($task['methods'])) {
             foreach (array_keys($task['methods']) as $method) {
                 if (!in_array($method, $task['alarm_methods'])) {
                     unset($task['methods'][$method]);
                 }
             }
             foreach ($task['alarm_methods'] as $method) {
                 if (!isset($task['methods'][$method])) {
                     $task['methods'][$method] = array();
                 }
             }
         } else {
             $task['methods'] = array();
         }
     } else {
         $task['alarm'] = 0;
         $task['methods'] = array();
     }
     unset($task['alarm_methods']);
     if (!isset($task['completed'])) {
         $task['completed'] = false;
     }
     if ($this->vars->recur && !empty($due)) {
         $task['recurrence'] = Kronolith_Event::readRecurrenceForm($due, 'UTC');
     }
     $task['tags'] = Horde_Util::getFormData('tags');
     try {
         $ids = $id && $list ? $GLOBALS['registry']->tasks->updateTask($list, $id, $task) : $GLOBALS['registry']->tasks->addTask($task);
         if (!$id) {
             $id = $ids[0];
         }
         $task = $GLOBALS['registry']->tasks->getTask($task['tasklist'], $id);
         $result->tasks = array($id => $task->toJson(false, $GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:i A'));
         $result->type = $task->completed ? 'complete' : 'incomplete';
         $result->list = $task->tasklist;
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         return $result;
     }
     if ($due && ($kronolith_driver = $this->_getDriver('tasklists|tasks/' . $task->tasklist))) {
         try {
             $event = $kronolith_driver->getEvent('_tasks' . $id);
             $end = clone $due;
             $end->hour = 23;
             $end->min = $end->sec = 59;
             $start = clone $due;
             $start->hour = $start->min = $start->sec = 0;
             $events = array();
             Kronolith::addEvents($events, $event, $start, $end, true, true);
             if (count($events)) {
                 $result->events = $events;
             }
         } catch (Horde_Exception_NotFound $e) {
         } catch (Exception $e) {
             $GLOBALS['notification']->push($e, 'horde.error');
         }
     }
     return $result;
 }
开发者ID:kossamums,项目名称:horde,代码行数:88,代码来源:Handler.php

示例2: readRecurrenceForm

 public static function readRecurrenceForm($start, $timezone, $recurrence = null)
 {
     $recur = Horde_Util::getFormData('recur');
     if (!strlen($recur)) {
         return $recurrence;
     }
     if (!isset($recurrence)) {
         $recurrence = new Horde_Date_Recurrence($start);
     } else {
         $recurrence->setRecurStart($start);
     }
     if (Horde_Util::getFormData('recur_end_type') == 'date') {
         if ($end_date = Horde_Util::getFormData('recur_end_date')) {
             // From ajax interface.
             $date_ob = Kronolith::parseDate($end_date, false);
             $recur_enddate = array('year' => $date_ob->year, 'month' => $date_ob->month, 'day' => $date_ob->mday);
         } else {
             // From traditional interface.
             $recur_enddate = Horde_Util::getFormData('recur_end');
         }
         if ($recurrence->hasRecurEnd()) {
             $recurEnd = $recurrence->recurEnd;
             $recurEnd->month = $recur_enddate['month'];
             $recurEnd->mday = $recur_enddate['day'];
             $recurEnd->year = $recur_enddate['year'];
         } else {
             $recurEnd = new Horde_Date(array('hour' => 23, 'min' => 59, 'sec' => 59, 'month' => $recur_enddate['month'], 'mday' => $recur_enddate['day'], 'year' => $recur_enddate['year']), $timezone);
         }
         $recurrence->setRecurEnd($recurEnd);
     } elseif (Horde_Util::getFormData('recur_end_type') == 'count') {
         $recurrence->setRecurCount(Horde_Util::getFormData('recur_count'));
     } elseif (Horde_Util::getFormData('recur_end_type') == 'none') {
         $recurrence->setRecurCount(0);
         $recurrence->setRecurEnd(null);
     }
     $recurrence->setRecurType($recur);
     switch ($recur) {
         case Horde_Date_Recurrence::RECUR_DAILY:
             $recurrence->setRecurInterval(Horde_Util::getFormData('recur_daily_interval', 1));
             break;
         case Horde_Date_Recurrence::RECUR_WEEKLY:
             $weekly = Horde_Util::getFormData('weekly');
             $weekdays = 0;
             if (is_array($weekly)) {
                 foreach ($weekly as $day) {
                     $weekdays |= $day;
                 }
             }
             if ($weekdays == 0) {
                 // Sunday starts at 0.
                 switch ($start->dayOfWeek()) {
                     case 0:
                         $weekdays |= Horde_Date::MASK_SUNDAY;
                         break;
                     case 1:
                         $weekdays |= Horde_Date::MASK_MONDAY;
                         break;
                     case 2:
                         $weekdays |= Horde_Date::MASK_TUESDAY;
                         break;
                     case 3:
                         $weekdays |= Horde_Date::MASK_WEDNESDAY;
                         break;
                     case 4:
                         $weekdays |= Horde_Date::MASK_THURSDAY;
                         break;
                     case 5:
                         $weekdays |= Horde_Date::MASK_FRIDAY;
                         break;
                     case 6:
                         $weekdays |= Horde_Date::MASK_SATURDAY;
                         break;
                 }
             }
             $recurrence->setRecurInterval(Horde_Util::getFormData('recur_weekly_interval', 1));
             $recurrence->setRecurOnDay($weekdays);
             break;
         case Horde_Date_Recurrence::RECUR_MONTHLY_DATE:
             switch (Horde_Util::getFormData('recur_monthly_scheme')) {
                 case Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY:
                     $recurrence->setRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY);
                 case Horde_Date_Recurrence::RECUR_MONTHLY_DATE:
                     $recurrence->setRecurInterval(Horde_Util::getFormData('recur_monthly') ? 1 : Horde_Util::getFormData('recur_monthly_interval', 1));
                     break;
                 default:
                     $recurrence->setRecurInterval(Horde_Util::getFormData('recur_day_of_month_interval', 1));
                     break;
             }
             break;
         case Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY:
             $recurrence->setRecurInterval(Horde_Util::getFormData('recur_week_of_month_interval', 1));
             break;
         case Horde_Date_Recurrence::RECUR_YEARLY_DATE:
             switch (Horde_Util::getFormData('recur_yearly_scheme')) {
                 case Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY:
                 case Horde_Date_Recurrence::RECUR_YEARLY_DAY:
                     $recurrence->setRecurType(Horde_Util::getFormData('recur_yearly_scheme'));
                 case Horde_Date_Recurrence::RECUR_YEARLY_DATE:
                     $recurrence->setRecurInterval(Horde_Util::getFormData('recur_yearly') ? 1 : Horde_Util::getFormData('recur_yearly_interval', 1));
                     break;
//.........这里部分代码省略.........
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:101,代码来源:Event.php


注:本文中的Kronolith::parseDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。