Fix vacation times handling

pull/187/head
Aleksander Machniak 10 years ago
parent 29c24e647c
commit 5a64153f40

@ -156,20 +156,22 @@ class rcube_sieve_vacation extends rcube_sieve_engine
$date = trim($$var . ' ' . $time); $date = trim($$var . ' ' . $time);
if ($date && ($dt = rcube_utils::anytodatetime($date, $timezone))) { if ($date && ($dt = rcube_utils::anytodatetime($date, $timezone))) {
if ($time) {
$vacation_tests[] = array( $vacation_tests[] = array(
'test' => 'currentdate', 'test' => 'currentdate',
'part' => 'date', 'part' => 'iso8601',
'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'), 'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'),
'zone' => $dt->format('O'), 'zone' => $dt->format('O'),
'arg' => $dt->format('Y-m-d'), 'arg' => str_replace('+00:00', 'Z', strtoupper($dt->format('c'))),
); );
if ($time) { }
else {
$vacation_tests[] = array( $vacation_tests[] = array(
'test' => 'currentdate', 'test' => 'currentdate',
'part' => 'time', 'part' => 'date',
'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'), 'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'),
'zone' => $dt->format('O'), 'zone' => $dt->format('O'),
'arg' => $dt->format('H:i:s'), 'arg' => $dt->format('Y-m-d'),
); );
} }
} }
@ -333,24 +335,24 @@ class rcube_sieve_vacation extends rcube_sieve_engine
$date_value = array(); $date_value = array();
foreach ((array) $this->vacation['tests'] as $test) { foreach ((array) $this->vacation['tests'] as $test) {
if ($test['test'] == 'currentdate' && ($test['part'] == 'date' || $test['part'] == 'time')) { if ($test['test'] == 'currentdate') {
$idx = $test['type'] == 'value-ge' ? 'from' : 'to'; $idx = $test['type'] == 'value-ge' ? 'from' : 'to';
$date_value[$idx][$test['part']] = $test['arg'];
if ($test['zone']) { if ($test['part'] == 'date') {
$date_value[$idx]['zone'] = $test['zone']; $date_value[$idx]['date'] = $test['arg'];
}
else if ($test['part'] == 'iso8601') {
$date_value[$idx]['datetime'] = $test['arg'];
} }
} }
} }
foreach ($date_value as $idx => $value) { foreach ($date_value as $idx => $value) {
$date = $value['date'] . ' ' $date = $value['datetime'] ?: $value['date'];
. ($value['time'] ? $value['time'] : ($idx == 'from' ? '00:00:00' : '23:59:59')) $date_value[$idx] = $this->rc->format_date($date, $date_format, false);
. ($value['zone'] ? ' ' . $value['zone'] : '');
$date_value[$idx] = $this->rc->format_date($date, $date_format, !empty($value['time']) && !empty($value['zone']));
if (!empty($value['time'])) { if (!empty($value['datetime'])) {
$date_value['time_' . $idx] = $this->rc->format_date($date, $time_format, !empty($value['zone'])); $date_value['time_' . $idx] = $this->rc->format_date($date, $time_format, true);
} }
} }
} }

Loading…
Cancel
Save