本文整理汇总了PHP中Calendar::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Calendar::add方法的具体用法?PHP Calendar::add怎么用?PHP Calendar::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Calendar
的用法示例。
在下文中一共展示了Calendar::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDateNavigation
public function testDateNavigation()
{
$calendar = new Calendar(new \DateTime('2014-01-04 12:14:00'));
$this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d'));
$calendar->nextDay();
$this->assertEquals('2014-01-05', $calendar->getDate()->format('Y-m-d'));
$calendar->prevDay();
$this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d'));
$calendar->nextMonth();
$this->assertEquals('2014-02-04', $calendar->getDate()->format('Y-m-d'));
$calendar->prevMonth();
$this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d'));
$calendar->nextYear();
$this->assertEquals('2015-01-04', $calendar->getDate()->format('Y-m-d'));
$calendar->prevYear();
$this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d'));
$calendar->add(new \DateInterval('P1M2D'));
$this->assertEquals('2014-02-06', $calendar->getDate()->format('Y-m-d'));
$calendar->sub(new \DateInterval('P1M2D'));
$this->assertEquals('2014-01-04', $calendar->getDate()->format('Y-m-d'));
}
示例2: Calendar
echo $cal->getFirstDayName();
?>
</td>
</tr>
<tr>
<td class='name'>Timezone offset in second</td>
<td class='value'><?php
echo $cal->getTimezoneOffset();
?>
</td>
</tr>
<tr>
<td class='name'>Date list from -5 days to now</td>
<td class='value'>
<?php
$date_from = new Calendar();
$date_to = new Calendar();
$date_from->add('day', -5);
$list = Calendar::generateDateList($date_from, $date_to, 'dd/MM/yyyy');
$list_len = count($list);
for ($i = 0; $i < $list_len; $i++) {
echo $list[$i], '<br>';
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
示例3: pluginMonitoringInstall
function pluginMonitoringInstall($version)
{
global $DB, $CFG_GLPI;
// ** Insert in DB
$DB_file = GLPI_ROOT . "/plugins/monitoring/install/mysql/plugin_monitoring-" . $version . "-empty.sql";
$DBf_handle = fopen($DB_file, "rt");
$sql_query = fread($DBf_handle, filesize($DB_file));
fclose($DBf_handle);
foreach (explode(";\n", "{$sql_query}") as $sql_line) {
if (get_magic_quotes_runtime()) {
$sql_line = Toolbox::stripslashes_deep($sql_line);
}
if (!empty($sql_line)) {
$DB->query($sql_line);
}
}
include GLPI_ROOT . "/plugins/monitoring/inc/profile.class.php";
$pmProfile = new PluginMonitoringProfile();
$pmProfile->initProfile();
include GLPI_ROOT . "/plugins/monitoring/inc/command.class.php";
$pmCommand = new PluginMonitoringCommand();
$pmCommand->initCommands();
include GLPI_ROOT . "/plugins/monitoring/inc/notificationcommand.class.php";
$pmNotificationcommand = new PluginMonitoringNotificationcommand();
$pmNotificationcommand->initCommands();
include GLPI_ROOT . "/plugins/monitoring/inc/check.class.php";
$pmCheck = new PluginMonitoringCheck();
$pmCheck->initChecks();
include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php";
$pmHostconfig = new PluginMonitoringHostconfig();
$pmHostconfig->initConfig();
include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php";
$pmConfig = new PluginMonitoringConfig();
$pmConfig->initConfig();
$query = "UPDATE `glpi_plugin_monitoring_configs`\n SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n WHERE `id`='1'";
$DB->query($query);
$query = "SELECT * FROM `glpi_calendars`\n WHERE `name`='24x7'\n LIMIT 1";
$result = $DB->query($query);
if ($DB->numrows($result) == 0) {
$calendar = new Calendar();
$input = array();
$input['name'] = '24x7';
$input['is_recursive'] = 1;
$calendars_id = $calendar->add($input);
$calendarSegment = new CalendarSegment();
$input = array();
$input['calendars_id'] = $calendars_id;
$input['is_recursive'] = 1;
$input['begin'] = '00:00:00';
$input['end'] = '24:00:00';
$input['day'] = '0';
$calendarSegment->add($input);
$input['day'] = '1';
$calendarSegment->add($input);
$input['day'] = '2';
$calendarSegment->add($input);
$input['day'] = '3';
$calendarSegment->add($input);
$input['day'] = '4';
$calendarSegment->add($input);
$input['day'] = '5';
$calendarSegment->add($input);
$input['day'] = '6';
$calendarSegment->add($input);
}
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring");
}
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates");
}
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg");
}
CronTask::Register('PluginMonitoringServiceevent', 'updaterrd', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
CronTask::Register('PluginMonitoringUnavaibility', 'unavaibility', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
CronTask::Register('PluginMonitoringDisplayview_rule', 'replayallviewrules', '1200', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
}
示例4: pluginMonitoringUpdate
function pluginMonitoringUpdate($current_version, $migrationname = 'Migration')
{
global $DB;
$migration = new $migrationname($current_version);
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring");
}
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates");
}
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg");
}
$unavaibility_recalculate = 0;
if (!TableExists("glpi_plugin_monitoring_unavaibilities") || !FieldExists("glpi_plugin_monitoring_unavaibilities", "duration")) {
$unavaibility_recalculate = 1;
}
/*
* Table glpi_plugin_monitoring_servicescatalogs
*/
$newTable = "glpi_plugin_monitoring_servicescatalogs";
if (!TableExists($newTable)) {
$query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query);
}
$migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT");
$migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL");
$migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL");
$migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'");
$migration->migrationOneTable($newTable);
$migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL");
$migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'last_check', "datetime DEFAULT NULL");
$migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_acknowledged', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_acknowledgeconfirmed', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'acknowledge_comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->addField($newTable, 'acknowledge_users_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addKey($newTable, "name");
$migration->migrationOneTable($newTable);
/*
* Table glpi_plugin_monitoring_componentscatalogs
*/
$newTable = "glpi_plugin_monitoring_componentscatalogs";
if (!TableExists($newTable)) {
$query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query);
}
$migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT");
$migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL");
$migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'notification_interval', 'notification_interval', "int(4) NOT NULL DEFAULT '30'");
$migration->migrationOneTable($newTable);
$migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL");
$migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->addField($newTable, 'notification_interval', "int(4) NOT NULL DEFAULT '30'");
$migration->addKey($newTable, "name");
$migration->migrationOneTable($newTable);
/*
* Table glpi_plugin_monitoring_components
*/
$newTable = "glpi_plugin_monitoring_components";
if (!TableExists($newTable)) {
$query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query);
}
$migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT");
$migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL");
$migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'active_checks_enabled', 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'");
$migration->changeField($newTable, 'passive_checks_enabled', 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'");
$migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'remotesystem', 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
$migration->changeField($newTable, 'is_arguments', 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'alias_command', 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'graph_template', 'graph_template', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
$migration->changeField($newTable, 'link', 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
$migration->changeField($newTable, 'is_weathermap', 'is_weathermap', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'weathermap_regex', 'weathermap_regex_in', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'perfname', 'perfname', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'perfnameinvert', 'perfnameinvert', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'perfnamecolor', 'perfnamecolor', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->migrationOneTable($newTable);
$migration->addField($newTable, 'id', "int(11) NOT NULL AUTO_INCREMENT");
//.........这里部分代码省略.........
示例5: pluginMonitoringUpdate
function pluginMonitoringUpdate($current_version, $migrationname = 'Migration')
{
global $DB;
$migration = new $migrationname($current_version);
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring");
}
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates");
}
if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) {
mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg");
}
$unavailability_recalculate = 0;
if (!TableExists("glpi_plugin_monitoring_unavailabilities") || !FieldExists("glpi_plugin_monitoring_unavailabilities", "duration")) {
$unavailability_recalculate = 1;
}
$unavailability_reset = 0;
if (!TableExists("glpi_plugin_monitoring_unavailabilities")) {
$unavailability_reset = 1;
}
/*
* Table glpi_plugin_monitoring_servicescatalogs
*/
$newTable = "glpi_plugin_monitoring_servicescatalogs";
if (!TableExists($newTable)) {
$query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query);
}
$migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT");
$migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL");
$migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL");
$migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'");
$migration->migrationOneTable($newTable);
$migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL");
$migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'last_check', "datetime DEFAULT NULL");
$migration->addField($newTable, 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL");
$migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_acknowledged', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_acknowledgeconfirmed', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'acknowledge_comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->addField($newTable, 'acknowledge_users_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'notification_interval', "int(4) NOT NULL DEFAULT '30'");
$migration->addField($newTable, 'business_priority', "tinyint(1) NOT NULL DEFAULT '1'");
$migration->addField($newTable, 'is_generic', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'plugin_monitoring_servicescatalogs_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addKey($newTable, "name");
$migration->migrationOneTable($newTable);
/*
* Table glpi_plugin_monitoring_componentscatalogs
*/
$newTable = "glpi_plugin_monitoring_componentscatalogs";
if (!TableExists($newTable)) {
$query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query);
}
$migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT");
$migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL");
$migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->changeField($newTable, 'notification_interval', 'notification_interval', "int(4) NOT NULL DEFAULT '30'");
$migration->migrationOneTable($newTable);
$migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL");
$migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci");
$migration->addField($newTable, 'notification_interval', "int(4) NOT NULL DEFAULT '30'");
$migration->addKey($newTable, "name");
$migration->migrationOneTable($newTable);
/*
* glpi_plugin_monitoring_perfdatas
*/
$a_table = array();
$a_table['name'] = 'glpi_plugin_monitoring_perfdatas';
$a_table['oldname'] = array();
$a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'name' => array('type' => 'string', 'value' => NULL), 'perfdata' => array('type' => 'text', 'value' => NULL));
$a_table['oldfields'] = array();
$a_table['renamefields'] = array();
$a_table['keys'] = array();
$a_table['oldkeys'] = array();
migrateTablesMonitoring($migration, $a_table);
/*
* glpi_plugin_monitoring_customitems_counters
*/
$a_table = array();
$a_table['name'] = 'glpi_plugin_monitoring_customitems_counters';
$a_table['oldname'] = array();
$a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'name' => array('type' => 'string', 'value' => NULL), 'entities_id' => array('type' => 'integer', 'value' => NULL), 'is_recursive' => array('type' => 'bool', 'value' => NULL), 'type' => array('type' => 'string', 'value' => NULL), 'aggregate_items' => array('type' => 'text', 'value' => NULL), 'time' => array('type' => 'string', 'value' => NULL), 'time_specific' => array('type' => 'string', 'value' => NULL));
//.........这里部分代码省略.........