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


PHP Horde_Date::timestamp方法代码示例

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


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

示例1: getTile

 /**
  * Outputs the html for a DateGallery tile.
  *
  * @param Ansel_Gallery_Decorator_Date $dgallery  The Ansel_Gallery_Date we are
  *                                     displaying.
  * @param Ansel_Style $style  A style object.
  * @param boolean $mini       Force the use of a mini thumbail?
  * @param array $params       An array containing additional parameters.
  *                            Currently, gallery_view_url and image_view_url
  *                            are used to override the respective urls.
  *                            %g and %i are replaced with image id and
  *                            gallery id, respectively.
  *
  * @return string  The HTML for the tile.
  */
 public function getTile(Ansel_Gallery_Decorator_Date $dgallery, Ansel_Style $style = null, $mini = false, array $params = array())
 {
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addTemplatePath(ANSEL_TEMPLATES . '/tile');
     // User's preferred date format
     $date_format = $GLOBALS['prefs']->getValue('date_format');
     $date_array = $dgallery->getDate();
     if (empty($date_array['month'])) {
         $date_array['month'] = 1;
     }
     if (empty($date_array['day'])) {
         $date_array['day'] = 1;
     }
     $full_date = new Horde_Date($date_array);
     // Need the unaltered date part array
     $date_array = $dgallery->getDate();
     // Figure out the needed link for the next drill down level. We *must*
     // have at least a year since we are in a date tile.
     if (empty($date_array['month'])) {
         // unit == year
         $view->caption = $full_date->strftime('%Y');
         $next_date = array('year' => (int) $view->caption);
     } elseif (empty($date_array['day'])) {
         // unit == month
         $view->caption = $full_date->strftime('%B %Y');
         $next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()));
     } else {
         // unit == day
         $view->caption = $full_date->strftime($date_format);
         $next_date = array('year' => date('Y', $full_date->timestamp()), 'month' => date('n', $full_date->timestamp()), 'day' => date('j', $full_date->timestamp()));
     }
     // Check permissions on the gallery and get appropriate tile image
     if ($dgallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         if (is_null($style)) {
             $style = $dgallery->getStyle();
         }
         $thumbstyle = $mini ? 'mini' : 'thumb';
         $view->gallery_image = Ansel::getImageUrl($dgallery->getKeyImage(), $thumbstyle, true, $style);
     } else {
         $view->gallery_image = Horde_Themes::img('thumb-error.png');
     }
     /* Check for being called via the api and generate correct view links */
     if (!isset($params['gallery_view_url'])) {
         if (empty($params['style'])) {
             $gstyle = $dgallery->getStyle();
         } else {
             $gstyle = $params['style'];
         }
         $params = array('gallery' => $dgallery->id, 'view' => 'Gallery', 'slug' => $dgallery->get('slug'));
         $view->view_link = Ansel::getUrlFor('view', array_merge($params, $next_date));
     } else {
         $view->view_link = new Horde_Url(str_replace(array('%g', '%s'), array($dgallery->id, $dgallery->get('slug')), urldecode($params['gallery_view_url'])));
         $view->view_link->add($next_date);
     }
     $view->gallery_count = $dgallery->countImages(true);
     return $view->render('dategallery');
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:72,代码来源:DateGallery.php

