本文整理汇总了PHP中TBGSettings::getGMToffset方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGSettings::getGMToffset方法的具体用法?PHP TBGSettings::getGMToffset怎么用?PHP TBGSettings::getGMToffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBGSettings
的用法示例。
在下文中一共展示了TBGSettings::getGMToffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
?>
<option value="0"<?php
if (TBGSettings::getGMToffset() == 0) {
?>
selected<?php
}
?>
>GMT/UTC</option>
<?php
for ($cc = 1; $cc <= 12; $cc++) {
?>
<option value="<?php
echo $cc;
?>
"<?php
if (TBGSettings::getGMToffset() == $cc) {
?>
selected<?php
}
?>
>GMT +<?php
echo $cc;
?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
示例2: tbg_formatTime
/**
* Returns a formatted string of the given timestamp
*
* @param integer $tstamp the timestamp to format
* @param integer $format[optional] the format
* @param integer $skiptimestamp
*/
function tbg_formatTime($tstamp, $format = 0)
{
// offset the timestamp properly
if (TBGSettings::getGMToffset() > 0) {
$tstamp += TBGSettings::getGMToffset() * 60 * 60;
} elseif (TBGSettings::getGMToffset() < 0) {
$tstamp -= TBGSettings::getGMToffset() * 60 * 60;
}
if (TBGSettings::getUserTimezone() > 0) {
$tstamp += TBGSettings::getUserTimezone() * 60 * 60;
} elseif (TBGSettings::getUserTimezone() < 0) {
$tstamp -= TBGSettings::getUserTimezone() * 60 * 60;
}
switch ($format) {
case 1:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(1), $tstamp);
break;
case 2:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(2), $tstamp);
break;
case 3:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(3), $tstamp);
break;
case 4:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(4), $tstamp);
break;
case 5:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(5), $tstamp);
break;
case 6:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(6), $tstamp);
break;
case 7:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(7), $tstamp);
break;
case 8:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(8), $tstamp);
break;
case 9:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(9), $tstamp);
break;
case 10:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(10), $tstamp);
break;
case 11:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(9), $tstamp);
break;
case 12:
$tstring = '';
if (date('dmY', $tstamp) == date('dmY')) {
$tstring .= __('Today') . ', ';
} elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
$tstring .= __('Yesterday') . ', ';
} elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
$tstring .= __('Tomorrow') . ', ';
} else {
$tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(12) . ', ', $tstamp);
}
$tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(14), $tstamp);
break;
case 13:
$tstring = '';
if (date('dmY', $tstamp) == date('dmY')) {
//$tstring .= __('Today') . ', ';
} elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
$tstring .= __('Yesterday') . ', ';
} elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
$tstring .= __('Tomorrow') . ', ';
} else {
$tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(12) . ', ', $tstamp);
}
$tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(14), $tstamp);
break;
case 14:
$tstring = '';
if (date('dmY', $tstamp) == date('dmY')) {
$tstring .= __('Today');
} elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
$tstring .= __('Yesterday');
} elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
$tstring .= __('Tomorrow');
} else {
$tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(12), $tstamp);
}
break;
case 15:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(11), $tstamp);
break;
case 16:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(12), $tstamp);
break;
case 17:
$tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(13), $tstamp);
//.........这里部分代码省略.........
示例3: _fixTimestamps
private function _fixTimestamps()
{
// Unlimited execution time
set_time_limit(0);
foreach (TBGScope::getAll() as $scope) {
TBGContext::setScope($scope);
// The first job is to work out the offsets that need applying
$offsets = array('system', 'users');
$offsets['users'] = array();
$offsets['system'] = (int) TBGSettings::getGMToffset() * 3600;
$settingstable = TBGSettingsTable::getTable();
$crit = $settingstable->getCriteria();
$crit->addWhere(TBGSettingsTable::NAME, 'timezone');
$crit->addWhere(TBGSettingsTable::MODULE, 'core');
$crit->addWhere(TBGSettingsTable::UID, 0, \b2db\Criteria::DB_NOT_EQUALS);
$crit->addWhere(TBGSettingsTable::VALUE, 0, \b2db\Criteria::DB_NOT_EQUALS);
$crit->addWhere(TBGSettingsTable::VALUE, 'sys', \b2db\Criteria::DB_NOT_EQUALS);
$crit->addWhere(TBGSettingsTable::SCOPE, $scope->getID());
$res = $settingstable->doSelect($crit);
if ($res instanceof \b2db\Resultset) {
while ($user = $res->getNextRow()) {
$offsets['users']['uid_' . $user->get(TBGSettingsTable::UID)] = (int) $user->get(TBGSettingsTable::VALUE) * 3600;
}
}
// Now go through every thing which requires updating
TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes' . DS . 'B2DB');
TBGContext::addAutoloaderClassPath(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'classes');
// ARTICLE HISTORY
$this->_fixUserDependentTimezone($offsets, TBGArticleHistoryTable::getTable(), TBGArticleHistoryTable::AUTHOR, TBGArticleHistoryTable::DATE, $scope);
// ARTICLES
$this->_fixUserDependentTimezone($offsets, TBGArticlesTable::getTable(), TBGArticlesTable::AUTHOR, TBGArticlesTable::DATE, $scope);
// BUILDS
$this->_fixNonUserDependentTimezone($offsets, TBGBuildsTable::getTable(), TBGBuildsTable::RELEASE_DATE, $scope, TBGBuildsTable::RELEASED);
// COMMENTS
$this->_fixUserDependentTimezone($offsets, TBGCommentsTable::getTable(), array('a' => TBGCommentsTable::POSTED_BY, 'b' => TBGCommentsTable::UPDATED_BY), array('a' => TBGCommentsTable::POSTED, 'b' => TBGCommentsTable::UPDATED), $scope);
// EDITIONS
$this->_fixNonUserDependentTimezone($offsets, TBGEditionsTable::getTable(), TBGEditionsTable::RELEASE_DATE, $scope, TBGEditionsTable::RELEASED);
// ISSUES
// This is a bit more complex so do this manually - we have to poke around with the issue log
$table = TBGIssuesTable::getTable();
$crit = $table->getCriteria();
$crit->addWhere(TBGIssuesTable::SCOPE, $scope->getID());
$crit->addWhere(TBGIssuesTable::DELETED, false);
$res = $table->doSelect($crit);
if ($res) {
while ($row = $res->getNextRow()) {
$crit = TBGLogTable::getTable()->getCriteria();
$crit->addSelectionColumn(TBGLogTable::UID);
$crit->addWhere(TBGLogTable::CHANGE_TYPE, TBGLogTable::LOG_ISSUE_ASSIGNED);
$crit->addWhere(TBGLogTable::TARGET, $row->get(TBGIssuesTable::ID));
$crit->addWhere(TBGLogTable::TARGET_TYPE, TBGLogTable::TYPE_ISSUE);
$crit->addOrderBy(TBGLogTable::TIME, b2db\Criteria::SORT_DESC);
$crit->addOrderBy(TBGLogTable::ID, b2db\Criteria::SORT_DESC);
if ($row2 = TBGLogTable::getTable()->doSelectOne($crit)) {
$assigned_by = $row2->get(TBGLogTable::UID);
}
$crit = TBGLogTable::getTable()->getCriteria();
$crit->addSelectionColumn(TBGLogTable::UID);
$crit->addWhere(TBGLogTable::TARGET, $row->get(TBGIssuesTable::ID));
$crit->addWhere(TBGLogTable::TARGET_TYPE, TBGLogTable::TYPE_ISSUE);
$crit->addOrderBy(TBGLogTable::TIME, b2db\Criteria::SORT_DESC);
$crit->addOrderBy(TBGLogTable::ID, b2db\Criteria::SORT_DESC);
if ($row2 = TBGLogTable::getTable()->doSelectOne($crit)) {
$updated_by = $row2->get(TBGLogTable::UID);
}
unset($crit);
unset($row2);
if (array_key_exists('uid_' . $row->get(TBGIssuesTable::POSTED_BY), $offsets['users'])) {
$offset = $offsets['users']['uid_' . $row->get(TBGIssuesTable::POSTED_BY)];
} else {
$offset = $offsets['system'];
}
if (isset($updated_by) && array_key_exists('uid_' . $updated_by, $offsets['users'])) {
$offset2 = $offsets['users']['uid_' . $updated_by];
} elseif (isset($updated_by)) {
$offset2 = $offsets['system'];
}
if (isset($assigned_by) && array_key_exists('uid_' . $assigned_by, $offsets['users'])) {
$offset3 = $offsets['users']['uid_' . $assigned_by];
} elseif (isset($assigned_by)) {
$offset3 = $offsets['system'];
}
$crit2 = $table->getCriteria();
$crit2->addUpdate(TBGIssuesTable::POSTED, (int) $row->get(TBGIssuesTable::POSTED) + $offset);
if (isset($offset2)) {
$crit2->addUpdate(TBGIssuesTable::LAST_UPDATED, (int) $row->get(TBGIssuesTable::LAST_UPDATED) + $offset2);
unset($offset2);
}
if (isset($offset3)) {
$crit2->addUpdate(TBGIssuesTable::BEING_WORKED_ON_BY_USER_SINCE, (int) $row->get(TBGIssuesTable::BEING_WORKED_ON_BY_USER_SINCE) + $offset3);
unset($offset3);
}
$crit2->addWhere(TBGIssuesTable::ID, $row->get(TBGIssuesTable::ID));
$table->doUpdate($crit2);
}
}
// LOG
$this->_fixUserDependentTimezone($offsets, TBGLogTable::getTable(), TBGLogTable::UID, TBGLogTable::TIME, $scope);
// MILESTONES
// The conditions are a bit different here so do it manually
//.........这里部分代码省略.........