本文整理汇总了PHP中rcube_utils::format_datestr方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_utils::format_datestr方法的具体用法?PHP rcube_utils::format_datestr怎么用?PHP rcube_utils::format_datestr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcube_utils
的用法示例。
在下文中一共展示了rcube_utils::format_datestr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vacation_post
private function vacation_post()
{
if (empty($_POST)) {
return;
}
$date_extension = in_array('date', $this->exts);
$regex_extension = in_array('regex', $this->exts);
// set user's timezone
try {
$timezone = new DateTimeZone($this->rc->config->get('timezone', 'GMT'));
} catch (Exception $e) {
$timezone = new DateTimeZone('GMT');
}
$status = rcube_utils::get_input_value('vacation_status', rcube_utils::INPUT_POST);
$from = rcube_utils::get_input_value('vacation_from', rcube_utils::INPUT_POST);
$subject = rcube_utils::get_input_value('vacation_subject', rcube_utils::INPUT_POST, true);
$reason = rcube_utils::get_input_value('vacation_reason', rcube_utils::INPUT_POST, true);
$addresses = rcube_utils::get_input_value('vacation_addresses', rcube_utils::INPUT_POST, true);
$interval = rcube_utils::get_input_value('vacation_interval', rcube_utils::INPUT_POST);
$interval_type = rcube_utils::get_input_value('vacation_interval_type', rcube_utils::INPUT_POST);
$date_from = rcube_utils::get_input_value('vacation_datefrom', rcube_utils::INPUT_POST);
$date_to = rcube_utils::get_input_value('vacation_dateto', rcube_utils::INPUT_POST);
$time_from = rcube_utils::get_input_value('vacation_timefrom', rcube_utils::INPUT_POST);
$time_to = rcube_utils::get_input_value('vacation_timeto', rcube_utils::INPUT_POST);
$after = rcube_utils::get_input_value('vacation_after', rcube_utils::INPUT_POST);
$action = rcube_utils::get_input_value('vacation_action', rcube_utils::INPUT_POST);
$target = rcube_utils::get_input_value('action_target', rcube_utils::INPUT_POST, true);
$target_domain = rcube_utils::get_input_value('action_domain', rcube_utils::INPUT_POST);
$interval_type = $interval_type == 'seconds' ? 'seconds' : 'days';
$vacation_action['type'] = 'vacation';
$vacation_action['reason'] = $this->strip_value(str_replace("\r\n", "\n", $reason));
$vacation_action['subject'] = trim($subject);
$vacation_action['from'] = trim($from);
$vacation_action['addresses'] = $addresses;
$vacation_action[$interval_type] = $interval;
$vacation_tests = (array) $this->vacation['tests'];
foreach ((array) $vacation_action['addresses'] as $aidx => $address) {
$vacation_action['addresses'][$aidx] = $address = trim($address);
if (empty($address)) {
unset($vacation_action['addresses'][$aidx]);
} else {
if (!rcube_utils::check_email($address)) {
$error = 'noemailwarning';
break;
}
}
}
if (!empty($vacation_action['from']) && !rcube_utils::check_email($vacation_action['from'])) {
$error = 'noemailwarning';
}
if ($vacation_action['reason'] == '') {
$error = 'managesieve.emptyvacationbody';
}
if ($vacation_action[$interval_type] && !preg_match('/^[0-9]+$/', $vacation_action[$interval_type])) {
$error = 'managesieve.forbiddenchars';
}
// find and remove existing date/regex/true rules
foreach ((array) $vacation_tests as $idx => $t) {
if ($t['test'] == 'currentdate' || $t['test'] == 'true' || $t['test'] == 'header' && $t['type'] == 'regex' && $t['arg1'] == 'received') {
unset($vacation_tests[$idx]);
}
}
if ($date_extension) {
$date_format = $this->rc->config->get('date_format', 'Y-m-d');
foreach (array('date_from', 'date_to') as $var) {
$time = ${str_replace('date', 'time', $var)};
$date = rcube_utils::format_datestr(${$var}, $date_format);
$date = trim($date . ' ' . $time);
if ($date && ($dt = rcube_utils::anytodatetime($date, $timezone))) {
if ($time) {
$vacation_tests[] = array('test' => 'currentdate', 'part' => 'iso8601', 'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'), 'zone' => $dt->format('O'), 'arg' => str_replace('+00:00', 'Z', strtoupper($dt->format('c'))));
} else {
$vacation_tests[] = array('test' => 'currentdate', 'part' => 'date', 'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'), 'zone' => $dt->format('O'), 'arg' => $dt->format('Y-m-d'));
}
}
}
} else {
if ($regex_extension) {
// Add date range rules if range specified
if ($date_from && $date_to) {
if ($tests = self::build_regexp_tests($date_from, $date_to, $error)) {
$vacation_tests = array_merge($vacation_tests, $tests);
}
}
}
}
if ($action == 'redirect' || $action == 'copy') {
if ($target_domain) {
$target .= '@' . $target_domain;
}
if (empty($target) || !rcube_utils::check_email($target)) {
$error = 'noemailwarning';
}
}
if (empty($vacation_tests)) {
$vacation_tests = $this->rc->config->get('managesieve_vacation_test', array(array('test' => 'true')));
}
if (!$error) {
$rule = $this->vacation;
$rule['type'] = 'if';
//.........这里部分代码省略.........
示例2: test_format_datestr
/**
* rcube:utils::format_datestr()
*/
function test_format_datestr()
{
$test = array(array('abc-555', 'abc', 'abc-555'), array('2013-04-22', 'Y-m-d', '2013-04-22'), array('22/04/2013', 'd/m/Y', '2013-04-22'), array('4.22.2013', 'm.d.Y', '2013-04-22'));
foreach ($test as $data) {
$result = rcube_utils::format_datestr($data[0], $data[1]);
$this->assertSame($data[2], $result, "Error formatting date: " . $data[0]);
}
}