示例2: relativeDateTime

 /**
  * Returns a relative, natural language representation of a timestamp
  *
  * @todo Wider range of values ... maybe future time as well?
  * @todo Support minimum resolution parameter.
  *
  * @param mixed $time          The time. Any format accepted by Horde_Date.
  * @param string $date_format  Format to display date if timestamp is
  *                             more then 1 day old.
  * @param string $time_format  Format to display time if timestamp is 1
  *                             day old.
  *
  * @return string  The relative time (i.e. 2 minutes ago)
  */
 public static function relativeDateTime($time, $date_format = '%x', $time_format = '%X')
 {
     $date = new Horde_Date($time);
     $delta = time() - $date->timestamp();
     if ($delta < 60) {
         return sprintf(Horde_Date_Translation::ngettext("%d second ago", "%d seconds ago", $delta), $delta);
     }
     $delta = round($delta / 60);
     if ($delta < 60) {
         return sprintf(Horde_Date_Translation::ngettext("%d minute ago", "%d minutes ago", $delta), $delta);
     }
     $delta = round($delta / 60);
     if ($delta < 24) {
         return sprintf(Horde_Date_Translation::ngettext("%d hour ago", "%d hours ago", $delta), $delta);
     }
     if ($delta > 24 && $delta < 48) {
         $date = new Horde_Date($time);
         return sprintf(Horde_Date_Translation::t("yesterday at %s"), $date->strftime($time_format));
     }
     $delta = round($delta / 24);
     if ($delta < 7) {
         return sprintf(Horde_Date_Translation::t("%d days ago"), $delta);
     }
     if (round($delta / 7) < 5) {
         $delta = round($delta / 7);
         return sprintf(Horde_Date_Translation::ngettext("%d week ago", "%d weeks ago", $delta), $delta);
     }
     // Default to the user specified date format.
     return $date->strftime($date_format);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:44,代码来源:Utils.php

示例3: testMethodListeventsHasResultArrayTheEventsInTheGivenTimeSpan

 public function testMethodListeventsHasResultArrayTheEventsInTheGivenTimeSpan()
 {
     $rec_start = new Horde_Date('2009-12-12 10:00:00');
     $rec_end = new Horde_Date('2009-12-12 14:00:00');
     $objects = array(array('uid' => 1, 'sensitivity' => 'public', 'start-date' => $rec_start->timestamp(), 'end-date' => $rec_end->timestamp(), 'recurrence' => array('interval' => 1, 'cycle' => 'daily', 'range-type' => 'none')));
     $resource = $this->_getData($objects);
     $start = new Horde_Date('2009-12-13 0:00:00');
     $end = new Horde_Date('2009-12-14 0:00:00');
     $result = $resource->listEvents($start, $end);
     $this->assertInstanceOf('Horde_Kolab_FreeBusy_Object_Event', $result[0]);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:11,代码来源:KolabTest.php

示例4: getInfo

 public function getInfo(&$vars, &$var, &$info)
 {
     $due_type = $vars->get('due_type');
     $due = $vars->get('due');
     if (is_array($due)) {
         $due_date = !empty($due['date']) ? $due['date'] : null;
         $due_time = !empty($due['time']) ? $due['time'] : null;
         $due_array = Nag::parseDate("{$due_date} {$due_time}");
         $due_dt = new Horde_Date($due_array);
         $due = $due_dt->timestamp();
     }
     $info = strcasecmp($due_type, 'none') ? $due : 0;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:13,代码来源:NagDue.php

示例5: getInfo

 public function getInfo(&$vars, &$var, &$info)
 {
     $start_type = $vars->get('start_date');
     $start = $vars->get('start');
     if (is_array($start)) {
         if (empty($start['date'])) {
             $start = null;
         } else {
             $start_array = Nag::parseDate($start['date'], false);
             $start_dt = new Horde_Date($start_array);
             $start = $start_dt->timestamp();
         }
     }
     $info = strcasecmp($start_type, 'none') ? $start : 0;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:15,代码来源:NagStart.php

示例6: _listObjects

 /**
  * Returns a list of events or tasks.
  *
  * @param integer $folder    A folder ID. If empty, returns objects of all
  *                           visible resources.
  * @param Horde_Date $start  Start date, defaults to epoch.
  * @param Horde_Date $end    End date, defaults to maximum date possible.
  *
  * @return array  List of object hashes.
  * @throws Horde_OpenXchange_Exception.
  */
 protected function _listObjects($folder = null, $start = null, $end = null)
 {
     $this->_login();
     $data = array('session' => $this->_session, 'columns' => implode(',', array_keys($this->_columns)), 'start' => $start ? $start->timestamp() * 1000 : 0, 'end' => $end ? $end->timestamp() * 1000 : PHP_INT_MAX, 'recurrence_master' => true);
     if ($folder) {
         $data['folder'] = $folder;
     }
     $response = $this->_request('GET', $this->_folderType, array('action' => 'all'), $data);
     $events = array();
     foreach ($response['data'] as $event) {
         $map = array();
         foreach (array_values($this->_columns) as $key => $column) {
             $map[$column] = $event[$key];
         }
         $events[] = $map;
     }
     return $events;
 }
开发者ID:horde,项目名称:horde,代码行数:29,代码来源:EventsAndTasks.php

示例7: getBusyTimes

 /**
  * Retrieve the busy times from this event within the given timeframe.  This
  * is trivial for non-recurring events but recurring events need to be
  * expanded.
  *
  * @param Horde_Date $startDate The start point.
  * @param Horde_Date $endDate   The end point.
  *
  * @return array The list of busy times (only the start times of the event).
  */
 public function getBusyTimes(Horde_Date $startDate, Horde_Date $endDate)
 {
     if (!$this->recurs()) {
         if ($startDate->compareDateTime($this->_start) > 0 || $endDate->compareDateTime($this->_start) < 0) {
             return array();
         }
         return array($this->_start->timestamp());
     } else {
         $result = array();
         $next = $this->_recurrence->nextRecurrence($startDate);
         while ($next) {
             if ($endDate->compareDateTime($next) < 0) {
                 break;
             }
             if (!$this->_recurrence->hasException($next->year, $next->month, $next->mday)) {
                 $result[] = $next->timestamp();
             }
             $next->mday++;
             $next = $this->_recurrence->nextRecurrence($next);
         }
         return $result;
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:33,代码来源:Event.php

示例8: listTimeObjects

 /**
  * Lists users with birthdays/goout dates as time objects.
  *
  * @param array $categories  The time categories (from listTimeObjectCategories) to list.
  * @param Horde_Date $start       The start date of the period.
  * @param Horde_Date $end         The end date of the period.
  */
 public function listTimeObjects($categories, $start, $end)
 {
     require_once __DIR__ . '/base.php';
     require_once FOLKS_BASE . '/lib/Friends.php';
     $friends_driver = Folks_Friends::singleton('sql');
     $friends = $friends_driver->getFriends();
     if ($friends instanceof PEAR_Error) {
         return array();
     }
     $objects = array();
     foreach ($friends as $friend) {
         $user = $GLOBALS['folks_driver']->getProfile($friend);
         if ($user instanceof PEAR_Error) {
             continue;
         }
         $user['user_birthday'] = date('Y') . substr($user['user_birthday'], 4);
         $born = strtotime($user['user_birthday']);
         if ($born === false || $born < $start->timestamp() || $born > $end->timestamp()) {
             continue;
         }
         $age = Folks::calcAge($user['user_birthday']);
         $desc = $age['age'] . ' (' . $age['sign'] . ')';
         $objects[$friend] = array('title' => $friend, 'description' => $desc, 'id' => $friend, 'start' => date('Y-m-d\\TH:i:s', $born), 'end' => date('Y-m-d\\TH:i:s', $born + 1), 'params' => array('user' => $friend), 'link' => Folks::getUrlFor('user', $friend, true));
     }
     return $objects;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:33,代码来源:Api.php

示例9: listTimeObjects

 /**
  * Lists active tasks as time objects.
  *
  * @param array $categories  The time categories (from
  *                           listTimeObjectCategories) to list.
  * @param mixed $start       The start date of the period.
  * @param mixed $end         The end date of the period.
  */
 public function listTimeObjects($categories, $start, $end)
 {
     $allowed_tasklists = Nag::listTasklists(false, Horde_Perms::READ);
     foreach ($categories as $tasklist) {
         if (!isset($allowed_tasklists[$tasklist])) {
             throw new Horde_Exception_PermissionDenied();
         }
     }
     $timeobjects = array();
     $start = new Horde_Date($start);
     $start_ts = $start->timestamp();
     $end = new Horde_Date($end);
     $end_ts = $end->timestamp();
     // List incomplete tasks.
     $tasks = Nag::listTasks(array('tasklists' => $categories, 'completed' => Nag::VIEW_INCOMPLETE, 'include_history' => false));
     $tasks->reset();
     while ($task = $tasks->each()) {
         // If there's no due date, it's not a time object.
         if (!$task->due || $task->due > $end_ts || !$task->recurs() && $task->due + 1 < $start_ts || $task->recurs() && $task->recurrence->getRecurEnd() && $task->recurrence->getRecurEnd()->timestamp() + 1 < $start_ts) {
             continue;
         }
         $due_date = date('Y-m-d\\TH:i:s', $task->due);
         $recurrence = null;
         if ($task->recurs()) {
             $recurrence = array('type' => $task->recurrence->getRecurType(), 'interval' => $task->recurrence->getRecurInterval(), 'end' => $task->recurrence->getRecurEnd(), 'count' => $task->recurrence->getRecurCount(), 'days' => $task->recurrence->getRecurOnDays(), 'exceptions' => $task->recurrence->getExceptions(), 'completions' => $task->recurrence->getCompletions());
         }
         $timeobjects[$task->id] = array('id' => $task->id, 'title' => $task->name, 'description' => $task->desc, 'start' => $due_date, 'end' => $due_date, 'recurrence' => $recurrence, 'color' => $allowed_tasklists[$task->tasklist]->get('color'), 'owner' => $allowed_tasklists[$task->tasklist]->get('owner'), 'permissions' => $GLOBALS['nag_shares']->getPermissions($task->tasklist, $GLOBALS['registry']->getAuth()), 'variable_length' => false, 'params' => array('task' => $task->id, 'tasklist' => $task->tasklist), 'link' => Horde::url('view.php', true)->add(array('tasklist' => $task->tasklist, 'task' => $task->id)), 'edit_link' => Horde::url('task.php', true)->add(array('tasklist' => $task->tasklist, 'task' => $task->id, 'actionID' => 'modify_task')), 'delete_link' => Horde::url('task.php', true)->add(array('tasklist' => $task->tasklist, 'task' => $task->id, 'actionID' => 'delete_task')), 'ajax_link' => 'task:' . $task->tasklist . ':' . $task->id);
     }
     return $timeobjects;
 }
开发者ID:Gomez,项目名称:horde,代码行数:38,代码来源:Api.php

示例10: foreach

$form = new Ansel_Form_ImageDate($vars, _("Edit Dates"));
/* Are we doing the edit now? */
if ($actionID == 'edit_dates') {
    $count = 0;
    foreach (array_keys($images) as $image_id) {
        try {
            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id);
            if (empty($gallery_id)) {
                // Images might be from different galleries
                $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
                if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                    continue;
                }
            }
            $newDate = new Horde_Date($vars->get('image_originalDate'));
            $image->originalDate = (int) $newDate->timestamp();
            $image->save();
            ++$count;
        } catch (Ansel_Exception $e) {
            $notification->push(sprintf(_("There was an error editing the dates: %s"), $e->getMessage()), 'horde.error');
            echo Horde::wrapInlineScript(array('window.opener.location.href = window.opener.location.href;', 'window.close();'));
            exit;
        }
    }
    $notification->push(sprintf(_("Successfully modified the date on %d photos."), $count), 'horde.success');
    echo Horde::wrapInlineScript(array('window.opener.location.href = window.opener.location.href;', 'window.close();'));
    exit;
}
$keys = array_keys($images);
$html = '';
foreach ($keys as $key) {
开发者ID:jubinpatel,项目名称:horde,代码行数:31,代码来源:edit_dates.php

示例11: _getMinimalInvitation

 private function _getMinimalInvitation()
 {
     $start = new Horde_Date('20080926T110000');
     $end = new Horde_Date('20080926T120000');
     $vCal = new Horde_Icalendar();
     $vCal->setAttribute('METHOD', 'REQUEST');
     $inv = Horde_Icalendar::newComponent('VEVENT', $vCal);
     $inv->setAttribute('UID', '1001');
     $inv->setAttribute('ORGANIZER', 'mailto:orga@example.org', array('cn' => 'Mr. Orga'));
     $inv->setAttribute('DTSTART', $start->timestamp());
     $inv->setAttribute('DTEND', $end->timestamp());
     return $inv;
 }
开发者ID:Gomez,项目名称:horde,代码行数:13,代码来源:ItipTest.php

示例12: foreach

     }
     $task = new Nag_Task($nag_storage);
     $task->fromiCalendar($row);
     $row = $task->toHash();
     foreach (array_keys($app_fields) as $field) {
         if (!isset($row[$field])) {
             $row[$field] = '';
         }
     }
 }
 $row['owner'] = $GLOBALS['registry']->getAuth();
 foreach (array('start', 'due', 'completed_date') as $field) {
     if (!empty($row[$field])) {
         try {
             $date = new Horde_Date($row[$field]);
             $row[$field] = $date->timestamp();
         } catch (Horde_Date_Exception $e) {
             unset($row[$field]);
         }
     } else {
         $row[$field] = 0;
     }
 }
 try {
     $nag_storage->add($row);
 } catch (Nag_Exception $e) {
     $haveError = true;
     $notification->push(sprintf(_("There was an error importing the data: %s"), $e->getMessage()), 'horde.error');
     break;
 }
 $num_tasks++;
开发者ID:horde,项目名称:horde,代码行数:31,代码来源:data.php

示例13: updateTime

 /**
  * Update a set of billing information.
  *
  * @param array $entries  The billing information to enter. Each array row
  *                        must contain the following entries:
  *              'id'           The id of this time entry.
  *              'date'         The day the hours were worked (ISO format)
  *              'client'       The id of the client the work was done for.
  *              'type'         The type of work done.
  *              'hours'        The number of hours worked
  *              'rate'         The hourly rate the work was done at.
  *              'billable'     Whether or not the work is billable hours.
  *              'description'  A short description of the work.
  *              'employee'     The employee
  *
  *                        If any rows contain a 'delete' entry, those rows
  *                        will be deleted instead of updated.
  *
  * @return integer  The number of successful updates.
  * @throws Horde_Exception_PermissionDenied
  * @throws Hermes_Exception
  */
 public function updateTime($entries)
 {
     foreach ($entries as $info) {
         if (!Hermes::canEditTimeslice($info['id'])) {
             throw new Horde_Exception_PermissionDenied(_("Access denied; user cannot modify this timeslice."));
         }
         if (!empty($info['delete'])) {
             try {
                 return $this->_db->delete('DELETE FROM hermes_timeslices WHERE timeslice_id = ?', array((int) $info['id']));
             } catch (Horde_Db_Exception $e) {
                 throw new Hermes_Exception($e);
             }
         } else {
             if (isset($info['employee'])) {
                 $employee_cl = ' ,employee_id = ?';
             } else {
                 $employee_cl = '';
             }
             $dt = new Horde_Date($info['date']);
             $sql = 'UPDATE hermes_timeslices SET' . ' clientjob_id = ?, jobtype_id = ?,' . ' timeslice_hours = ?, timeslice_isbillable = ?,' . ' timeslice_date = ?, timeslice_description = ?,' . ' timeslice_note = ?, costobject_id = ?' . $employee_cl . ' WHERE timeslice_id = ?';
             $values = array($info['client'], $info['type'], $info['hours'], isset($info['billable']) ? (int) $info['billable'] : 0, $dt->timestamp(), $this->_convertToDriver($info['description']), $this->_convertToDriver($info['note']), empty($info['costobject']) ? null : $info['costobject']);
             if (!empty($employee_cl)) {
                 $values[] = $info['employee'];
             }
             $values[] = (int) $info['id'];
             try {
                 return $this->_db->update($sql, $values);
             } catch (Horde_Db_Exception $e) {
                 throw new Hermes_Exception($e);
             }
         }
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:55,代码来源:Sql.php

示例14: _readSearchForm

 /**
  * Reads the search form submitted and return the search criteria
  *
  */
 protected function _readSearchForm()
 {
     $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
     $vars = $this->vars;
     $criteria = array();
     if ($GLOBALS['registry']->isAdmin(array('permission' => 'hermes:review'))) {
         if (!empty($vars->employees[0])) {
             $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
             if (!$auth->hasCapability('list')) {
                 $criteria['employee'] = explode(',', $vars->employees[0]);
                 if (empty($criteria['employee'])) {
                     unset($criteria['employee']);
                 }
             } else {
                 $criteria['employee'] = $vars->employees;
             }
         }
     } else {
         $criteria['employee'] = $GLOBALS['registry']->getAuth();
     }
     if (!empty($vars->client)) {
         $criteria['client'] = $vars->client;
     }
     if (!empty($vars->type)) {
         $criteria['jobtype'] = $vars->type;
     }
     if (!empty($vars->costobject)) {
         $criteria['costobject'] = $vars->costobject;
     }
     if (!empty($vars->after_date)) {
         $dt = new Horde_Date($vars->after_date);
         $criteria['start'] = $dt->timestamp();
     }
     if (!empty($vars->before_date)) {
         $dt = new Horde_Date($vars->before_date);
         $criteria['end'] = $dt->add(86400)->timestamp();
     }
     if ($vars->billable !== '') {
         $criteria['billable'] = $vars->billable;
     }
     if ($vars->submitted !== '') {
         $criteria['submitted'] = $vars->submitted;
     }
     if ($vars->exported !== '') {
         $criteria['exported'] = $vars->exported;
     }
     return $criteria;
 }
开发者ID:kossamums,项目名称:horde,代码行数:52,代码来源:Handler.php

示例15: testRecurringTasks

 public function testRecurringTasks()
 {
     $due = time() - 1;
     $recurrence = new Horde_Date_Recurrence($due);
     $recurrence->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
     $id = $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.', 'due' => $due, 'recurrence' => $recurrence));
     $due = new Horde_Date($due);
     $result = self::$driver->get($id[0]);
     $next = $result->getNextDue();
     $this->assertInstanceOf('Horde_Date', $next);
     $this->assertEquals($due->timestamp(), $next->timestamp());
     $result->toggleComplete();
     $result->save();
     $result2 = self::$driver->get($id[0]);
     $due->mday++;
     $next = $result2->getNextDue();
     $this->assertInstanceOf('Horde_Date', $next);
     $this->assertEquals($due->timestamp(), $next->timestamp());
     $result2->toggleComplete();
     $result2->save();
     $result3 = self::$driver->get($id[0]);
     $due->mday++;
     $next = $result3->getNextDue();
     $this->assertInstanceOf('Horde_Date', $next);
     $this->assertEquals($due->timestamp(), $next->timestamp());
     $this->assertFalse($result3->recurrence->hasCompletion($due->year, $due->month, $due->mday));
     $due->mday--;
     $this->assertTrue($result3->recurrence->hasCompletion($due->year, $due->month, $due->mday));
     $due->mday--;
     $this->assertTrue($result3->recurrence->hasCompletion($due->year, $due->month, $due->mday));
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:31,代码来源:Base.php


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