本文整理汇总了PHP中DateTimeValue类的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValue类的具体用法?PHP DateTimeValue怎么用?PHP DateTimeValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateTimeValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExecuteQuery
function ExecuteQuery()
{
$this->data = array();
$parameters = $this->getParameters();
$this->acum = 0;
$this->acumExec = 0;
foreach ($parameters as $p) {
$value = $p->getValue();
$id = $p->getId();
$series = 0;
if ($id > 1000) {
$series = 1;
$id = $id % 1000;
$this->acum += (int) $value;
} else {
$this->acumExec += (int) $value;
}
$date = new DateTimeValue(mktime(12, 0, 0, $id, 1, 2008));
$this->data['values'][$series]['labels'][] = $date->format("F");
$this->data['values'][$series]['values'][] = (int) $value;
}
// foreach
$this->data['values'][0]['name'] = lang('executed');
$this->data['values'][1]['name'] = lang('budgeted');
}
示例2: smarty_function_reminder
/**
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_reminder($params, &$smarty)
{
$object = array_var($params, 'object');
$reminder_date = null;
if (instance_of($object, 'ProjectObject')) {
if ($object->isCompleted()) {
return '';
}
// if
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME, $link);
$query = "select reminder_date from healingcrystals_project_object_misc where object_id='" . $object->getId() . "'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
if (!empty($info['reminder_date'])) {
$reminder_date = DateTimeValue::makeFromString($info['reminder_date']);
}
}
mysql_close($link);
} else {
return new InvalidParamError('object', $object, '$object is not expected to be an instance of ProjectObject', true);
}
// if
$offset = get_user_gmt_offset();
if (instance_of($reminder_date, 'DateTimeValue')) {
require_once SMARTY_PATH . '/plugins/modifier.datetime.php';
$date = smarty_modifier_datetime($reminder_date, 0);
// just printing date, offset is 0!
if ($reminder_date->isToday($offset)) {
return '<span class="today"><span class="number">Reminder set for: ' . lang('Today') . ' ' . date('h:i A', $reminder_date->getTimestamp()) . '</span></span>';
} elseif ($reminder_date->isYesterday($offset)) {
return '<span class="late" title="' . clean($date) . '">Reminder set for: ' . lang('<span class="number">Yesterday ' . date('h:i A', $reminder_date->getTimestamp()) . '</span>') . '</span>';
} elseif ($reminder_date->isTomorrow($offset)) {
return '<span class="upcoming" title="' . clean($date) . '">Reminder set for: <span class="number">' . lang('Tomorrow') . ' ' . date('h:i A', $reminder_date->getTimestamp()) . '</span></span>';
} else {
$now = new DateTimeValue();
$now->advance($offset);
$now = $now->beginningOfDay();
$reminder_date->beginningOfDay();
if ($reminder_date->getTimestamp() > $now->getTimestamp()) {
return '<span class="upcoming" title="' . clean($date) . '">Reminder set for: ' . date('F d, Y h:i A', $reminder_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days)', array('days' => floor(($reminder_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
} else {
return '<span class="late" title="' . clean($date) . '">Reminder set for: ' . date('F d, Y h:i A', $reminder_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days Late)', array('days' => floor(($now->getTimestamp() - $reminder_date->getTimestamp()) / 86400))) . '</span>';
}
// if
}
// if
} else {
return '';
}
// if
}
示例3: 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>';
}
示例4: cvs_total_task_times_table
function cvs_total_task_times_table($objects, $pad_str, $options, $group_name, &$sub_total = 0) {
echo lang('date') . ';';
echo lang('title') . ';';
echo lang('description') . ';';
echo lang('person') . ';';
echo lang('time') .'('.lang('hours').')'. ';';
echo "\n";
$sub_total = 0;
foreach ($objects as $ts) {
echo $pad_str . format_date($ts->getStartTime()) . ';';
$name = ($ts->getRelObjectId() == 0 ? $ts->getObjectName() : $ts->getRelObject()->getObjectName());
$name = str_replace("\r", " ", str_replace("\n", " ", str_replace("\r\n", " ", $name)));
echo $name . ';';
$desc = $ts->getDescription();
$desc = str_replace("\r", " ", str_replace("\n", " ", str_replace("\r\n", " ", $desc)));
$desc = '"'.$desc.'"';
echo $desc .';';
echo ($ts->getUser() instanceof Contact ? $ts->getUser()->getObjectName() : '') .';';
$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
$mystring = DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "m", 60, $ts->getSubtract());
$resultado = ereg_replace("[^0-9]", "", $mystring);
$resultado = round(($resultado/60),5);
echo $resultado;
$sub_total += $resultado;
echo "\n";
}
}
示例5: ExecuteQuery
function ExecuteQuery(){
$this->data = array();
$parameters = $this->getParameters();
foreach ($parameters as $p){
$value = $p->getValue();
$date = new DateTimeValue(mktime(12,0,0,$p->getId(),1,2008));
$this->data['values'][0]['labels'][] = $date->format("F");
$this->data['values'][0]['values'][] = (int)$value;
$this->data['values'][1]['labels'][] = $date->format("F");
$this->data['values'][1]['values'][] = 10000;
} // foreach
$this->data['values'][0]['name'] = lang('current');
$this->data['values'][1]['name'] = lang('budgeted');
}
示例6: ExecuteQuery
function ExecuteQuery()
{
$this->data = array();
$date = new DateTimeValue(Time());
$notYet = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND ( due_date = \'0000-00-00 00:00:00\' OR due_date > \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "')"));
$today = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date = \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
$past = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date > \'1900-01-01 00:00:00\' AND due_date < \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
$value = 0;
if (isset($past)) {
$value = count($past);
}
$this->data['values'][0]['labels'][] = 'Overdue';
$this->data['values'][0]['values'][] = $value;
$value = 0;
if (isset($notYet)) {
$value = count($notYet);
}
$this->data['values'][0]['labels'][] = 'Not yet due';
$this->data['values'][0]['values'][] = $value;
$value = 0;
if (isset($today)) {
$value = count($today);
}
$this->data['values'][0]['labels'][] = 'Due today';
$this->data['values'][0]['values'][] = $value;
}
示例7: index
/**
* Index
*
* @param voi
* @return null
*/
function index()
{
require_once CALENDAR_MODULE_PATH . '/models/generators/ProjectCalendarGenerator.class.php';
$today = new DateTimeValue(time() + get_user_gmt_offset());
if ($this->request->get('month') && $this->request->get('year')) {
$month = $this->request->get('month');
$year = $this->request->get('year');
} else {
$month = $today->getMonth();
$year = $today->getYear();
}
// if
$first_weekday = UserConfigOptions::getValue('time_first_week_day', $this->logged_user);
$generator = new ProjectCalendarGenerator($month, $year, $first_weekday);
$generator->setProject($this->active_project);
$generator->setData(Calendar::getProjectData($this->logged_user, $this->active_project, $month, $year));
$this->smarty->assign(array('month' => $month, 'year' => $year, 'calendar' => $generator, 'page_tab' => 'calendar', 'navigation_pattern' => Calendar::getProjectMonthUrl($this->active_project, '-YEAR-', '-MONTH-')));
}
示例8: 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;
}
示例9: 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);
}
示例10: index
/**
* Calendar
*
* @param void
* @return null
*/
function index()
{
require_once CALENDAR_MODULE_PATH . '/models/generators/DashboardCalendarGenerator.class.php';
if ($this->request->get('month') && $this->request->get('year')) {
$month = $this->request->get('month');
$year = $this->request->get('year');
} else {
$today = new DateTimeValue(time() + get_user_gmt_offset());
$month = $today->getMonth();
$year = $today->getYear();
}
// if
$first_weekday = UserConfigOptions::getValue('time_first_week_day', $this->logged_user);
$generator = new DashboardCalendarGenerator($month, $year, $first_weekday);
$generator->setData(Calendar::getActiveProjectsData($this->logged_user, $month, $year));
$this->smarty->assign(array('month' => $month, 'year' => $year, 'calendar' => $generator, 'navigation_pattern' => Calendar::getDashboardMonthUrl('-YEAR-', '-MONTH-')));
//BOF:mod 20110623
$tabs = new NamedList();
$tabs->add('dashboard', array('text' => 'Active Teams', 'url' => assemble_url('dashboard')));
$tabs->add('home_page', array('text' => 'Home Page', 'url' => assemble_url('goto_home_tab')));
$this->smarty->assign('page_tabs', $tabs);
//EOF:mod 20110623
}
示例11: total_task_times_print_table
function total_task_times_print_table($objects, $left, $options, $group_name, &$sub_total = 0, &$sub_total_billing = 0) {
echo '<div style="padding-left:'. $left .'px;">';
echo '<table class="reporting-table"><tr class="reporting-table-heading">';
echo '<th>' . lang('date') . '</th>';
echo '<th>' . lang('title') . '</th>';
echo '<th>' . lang('description') . '</th>';
echo '<th>' . lang('person') . '</th>';
if (array_var($options, 'show_billing') == 'checked') {
echo '<th class="right">' . lang('billing') . '</th>';
}
echo '<th class="right">' . lang('time') . '</th>';
echo '</tr>';
$sub_total = 0;
$alt_cls = "";
foreach ($objects as $ts) { /* @var $ts Timeslot */
echo "<tr $alt_cls>";
echo "<td class='date'>" . format_date($ts->getStartTime()) . "</td>";
echo "<td class='name'>" . ($ts->getRelObjectId() == 0 ? clean($ts->getObjectName()) : clean($ts->getRelObject()->getObjectName())) ."</td>";
echo "<td class='name'>" . clean($ts->getDescription()) ."</td>";
echo "<td class='person'>" . clean($ts->getUser() instanceof Contact ? $ts->getUser()->getObjectName() : '') ."</td>";
if (array_var($options, 'show_billing') == 'checked') {
if($ts->getIsFixedBilling()){
echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format($ts->getFixedBilling(), 2) . "</td>";
$sub_total_billing += $ts->getFixedBilling();
}else{
$min = $ts->getMinutes();
echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format(($ts->getHourlyBilling()/60) * $min, 2) . "</td>";
$sub_total_billing += ($ts->getHourlyBilling()/60) * $min;
}
}
$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
echo "<td class='time nobr right'>" . DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) ."</td>";
echo "</tr>";
$sub_total += $ts->getMinutes();
$alt_cls = $alt_cls == "" ? 'class="alt-row"' : "";
}
echo '</table></div>';
}
示例12: cvs_total_task_times_table
function cvs_total_task_times_table($objects, $pad_str, $options, $group_name, &$sub_total = 0)
{
echo lang('date') . ';';
echo lang('title') . ';';
echo lang('description') . ';';
echo lang('person') . ';';
echo lang('time') . ';';
echo "\n";
$sub_total = 0;
foreach ($objects as $ts) {
echo $pad_str . format_date($ts->getStartTime()) . ';';
echo ($ts->getRelObjectId() == 0 ? clean($ts->getObjectName()) : clean($ts->getRelObject()->getObjectName())) . ';';
echo clean($ts->getDescription()) . ';';
echo clean($ts->getUser()->getObjectName()) . ';';
$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
echo DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) . ';';
$sub_total += $ts->getMinutes();
echo "\n";
}
}
示例13: smarty_function_calendar
/**
* Render calendar
*
* Params:
*
* - data - Calendar data
* - first_week_day - Value for first day in week from settings
* @param array $params
* @return string
*/
function smarty_function_calendar($params, &$smarty)
{
$first_week_day = 0;
if (isset($params['first_week_day'])) {
$first_week_day = (int) array_var($params, 'first_week_day');
unset($params['first_week_day']);
}
// if
$data = array();
if (isset($params['data'])) {
$data = array_var($params, 'data');
unset($params['first_week_day']);
}
// if
$days = array(0 => lang('Sunday'), 1 => lang('Monday'), 2 => lang('Tuesday '), 3 => lang('Wednesday'), 4 => lang('Thursday'), 5 => lang('Friday'), 6 => lang('Saturday'));
$data_keys = array_keys($data);
$date = $data_keys[0];
$date = explode('-', $date);
$year = $date[0];
// year to render
$month = $date[1];
// month to render
$begining_of_month = DateTimeValue::beginningOfMonth($month, $year);
$end_of_month = DateTimeValue::endOfMonth($month, $year);
$first_month_day = date('w', $begining_of_month->getTimestamp());
$calendar = "<div id=\"calendar\">\n<table>\n";
// header
$calendar .= "\t<thead>\n";
$from = $first_week_day;
$start_point = null;
for ($i = 0; $i < 7; $i++) {
$day = $from > 6 ? $days[$from - 7] : $days[$from];
$calendar .= "\t\t<th>{$day}</th>\n";
$from++;
if ($day == $days[$first_month_day]) {
$start_point = $i;
}
// if
}
$calendar .= "\t</thead>\n";
// data
$calendar .= "\t<tr>\n";
$curr_day = 1;
for ($i = 1; $i < 36; $i++) {
if ($i - 1 >= $start_point) {
if ($curr_day <= $end_of_month->getDay()) {
$calendar .= "\t\t<td><span>{$curr_day}</span>";
$items = $data[$year . '-' . $month . '-' . $curr_day]['items'];
$counts = $data[$year . '-' . $month . '-' . $curr_day]['counts'];
// milestones
foreach ($items as $milestone) {
if (instance_of($milestone, 'Milestone')) {
$calendar .= "<p>" . $milestone->getName() . "</p>";
}
}
// foreach
if ($counts) {
if ($counts['Ticket']) {
$calendar .= "<p>(" . $counts['Ticket'] . ')' . lang('Tickets') . "</p>";
}
// if
if ($counts['Task']) {
$calendar .= "<p>(" . $counts['Task'] . ')' . lang('Tasks') . "</p>";
}
// if
}
// if
$calendar .= "</td>\n";
$curr_day++;
} else {
$calendar .= "\t\t<td></td>\n";
}
// if
} else {
$calendar .= "\t\t<td></td>\n";
}
$calendar .= $i % 7 == 0 && $i < 35 ? "\t</tr>\n\t<tr>\n" : null;
}
$calendar .= "\t</tr>\n";
$calendar .= "</table>\n</div>\n";
return $calendar;
}
示例14: 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;
}
示例15: findUpcoming
/**
* Return upcoming objects in a given projects
*
* @param User $user
* @param Project $project
* @param array $types
* @param integer $page
* @param integer $per_page
* @return array
*/
function findUpcoming($user, $project = null, $types = null, $page = null, $per_page = null)
{
if (instance_of($project, 'Project')) {
$type_filter = ProjectUsers::getVisibleTypesFilterByProject($user, $project, $types);
} else {
$type_filter = ProjectUsers::getVisibleTypesFilter($user, array(PROJECT_STATUS_ACTIVE), $types);
}
if ($type_filter) {
$today = new DateTimeValue();
$today->advance(get_user_gmt_offset());
$newer_than = $today->endOfDay();
$conditions = array($type_filter . ' AND due_on > ? AND state >= ? AND visibility >= ? AND completed_on IS NULL', $newer_than, STATE_VISIBLE, $user->getVisibility());
if ($page !== null && $per_page !== null) {
return ProjectObjects::paginate(array('conditions' => $conditions, 'order' => 'due_on, priority DESC'), $page, $per_page);
} else {
return ProjectObjects::find(array('conditions' => $conditions, 'order' => 'due_on, priority DESC'));
}
// if
}
// if
return null;
}