Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions plugins/cck_field/jform_calendar/jform_calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class="'.$class.'"
return $field;
}
}

// onCCK_FieldPrepareSearch
public function onCCK_FieldPrepareSearch( &$field, $value = '', &$config = array(), $inherit = array(), $return = false )
{
Expand All @@ -214,20 +214,29 @@ public function onCCK_FieldPrepareSearch( &$field, $value = '', &$config = array
}
$value = trim( $value );

if ( (int)$value > 0 ) {
$date = JFactory::getDate( $value, $this->userTimeZone );
if ((int)$value > 0) {
$options2 = JCckDev::fromJSON($field->options2);
$modify = (isset($options2['modify']) && $options2['modify']) ? $options2['modify'] : '';

$options2 = JCckDev::fromJSON( $field->options2 );
$modify = ( isset( $options2['modify'] ) && $options2['modify'] ) ? $options2['modify'] : '';
// Detect if the value includes a time
$hasTime = strpos($value, ':') !== false;

if ( $modify ) {
$date->modify( $modify );
}
$timezone = new DateTimeZone( 'UTC' );
$date->setTimezone( $timezone );
$value = $date->toSql();
// Prevent timezone shift to previous day
if (!$hasTime) {
$value .= ' 12:00:00';
}

$date = JFactory::getDate($value, $this->userTimeZone);

if ($modify) {
$date->modify($modify);
}

$timezone = new DateTimeZone('UTC');
$date->setTimezone($timezone);
$value = $date->toSql();
}

// Prepare
self::onCCK_FieldPrepareForm( $field, $value, $config, $inherit, $return );

Expand Down