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


PHP DateTimeValue::getTimestamp方法代码示例

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


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

示例1: smarty_modifier_ago

/**
 * Return '*** ago' message
 *
 * @param DateTimeValue $input
 * @param integer $offset
 * @return string
 */
function smarty_modifier_ago($input, $offset = null)
{
    if (!instance_of($input, 'DateValue')) {
        return '<span class="ago">' . lang('-- Unknown --') . '</span>';
    }
    // if
    if ($offset === null) {
        $offset = get_user_gmt_offset();
    }
    // if
    $datetime = new DateTimeValue($input->getTimestamp() + $offset);
    $reference = new DateTimeValue(time() + $offset);
    $diff = $reference->getTimestamp() - $datetime->getTimestamp();
    // Get exact number of seconds between current time and yesterday morning
    $reference_timestamp = $reference->getTimestamp();
    $yesterday_begins_at = 86400 + date('G', $reference_timestamp) * 3600 + date('i', $reference_timestamp) * 60 + date('s', $reference_timestamp);
    if ($diff < 60) {
        $value = lang('Few seconds ago');
    } elseif ($diff < 120) {
        $value = lang('A minute ago');
    } elseif ($diff < 3600) {
        $value = lang(':num minutes ago', array('num' => floor($diff / 60)));
    } elseif ($diff < 7200) {
        $value = lang('An hour ago');
    } elseif ($diff < 86400) {
        if (date('j', $datetime->getTimestamp()) != date('j', $reference->getTimestamp())) {
            $value = lang('Yesterday');
        } else {
            $mod = $diff % 3600;
            if ($mod < 900) {
                $value = lang(':num hours ago', array('num' => floor($diff / 3600)));
            } elseif ($mod > 2700) {
                $value = lang(':num hours ago', array('num' => ceil($diff / 3600)));
            } else {
                $value = lang(':num and a half hours ago', array('num' => floor($diff / 3600)));
            }
            // if
        }
        // if
    } elseif ($diff <= $yesterday_begins_at) {
        $value = lang('Yesterday');
    } elseif ($diff < 2592000) {
        $value = lang(':num days ago', array('num' => floor($diff / 86400)));
    } else {
        require_once SMARTY_PATH . '/plugins/modifier.date.php';
        require_once SMARTY_PATH . '/plugins/modifier.datetime.php';
        return '<span class="ago" title="' . clean(smarty_modifier_datetime($datetime, 0)) . '">' . lang('On') . ' ' . smarty_modifier_date($datetime, 0) . '</span>';
    }
    // if
    require_once SMARTY_PATH . '/plugins/modifier.datetime.php';
    return '<span class="ago" title="' . clean(smarty_modifier_datetime($datetime, 0)) . '">' . $value . '</span>';
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:59,代码来源:modifier.ago.php

示例2: smarty_function_select_datetime_format

/**
 * Render select datetime format widget
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_datetime_format($params, &$smarty)
{
    $e = DIRECTORY_SEPARATOR == '\\' ? '%d' : '%e';
    // Windows does not support %e
    $presets = array('date' => array("%b {$e}. %Y", "%a, %b {$e}. %Y", "{$e} %b %Y", "%Y/%m/{$e}", "%m/{$e}/%Y"), 'time' => array('%I:%M %p', '%H:%M'));
    $mode = 'date';
    if (array_key_exists('mode', $params)) {
        $mode = $params['mode'];
        unset($params['mode']);
    }
    // if
    $value = null;
    if (array_key_exists('value', $params)) {
        $value = $params['value'];
        unset($params['value']);
    }
    // if
    $optional = false;
    if (array_key_exists('optional', $params)) {
        $optional = (bool) $params['optional'];
        unset($params['optional']);
    }
    // if
    $reference_time = new DateTimeValue('2007-11-21 20:45:15');
    $options = array();
    if ($optional) {
        $default_format = ConfigOptions::getValue("format_{$mode}");
        $default_value = strftime($default_format, $reference_time->getTimestamp());
        $options[] = option_tag(lang('-- System Default (:value) --', array('value' => $default_value)), '');
        $options[] = option_tag('', '');
    }
    // if
    foreach ($presets[$mode] as $v) {
        $option_attributes = $v === $value ? array('selected' => true) : null;
        $options[] = option_tag(strftime($v, $reference_time->getTimestamp()), $v, $option_attributes);
    }
    // foreach
    return select_box($options, $params);
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:46,代码来源:function.select_datetime_format.php

示例3: getRecentActivity

 /**
  * Get recent activity for a repository
  *
  * @param Repository $repository
  * @param int $from_days_before
  * @return array
  */
 function getRecentActivity($repository, $from_days_before = 15)
 {
     $from = new DateTimeValue($from_days_before - 1 . ' days ago');
     $last_commit = $repository->getLastcommit();
     $beginning_of_day = $from->beginningOfDay();
     $max_commits = Commits::count(array("parent_id = ? AND created_on >= ? GROUP BY DAY(created_on) ORDER BY row_count DESC LIMIT 1", $repository->getId(), $beginning_of_day));
     $from_days_before--;
     for ($i = $from_days_before; $i >= 0; $i--) {
         $date = new DateTimeValue($i . 'days ago');
         $this_date_beginning = $date->beginningOfDay();
         $this_date_end = $date->endOfDay();
         $commits_count = Commits::count(array("parent_id = ? AND created_on >= ? AND created_on <= ?", $repository->getId(), $this_date_beginning, $this_date_end));
         $activity[$i]['commits'] = $commits_count;
         $activity[$i]['created_on'] = date('F d, Y', $date->getTimestamp());
         $activity[$i]['percentage'] = round($commits_count * 100 / $max_commits);
     }
     return $activity;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:25,代码来源:Commits.class.php

示例4: edit

 /**
  * Edit timeslot
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->setTemplate('add_timeslot');
     $timeslot = Timeslots::findById(get_id());
     if (!$timeslot instanceof Timeslot) {
         flash_error(lang('timeslot dnx'));
         ajx_current("empty");
         return;
     }
     $object = $timeslot->getRelObject();
     if (!$object instanceof ContentDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     if (!$object->canAddTimeslot(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     if (!$timeslot->canEdit(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $timeslot_data = array_var($_POST, 'timeslot');
     if (!is_array($timeslot_data)) {
         $timeslot_data = array('contact_id' => $timeslot->getContactId(), 'description' => $timeslot->getDescription(), 'start_time' => $timeslot->getStartTime(), 'end_time' => $timeslot->getEndTime(), 'is_fixed_billing' => $timeslot->getIsFixedBilling(), 'hourly_billing' => $timeslot->getHourlyBilling(), 'fixed_billing' => $timeslot->getFixedBilling());
     }
     tpl_assign('timeslot_form_object', $object);
     tpl_assign('timeslot', $timeslot);
     tpl_assign('timeslot_data', $timeslot_data);
     tpl_assign('show_billing', BillingCategories::count() > 0);
     if (is_array(array_var($_POST, 'timeslot'))) {
         try {
             $this->percent_complete_delete($timeslot);
             $timeslot->setContactId(array_var($timeslot_data, 'contact_id', logged_user()->getId()));
             $timeslot->setDescription(array_var($timeslot_data, 'description'));
             $st = getDateValue(array_var($timeslot_data, 'start_value'), DateTimeValueLib::now());
             $st->setHour(array_var($timeslot_data, 'start_hour'));
             $st->setMinute(array_var($timeslot_data, 'start_minute'));
             $et = getDateValue(array_var($timeslot_data, 'end_value'), DateTimeValueLib::now());
             $et->setHour(array_var($timeslot_data, 'end_hour'));
             $et->setMinute(array_var($timeslot_data, 'end_minute'));
             $st = new DateTimeValue($st->getTimestamp() - logged_user()->getTimezone() * 3600);
             $et = new DateTimeValue($et->getTimestamp() - logged_user()->getTimezone() * 3600);
             $timeslot->setStartTime($st);
             $timeslot->setEndTime($et);
             if ($timeslot->getStartTime() > $timeslot->getEndTime()) {
                 flash_error(lang('error start time after end time'));
                 ajx_current("empty");
                 return;
             }
             $seconds = array_var($timeslot_data, 'subtract_seconds', 0);
             $minutes = array_var($timeslot_data, 'subtract_minutes', 0);
             $hours = array_var($timeslot_data, 'subtract_hours', 0);
             $subtract = $seconds + 60 * $minutes + 3600 * $hours;
             if ($subtract < 0) {
                 flash_error(lang('pause time cannot be negative'));
                 ajx_current("empty");
                 return;
             }
             $testEndTime = new DateTimeValue($timeslot->getEndTime()->getTimestamp());
             $testEndTime->add('s', -$subtract);
             if ($timeslot->getStartTime() > $testEndTime) {
                 flash_error(lang('pause time cannot exceed timeslot time'));
                 ajx_current("empty");
                 return;
             }
             $timeslot->setSubtract($subtract);
             if ($timeslot->getUser()->getDefaultBillingId()) {
                 $timeslot->setIsFixedBilling(array_var($timeslot_data, 'is_fixed_billing', false));
                 $timeslot->setHourlyBilling(array_var($timeslot_data, 'hourly_billing', 0));
                 if ($timeslot->getIsFixedBilling()) {
                     $timeslot->setFixedBilling(array_var($timeslot_data, 'fixed_billing', 0));
                 } else {
                     $timeslot->setFixedBilling($timeslot->getHourlyBilling() * $timeslot->getMinutes() / 60);
                 }
                 if ($timeslot->getBillingId() == 0 && ($timeslot->getHourlyBilling() > 0 || $timeslot->getFixedBilling() > 0)) {
                     $timeslot->setBillingId($timeslot->getUser()->getDefaultBillingId());
                 }
             }
             DB::beginWork();
             $timeslot->save();
             $timeslot_time = ($timeslot->getEndTime()->getTimestamp() - ($timeslot->getStartTime()->getTimestamp() + $timeslot->getSubtract())) / 3600;
             $task = ProjectTasks::findById($timeslot->getRelObjectId());
             if ($task->getTimeEstimate() > 0) {
                 $timeslot_percent = round($timeslot_time * 100 / ($task->getTimeEstimate() / 60));
                 $total_percentComplete = $timeslot_percent + $task->getPercentCompleted();
                 if ($total_percentComplete < 0) {
                     $total_percentComplete = 0;
                 }
                 $task->setPercentCompleted($total_percentComplete);
                 $task->save();
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:TimeslotController.class.php

示例5: FormatTimeDiff

	static function FormatTimeDiff(DateTimeValue $dt1, DateTimeValue $dt2=null, $format='yfwdhms', $modulus = 1, $subtract = 0){
		$t1 = $dt1->getTimestamp();
		if ($dt2)
			$t2 = $dt2->getTimestamp();
		else
			$t2 = time();
		$s = abs($t2 - $t1);
		$s -= $subtract;
		$s = $s - ($s % $modulus);
		$sign = $t2 > $t1 ? 1 : -1;
		$out = array();
		$left = $s;
		$format = array_unique(str_split(preg_replace('`[^yfwdhms]`', '', strtolower($format))));
		$format_count = count($format);
		$a = array('y'=>31556926, 'f'=>2629744, 'w'=>604800, 'd'=>86400, 'h'=>3600, 'm'=>60, 's'=>1);
		$i = 0;
		foreach($a as $k=>$v){
			if(in_array($k, $format)){
				++$i;
				if($i != $format_count){
					$out[$k] = $sign * (int)($left / $v);
					$left = $left % $v;
				}else{
					$out[$k] = $sign * ($left / $v);
				}
			}else{
				$out[$k] = 0;
			}
		}
		$result = '';
		if ($out['y'] > 0)
			$result .= ($result != ''? ', ':'') . ($out['y'] > 1 ? lang("x years", $out['y']) : lang("1 year"));
		if ($out['f'] > 0)
			$result .= ($result != ''? ', ':'') . ($out['f'] > 1 ? lang("x months", $out['f']) : lang("1 month"));
		if ($out['w'] > 0)
			$result .= ($result != ''? ', ':'') . ($out['w'] > 1 ? lang("x weeks", $out['w']) : lang("1 week"));
		if ($out['d'] > 0)
			$result .= ($result != ''? ', ':'') . ($out['d'] > 1 ? lang("x days", $out['d']) : lang("1 day"));
		if ($out['h'] > 0)
			$result .= ($result != ''? ', ':'') . ($out['h'] > 1 ? lang("x hours", $out['h']) : lang("1 hour"));
		if ($out['m'] > 0)
			$result .= ($result != ''? ', ':'') . ($out['m'] > 1 ? lang("x minutes", $out['m']) : lang("1 minute"));
		if ($out['s'] > 0)
			$result .= ($result != ''? ', ':'') . ($out['s'] > 1 ? lang("x seconds", $out['s']) : lang("1 second"));
			
		if ($result == '')
			$result = '< ' . lang("1 minute");
		return $result;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:49,代码来源:DateTimeValue.class.php

示例6: formatTime

 /**
  * Return formated time
  *
  * @access public
  * @param DateTimeValue $date
  * @param float $timezone Timezone offset in hours
  * @return string
  */
 function formatTime(DateTimeValue $date, $timezone = 0)
 {
     $lang_time_format = $this->langs->get('time format', null);
     $time_format = $lang_time_format ? $lang_time_format : $this->time_format;
     return $this->date_lang($time_format, $date->getTimestamp() + $timezone * 3600);
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:14,代码来源:Localization.class.php

示例7: DateTimeValue

            ?>
 
		  </td>
		  <?php 
        }
        ?>
		
		  
		  <?php 
        if (array_var($draw_options, 'show_end_dates')) {
            ?>
		  <td class="task-date-container">
		    <?php 
            if (array_var($task, 'dueDate')) {
                $date = new DateTimeValue(array_var($task, 'dueDate'));
                $due_date_late = $date->getTimestamp() < DateTimeValueLib::now()->getTimestamp();
                ?>
		     <?php 
                if ($due_date_late) {
                    ?>
		     <span class="nobr" style='font-size: 9px;font-weight:bold;color: #F00;'><?php 
                    echo format_datetime($date, null, 0);
                    ?>
</span>  
		     <?php 
                } else {
                    ?>
		     <span class="nobr" style='font-size: 9px;color: #888;'><?php 
                    echo format_datetime($date, null, 0);
                    ?>
</span>
开发者ID:abhinay100,项目名称:feng_app,代码行数:31,代码来源:print_tasks_list.php

示例8: getRangeMilestones

 /**
  * Return Day milestones
  *
  * @access public
  * @param DateTimeValue $date_start in user gmt
  * @param DateTimeValue $date_end	in user gmt	 * 
  */
 function getRangeMilestones(DateTimeValue $date_start, DateTimeValue $date_end, $archived = false)
 {
     $from_date = new DateTimeValue($date_start->getTimestamp());
     $from_date = $from_date->beginningOfDay();
     $to_date = new DateTimeValue($date_end->getTimestamp());
     $to_date = $to_date->endOfDay();
     //set dates to gmt 0 for sql
     $from_date->advance(-logged_user()->getTimezone() * 3600);
     $to_date->advance(-logged_user()->getTimezone() * 3600);
     $archived_cond = " AND `archived_on` " . ($archived ? "<>" : "=") . " 0";
     $conditions = DB::prepareString(' AND `is_template` = false AND `completed_on` = ? AND (`due_date` >= ? AND `due_date` < ?) ' . $archived_cond, array(EMPTY_DATETIME, $from_date, $to_date));
     $result = self::instance()->listing(array("extra_conditions" => $conditions));
     return $result->objects;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:21,代码来源:ProjectMilestones.class.php

示例9: difference

 /**
  * Difference to another DateTime
  *
  * @param void
  * @param integer $input 
  * @return integer $seconds
  */
 function difference(DateTimeValue $input)
 {
     return $this->getTimestamp() - $input->getTimestamp();
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:11,代码来源:DateTimeValue.class.php

示例10: foreach

 function cron_events()
 {
     if (!can_manage_configuration(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $events = CronEvents::getUserEvents();
     tpl_assign("events", $events);
     $cron_events = array_var($_POST, 'cron_events');
     if (is_array($cron_events)) {
         try {
             DB::beginWork();
             foreach ($cron_events as $id => $data) {
                 $event = CronEvents::findById($id);
                 $date = getDateValue($data['date']);
                 if ($date instanceof DateTimeValue) {
                     $this->parseTime($data['time'], $hour, $minute);
                     $date->add("m", $minute);
                     $date->add("h", $hour);
                     $date = new DateTimeValue($date->getTimestamp() - logged_user()->getTimezone() * 3600);
                     $event->setDate($date);
                 }
                 $delay = $data['delay'];
                 if (is_numeric($delay)) {
                     $event->setDelay($delay);
                 }
                 $enabled = array_var($data, 'enabled') == 'checked';
                 $event->setEnabled($enabled);
                 $event->save();
             }
             DB::commit();
             flash_success(lang("success update cron events"));
             ajx_current("back");
         } catch (Exception $ex) {
             DB::rollback();
             flash_error($ex->getMessage());
         }
     }
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:41,代码来源:AdministrationController.class.php

示例11: getDateValue

 function total_task_times_vs_estimate_comparison($report_data = null, $task = null)
 {
     $this->setTemplate('report_wrapper');
     if (!$report_data) {
         $report_data = array_var($_POST, 'report');
     }
     $workspace = Projects::findById(array_var($report_data, 'project_id'));
     if ($workspace instanceof Project) {
         if (array_var($report_data, 'include_subworkspaces')) {
             $workspacesCSV = $workspace->getAllSubWorkspacesQuery(false);
         } else {
             $workspacesCSV = $workspace->getId();
         }
     } else {
         $workspacesCSV = null;
     }
     $start = getDateValue(array_var($report_data, 'start_value'));
     $end = getDateValue(array_var($report_data, 'end_value'));
     $st = $start->beginningOfDay();
     $et = $end->endOfDay();
     $st = new DateTimeValue($st->getTimestamp() - logged_user()->getTimezone() * 3600);
     $et = new DateTimeValue($et->getTimestamp() - logged_user()->getTimezone() * 3600);
     $timeslots = Timeslots::getTimeslotsByUserWorkspacesAndDate($st, $et, 'ProjectTasks', null, $workspacesCSV, array_var($report_data, 'task_id', 0));
     tpl_assign('timeslots', $timeslots);
     tpl_assign('workspace', $workspace);
     tpl_assign('start_time', $st);
     tpl_assign('end_time', $et);
     tpl_assign('user', $user);
     tpl_assign('post', $report_data);
     tpl_assign('template_name', 'total_task_times');
     tpl_assign('title', lang('task time report'));
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:32,代码来源:ReportingController.class.php

示例12: getRangeContactsByBirthday

 function getRangeContactsByBirthday($from, $to, $tags = '', $project = null)
 {
     if (!$from instanceof DateTimeValue || !$to instanceof DateTimeValue || $from->getTimestamp() > $to->getTimestamp()) {
         return array();
     }
     $from = new DateTimeValue($from->getTimestamp());
     $from->beginningOfDay();
     $to = new DateTimeValue($to->getTimestamp());
     $to->endOfDay();
     $year1 = $from->getYear();
     $year2 = $to->getYear();
     if ($year1 == $year2) {
         $condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' AND DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
     } else {
         if ($year2 - $year1 == 1) {
             $condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' OR DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
         } else {
             $condition = "`birthday` <> '0000-00-00 00:00:00'";
         }
     }
     return $this->getAllowedContacts($condition);
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:22,代码来源:Contacts.class.php

示例13: instantiate


//.........这里部分代码省略.........
                 $manager = $copy->manager();
             }
         }
         // copy custom properties
         $copy->copyCustomPropertiesFrom($object);
         // set property values as defined in template
         $objProp = TemplateObjectProperties::getPropertiesByTemplateObject($id, $object->getId());
         foreach ($objProp as $property) {
             $propName = $property->getProperty();
             $value = $property->getValue();
             if ($manager->getColumnType($propName) == DATA_TYPE_STRING || $manager->getColumnType($propName) == DATA_TYPE_INTEGER) {
                 if (is_array($parameterValues)) {
                     foreach ($parameterValues as $param => $val) {
                         if (strpos($value, '{' . $param . '}') !== FALSE) {
                             $value = str_replace('{' . $param . '}', $val, $value);
                         }
                     }
                 }
             } else {
                 if ($manager->getColumnType($propName) == DATA_TYPE_DATE || $manager->getColumnType($propName) == DATA_TYPE_DATETIME) {
                     $operator = '+';
                     if (strpos($value, '+') === false) {
                         $operator = '-';
                     }
                     $opPos = strpos($value, $operator);
                     if ($opPos !== false) {
                         // Is parametric
                         $dateParam = substr($value, 1, strpos($value, '}') - 1);
                         $date = $parameterValues[$dateParam];
                         $dateUnit = substr($value, strlen($value) - 1);
                         // d, w or m (for days, weeks or months)
                         if ($dateUnit == 'm') {
                             $dateUnit = 'M';
                             // make month unit uppercase to call DateTimeValue::add with correct parameter
                         }
                         $dateNum = (int) substr($value, strpos($value, $operator), strlen($value) - 2);
                         $date = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $date);
                         $date = new DateTimeValue($date->getTimestamp() - logged_user()->getTimezone() * 3600);
                         // set date to GMT 0
                         $value = $date->add($dateUnit, $dateNum);
                     } else {
                         $value = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $value);
                     }
                 }
             }
             if ($value != '') {
                 if (!$copy->setColumnValue($propName, $value)) {
                     $copy->object->setColumnValue($propName, $value);
                 }
                 $copy->save();
             }
         }
         // subscribe assigned to
         if ($copy instanceof ProjectTask) {
             foreach ($copy->getOpenSubTasks(false) as $m_task) {
                 if ($m_task->getAssignedTo() instanceof Contact) {
                     $m_task->subscribeUser($copy->getAssignedTo());
                 }
             }
             if ($copy->getAssignedTo() instanceof Contact) {
                 $copy->subscribeUser($copy->getAssignedTo());
             }
         } else {
             if ($copy instanceof ProjectMilestone) {
                 foreach ($copy->getTasks(false) as $m_task) {
                     if ($m_task->getAssignedTo() instanceof Contact) {
                         $m_task->subscribeUser($copy->getAssignedTo());
                     }
                 }
             }
         }
         // copy reminders
         $reminders = ObjectReminders::getByObject($object);
         foreach ($reminders as $reminder) {
             $copy_reminder = new ObjectReminder();
             $copy_reminder->setContext($reminder->getContext());
             $reminder_date = $copy->getColumnValue($reminder->getContext());
             if ($reminder_date instanceof DateTimeValue) {
                 $reminder_date = new DateTimeValue($reminder_date->getTimestamp());
                 $reminder_date->add('m', -$reminder->getMinutesBefore());
             }
             $copy_reminder->setDate($reminder_date);
             $copy_reminder->setMinutesBefore($reminder->getMinutesBefore());
             $copy_reminder->setObject($copy);
             $copy_reminder->setType($reminder->getType());
             $copy_reminder->setUserId($reminder->getUserId());
             $copy_reminder->save();
         }
     }
     DB::commit();
     if (is_array($parameters) && count($parameters) > 0) {
         ajx_current("back");
     } else {
         if (!$choose_ctx) {
             ajx_current("back");
         } else {
             ajx_current("reload");
         }
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:TemplateController.class.php

示例14: mktime

 function move_event()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $event = ProjectEvents::findById(get_id());
     if (!$event->canEdit(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $is_read = $event->getIsRead(logged_user()->getId());
     $year = array_var($_GET, 'year', $event->getStart()->getYear());
     $month = array_var($_GET, 'month', $event->getStart()->getMonth());
     $day = array_var($_GET, 'day', $event->getStart()->getDay());
     $hour = array_var($_GET, 'hour', 0);
     $min = array_var($_GET, 'min', 0);
     if ($hour == -1) {
         $hour = format_date($event->getStart(), 'H', logged_user()->getTimezone());
     }
     if ($min == -1) {
         $min = format_date($event->getStart(), 'i', logged_user()->getTimezone());
     }
     if ($event->isRepetitive()) {
         $orig_date = DateTimeValueLib::dateFromFormatAndString('Y-m-d H:i:s', array_var($_GET, 'orig_date'));
         $diff = DateTimeValueLib::get_time_difference($orig_date->getTimestamp(), mktime($hour, $min, 0, $month, $day, $year));
         $new_start = new DateTimeValue($event->getStart()->getTimestamp());
         $new_start->add('d', $diff['days']);
         $new_start->add('h', $diff['hours']);
         $new_start->add('m', $diff['minutes']);
         if ($event->getRepeatH()) {
             $event->setRepeatDow(date("w", mktime($hour, $min, 0, $month, $day, $year)) + 1);
             $wnum = 0;
             $tmp_day = $new_start->getDay();
             while ($tmp_day > 0) {
                 $tmp_day -= 7;
                 $wnum++;
             }
             $event->setRepeatWnum($wnum);
         }
     } else {
         $new_start = new DateTimeValue(mktime($hour, $min, 0, $month, $day, $year) - logged_user()->getTimezone() * 3600);
     }
     $diff = DateTimeValueLib::get_time_difference($event->getStart()->getTimestamp(), $event->getDuration()->getTimestamp());
     $new_duration = new DateTimeValue($new_start->getTimestamp());
     $new_duration->add('d', $diff['days']);
     $new_duration->add('h', $diff['hours']);
     $new_duration->add('m', $diff['minutes']);
     // see if we have to reload
     $os = format_date($event->getStart(), 'd', logged_user()->getTimezone());
     $od = format_date($event->getDuration(), 'd', logged_user()->getTimezone());
     $ohm = format_date($event->getDuration(), 'H:i', logged_user()->getTimezone());
     $nd = format_date($new_duration, 'd', logged_user()->getTimezone());
     $nhm = format_date($new_duration, 'H:i', logged_user()->getTimezone());
     $different_days = $os != $od && $ohm != '00:00' || $day != $nd && $nhm != '00:00';
     DB::beginWork();
     $event->setStart($new_start->format("Y-m-d H:i:s"));
     $event->setDuration($new_duration->format("Y-m-d H:i:s"));
     $event->save();
     if (!$is_read) {
         $event->setIsRead(logged_user()->getId(), false);
     }
     DB::commit();
     ajx_extra_data($this->get_updated_event_data($event));
     if ($different_days || $event->isRepetitive()) {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:72,代码来源:EventController.class.php

示例15: formatTime

 /**
  * Return fromated time
  *
  * @access public
  * @param DateTimeValue $date
  * @param float $timezone Timezone offset in hours
  * @return string
  */
 function formatTime(DateTimeValue $date, $timezone = 0)
 {
     return date($this->time_format, $date->getTimestamp() + $timezone * 3600);
 }
开发者ID:ukd1,项目名称:Project-Pier,代码行数:12,代码来源:Localization.class.php


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