本文整理汇总了PHP中TimeDate::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeDate::getInstance方法的具体用法?PHP TimeDate::getInstance怎么用?PHP TimeDate::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeDate
的用法示例。
在下文中一共展示了TimeDate::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOrderBy
/**
* checks the request for the order by and if that is not set then it checks the session for it
*
* @return array containing the keys orderBy => field being ordered off of and sortOrder => the sort order of that field
*/
function getOrderBy($orderBy = '', $direction = '')
{
if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
if (!empty($_REQUEST[$this->var_order_by])) {
$direction = 'ASC';
$orderBy = $_REQUEST[$this->var_order_by];
if (!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0)) {
$direction = $_REQUEST['lvso'];
$trackerManager = TrackerManager::getInstance();
if ($monitor = $trackerManager->getMonitor('tracker')) {
$monitor->setValue('module_name', $GLOBALS['module']);
$monitor->setValue('item_summary', "lvso=" . $direction . "&" . $this->var_order_by . "=" . $_REQUEST[$this->var_order_by]);
$monitor->setValue('action', 'listview');
$monitor->setValue('user_id', $GLOBALS['current_user']->id);
$monitor->setValue('date_modified', TimeDate::getInstance()->nowDb());
$monitor->save();
}
}
}
$_SESSION[$this->var_order_by] = array('orderBy' => $orderBy, 'direction' => $direction);
$_SESSION['lvd']['last_ob'] = $orderBy;
} else {
if (!empty($_SESSION[$this->var_order_by])) {
$orderBy = $_SESSION[$this->var_order_by]['orderBy'];
$direction = $_SESSION[$this->var_order_by]['direction'];
} else {
$orderBy = 'date_entered';
$direction = 'DESC';
}
}
return array('orderBy' => $orderBy, 'sortOrder' => $direction);
}
示例2: setUp
public function setUp()
{
$this->scheduler = new TestScheduler(false);
$GLOBALS['timedate'] = $this->timedate = TimeDate::getInstance();
$this->timedate->allow_cache = true;
$this->now = $this->timedate->getNow();
}
示例3: ejecutar
public function ejecutar($focus, $string_parametros)
{
$this->procesar_parametros($string_parametros);
$alarma = loadBean('gcoop_alarmas');
$alarma->parent_type = $focus->module_dir;
$alarma->parent_id = $focus->id;
$alarma->destinatario = $this->destinatario;
$alarma->notificacion = $this->notificacion;
$alarma->parametro = $this->parametro;
$alarma->valor = $this->valor;
#sumarle dias no fin de semana!
$fecha = new DateTime();
$dia = new DateInterval('P1D');
while ($this->cantidad_dias > 0) {
$fecha->add($dia);
if ($fecha->format('N') < 6) {
$this->cantidad_dias -= 1;
}
}
$timedate = TimeDate::getInstance();
$alarma->fecha_disparo = $timedate->asDb($fecha);
$alarma->save();
if (method_exists($focus, 'notificar')) {
$focus->notificar("Se creó alarama con fecha de disparo {$alarma->fecha_disparo}", 'Alarma');
}
}
示例4: run
/**
* This method implements the run function of RunnableSchedulerJob and handles processing a SchedulersJob
*
* @param Mixed $data parameter passed in from the job_queue.data column when a SchedulerJob is run
* @return bool true on success, false on error
*/
public function run($data)
{
global $app_strings, $language;
$app_strings = return_application_language($language);
$admin = BeanFactory::getBean('Administration');
$config = $admin->getConfigForModule('Forecasts', 'base');
$timeperiodInterval = $config['timeperiod_interval'];
$timeperiodLeafInterval = $config['timeperiod_leaf_interval'];
$parentTimePeriod = TimePeriod::getLatest($timeperiodInterval);
$latestTimePeriod = TimePeriod::getLatest($timeperiodLeafInterval);
$currentTimePeriod = TimePeriod::getCurrentTimePeriod($timeperiodLeafInterval);
if (empty($latestTimePeriod)) {
$GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . '[latest]');
return false;
} else {
if (empty($currentTimePeriod)) {
$GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [current]');
return false;
} else {
if (empty($parentTimePeriod)) {
$GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [parent]');
return false;
}
}
}
$timedate = TimeDate::getInstance();
//We run the rebuild command if the latest TimePeriod is less than the specified configuration interval
//from the current TimePeriod
$correctStartDate = $timedate->fromDbDate($currentTimePeriod->start_date);
$latestStartDate = $timedate->fromDbDate($latestTimePeriod->start_date);
$shownForward = $config['timeperiod_shown_forward'];
//Move the current start date forward by the leaf period amounts
for ($x = 0; $x < $shownForward; $x++) {
$correctStartDate->modify($parentTimePeriod->next_date_modifier);
}
$leafCycle = $latestTimePeriod->leaf_cycle;
//If the current start data that was modified according to the shown forward period is past the latest
//leaf period we need to build more timeperiods
while ($correctStartDate > $latestStartDate) {
//We need to keep creating leaf periods until we are in sync.
//If the leaf period we need to create is the start of the leaf cycle
//then we should also create the parent TimePeriod record.
$startDate = $latestStartDate->modify($latestTimePeriod->next_date_modifier);
$leafCycle = $leafCycle == $parentTimePeriod->leaf_periods ? 1 : $leafCycle + 1;
if ($leafCycle == 1) {
$parentTimePeriod = TimePeriod::getByType($timeperiodInterval);
$parentTimePeriod->setStartDate($startDate->asDbDate());
$parentTimePeriod->name = $parentTimePeriod->getTimePeriodName($leafCycle);
$parentTimePeriod->save();
}
$leafTimePeriod = TimePeriod::getByType($timeperiodLeafInterval);
$leafTimePeriod->setStartDate($startDate->asDbDate());
$leafTimePeriod->name = $leafTimePeriod->getTimePeriodName($leafCycle, $parentTimePeriod);
$leafTimePeriod->leaf_cycle = $leafCycle;
$leafTimePeriod->parent_id = $parentTimePeriod->id;
$leafTimePeriod->save();
}
$this->job->succeedJob();
return true;
}
示例5: generateItem
protected function generateItem($item)
{
$name = !empty($item['name_value_list']['name']['value']) ? htmlentities($item['name_value_list']['name']['value']) : '';
$url = $GLOBALS['sugar_config']['site_url'] . htmlentities('/index.php?module=' . $item['module_name'] . '&action=DetailView&record=' . $item['id']);
$date = TimeDate::httpTime(TimeDate::getInstance()->fromDb($item['name_value_list']['date_modified']['value'])->getTimestamp());
$description = '';
$displayFieldNames = true;
if (count($item['name_value_list']) == 2 && isset($item['name_value_list']['name'])) {
$displayFieldNames = false;
}
foreach ($item['name_value_list'] as $k => $v) {
if ($k == 'name' || $k == 'date_modified') {
continue;
}
if ($displayFieldNames) {
$description .= '<b>' . htmlentities($k) . ':<b> ';
}
$description .= htmlentities($v['value']) . "<br>";
}
echo <<<EORSS
<item>
<title>{$name}</title>
<link>{$url}</link>
<description><![CDATA[{$description}]]></description>
<pubDate>{$date} GMT</pubDate>
<guid>{$item['id']}</guid>
</item>
EORSS;
}
示例6: getAgenda
public function getAgenda($api, $args)
{
// Fetch the next 14 days worth of meetings (limited to 20)
$end_time = new SugarDateTime("+14 days");
$start_time = new SugarDateTime("-1 hour");
$meeting = BeanFactory::newBean('Meetings');
$meetingList = $meeting->get_list('date_start', "date_start > " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($start_time->asDb()), 'datetime') . " AND date_start < " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($end_time->asDb()), 'datetime'));
// Setup the breaks for the various time periods
$datetime = new SugarDateTime();
$today_stamp = $datetime->get_day_end()->getTimestamp();
$tomorrow_stamp = $datetime->setDate($datetime->year, $datetime->month, $datetime->day + 1)->get_day_end()->getTimestamp();
$timeDate = TimeDate::getInstance();
$returnedMeetings = array('today' => array(), 'tomorrow' => array(), 'upcoming' => array());
foreach ($meetingList['list'] as $meetingBean) {
$meetingStamp = $timeDate->fromUser($meetingBean->date_start)->getTimestamp();
$meetingData = $this->formatBean($api, $args, $meetingBean);
if ($meetingStamp < $today_stamp) {
$returnedMeetings['today'][] = $meetingData;
} else {
if ($meetingStamp < $tomorrow_stamp) {
$returnedMeetings['tomorrow'][] = $meetingData;
} else {
$returnedMeetings['upcoming'][] = $meetingData;
}
}
}
return $returnedMeetings;
}
示例7: tearDown
public function tearDown()
{
SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
unset($GLOBALS['current_user']);
unset($GLOBALS['app_list_strings']);
unset($GLOBALS['beanList']);
$GLOBALS['timedate'] = TimeDate::getInstance();
}
示例8: setUp
public function setUp()
{
$this->sugarWidgetField = new SugarWidgetFieldDateTime48616Mock(new LayoutManager());
global $current_user, $timedate;
$timedate = TimeDate::getInstance();
$current_user = SugarTestUserUtilities::createAnonymousUser();
//$this->setOutputBuffering = false;
}
示例9: setUp
public function setUp()
{
global $timedate, $current_user;
$timedate = TimeDate::getInstance();
require 'include/modules.php';
$GLOBALS['beanList'] = $beanList;
$GLOBALS['beanFiles'] = $beanFiles;
$current_user = SugarTestUserUtilities::createAnonymousUser();
$this->nowTime = $timedate->asDb($timedate->getNow()->get("-10 minutes"));
$this->tenMinutesLaterTime = $timedate->asDb($timedate->getNow()->get("+10 minutes"));
$current_user->is_admin = 1;
$current_user->save();
$this->meeting = SugarTestMeetingUtilities::createMeeting();
$this->meeting->team_id = $current_user->team_id;
$this->meeting->team_set_id = $current_user->team_set_id;
$this->meeting->team_id = $current_user->team_id;
$this->meeting->team_set_id = $current_user->team_set_id;
$this->meeting->assigned_user_id = $current_user->id;
$this->meeting->save();
$this->meeting->load_relationship('users');
$this->meeting->users->add($current_user);
$this->call = SugarTestCallUtilities::createCall();
$this->call->team_id = $current_user->team_id;
$this->call->team_set_id = $current_user->team_set_id;
$this->call->assigned_user_id = $current_user->id;
$this->call->save();
$this->call->load_relationships('users');
$this->call->users->add($current_user);
$this->contact = SugarTestContactUtilities::createContact();
$this->contact->email1 = 'mark.zuckerberg@facebook.com';
$this->contact->contacts_users_id = $current_user->id;
$this->contact->load_relationship('user_sync');
$this->contact->user_sync->add($current_user);
$this->contact->sync_contact = 1;
$this->contact->save();
$this->task = SugarTestTaskUtilities::createTask();
$this->task->assigned_user_id = $current_user->id;
$this->task->team_id = $current_user->id;
$this->task->team_set_id = $current_user->id;
$this->task->save();
//$this->useOutputBuffering = false;
/**
* This provider returns an Array of Array data. Each Array contains the following data
* 0 => String - Left side module name
* 1 => String - Right side module name
* 2 => String - Relationship Query
* 3 => boolean to return deleted records or not (this is actually ignored by the function)
* 4 => integer offset to start with
* 5 => integer value for the maximum number of results
* 6 => array of fields to select and return
* 7 => load_relationships - Relationship name to use
* 8 => array of expected results
* 9 => integer of expected total count
* 10 => array of expected soap error
* @return array The provider array
*/
$this->testData = array(array('Users', 'Meetings', "( (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND m1.deleted = 0) OR (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND m1.deleted = 1) AND m1.id IN ('{$this->meeting->id}')) OR (m1.id NOT IN ('{$this->meeting->id}') AND m1.deleted = 0) AND m2.id = '{$current_user->id}'", 0, 0, 3000, $this->callsAndMeetingsSelectFields, 'meetings_users', array('id' => $this->meeting->id), 1, $this->noSoapErrorArray), array('Users', 'Calls', "( m1.deleted = 0) AND m2.id = '{$current_user->id}'", 0, 0, 3000, $this->callsAndMeetingsSelectFields, 'calls_users', array('id' => $this->call->id), 1, $this->noSoapErrorArray), array('Users', 'Contacts', "( (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 0) OR ({0}.date_modified > '{$this->nowTime}' AND {0}.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 1) AND m1.id IN ('31a219bd-b9c1-2c3e-aa5d-4f2778ab0347','c794bc39-e4fb-f515-f1d5-4f285ca88965','d51a0555-8f84-9e62-0fbc-4f2787b5d839','a1219ae6-5a6b-0d1b-c49f-4f2854bc2912')) OR (m1.id NOT IN ('31a219bd-b9c1-2c3e-aa5d-4f2778ab0347','c794bc39-e4fb-f515-f1d5-4f285ca88965','d51a0555-8f84-9e62-0fbc-4f2787b5d839','a1219ae6-5a6b-0d1b-c49f-4f2854bc2912') AND {0}.deleted = 0) AND m2.id = '1'", 0, 0, 3000, $this->contactsSelectFields, 'contacts_users', array('id' => $this->contact->id, 'email1' => 'mark.zuckerberg@facebook.com'), 1, $this->noSoapErrorArray), array('Users', 'Tasks', " ( (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 0) OR ({0}.date_modified > '{$this->nowTime}' AND {0}.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 1) AND m1.id IN ('{$this->task->id}')) OR (m1.id NOT IN ('{$this->task->id}') AND {0}.deleted = 0) AND m2.id = '1'", 0, 0, 3000, $this->tasksSelectFields, 'tasks_assigned_user', array('id' => $this->task->id), 1, $this->noSoapErrorArray));
}
示例10: getTimePeriodName
/**
* getTimePeriodName
*
* Returns the timeperiod name. The TimePeriod base implementation simply returns the $count argument passed
* in from the code
*
* @param $count The timeperiod series count
* @return string The formatted name of the timeperiod
*/
public function getTimePeriodName($count)
{
$timedate = TimeDate::getInstance();
$year = $timedate->fromDbDate($this->start_date);
if (isset($this->currentSettings['timeperiod_fiscal_year']) && $this->currentSettings['timeperiod_fiscal_year'] == 'next_year') {
$year->modify('+1 year');
}
return string_format($this->name_template, array($year->format('Y')));
}
示例11: testCorrectNextMonth
/**
* @dataProvider providerCorrectNextMonth
* @outputBuffering disabled
*/
public function testCorrectNextMonth($testDate, $direction, $expectedString)
{
global $timedate;
$timedate = TimeDate::getInstance();
$this->calendar = new Calendar('month');
$this->calendar->date_time = $timedate->fromString($testDate);
$uri = $this->calendar->get_neighbor_date_str($direction);
$this->assertContains($expectedString, $uri, "Failed to get {$direction} expected URL: {$expectedString} from date: {$testDate}");
}
示例12: Common
function Common()
{
global $db;
$this->db = $db;
if (empty($this->db)) {
$this->db = DBManagerFactory::getInstance();
}
$this->timedate = TimeDate::getInstance();
}
示例13: evaluate
/**
* Returns number of hours from now until the specified date.
*/
public function evaluate()
{
$params = DateExpression::parse($this->getParameters()->evaluate());
if (!$params) {
return false;
}
$now = TimeDate::getInstance()->getNow(true);
$tsdiff = $params->ts - $now->ts;
return (int) ($tsdiff / 3600);
}
示例14: setUp
public function setUp()
{
$this->sugarWidgetField = new SugarWidgetFieldDateTime49008Mock(new LayoutManager());
global $current_user, $timedate;
$timedate = TimeDate::getInstance();
$current_user = SugarTestUserUtilities::createAnonymousUser();
$current_user->setPreference('timezone', 'America/Los_Angeles');
$current_user->save();
$current_user->db->commit();
}
示例15: exportSanitize
/**
* Handles export field sanitizing for field type
*
* @param $value string value to be sanitized
* @param $vardef array representing the vardef definition
* @param $focus SugarBean object
* @param $row Array of a row of data to be exported
*
* @return string sanitized value
*/
public function exportSanitize($value, $vardef, $focus, $row = array())
{
$timedate = TimeDate::getInstance();
$db = DBManagerFactory::getInstance();
//If it's in ISO format, convert it to db format
if (preg_match('/(\\d{4})\\-?(\\d{2})\\-?(\\d{2})T(\\d{2}):?(\\d{2}):?(\\d{2})\\.?\\d*([Z+-]?)(\\d{0,2}):?(\\d{0,2})/i', $value)) {
$value = $timedate->fromIso($value)->asDbDate(false);
}
return $timedate->to_display_date($db->fromConvert($value, 'date'), false);
}