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
16 changes: 13 additions & 3 deletions lib/yform/value/datetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class rex_yform_value_datetime extends rex_yform_value_abstract
public function preValidateAction(): void
{
$value = $this->getValue();

if ('' == $this->getValue() && $this->params['main_id'] < 1) {
if (1 == $this->getElement('current_date')) {
$value = date(rex_sql::FORMAT_DATETIME);
Expand All @@ -36,7 +37,11 @@ public function preValidateAction(): void
$second = (int) ($value['second'] ?? 0);
} else {
$value = (string) $value;
$value = explode(' ', $value);
$localTimeTest = explode(' ', $value);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wäre es nicht einfacher nur das "T" mit einer Zeile $value = str_replace('T','',$value); zu ersetzen?

if (2 != count($localTimeTest)) {
$localTimeTest = explode('T', $value);
}
$value = $localTimeTest;
if (2 == count($value)) {
$date = explode('-', (string) $value[0]);
$year = (int) ($date[0] ?? 0);
Expand Down Expand Up @@ -64,7 +69,11 @@ public function enterObject()
$second = (int) ($value['second'] ?? 0);
} else {
$value = (string) $value;
$value = explode(' ', $value);
$localTimeTest = explode(' ', $value);
if (2 != count($localTimeTest)) {
$localTimeTest = explode('T', $value);
}
$value = $localTimeTest;
if (2 == count($value)) {
$date = explode('-', (string) $value[0]);
$year = (int) ($date[0] ?? 0);
Expand Down Expand Up @@ -182,7 +191,8 @@ public static function getSearchField($params)
'name' => $params['field']->getName(),
'label' => $params['field']->getLabel(),
'notice' => rex_i18n::msg('yform_values_date_search_notice', $format),
'attributes' => '{"data-yform-tools-datetimerangepicker":"' . $format . '"}', ]);
'attributes' => '{"data-yform-tools-datetimerangepicker":"' . $format . '"}',
]);
}

public static function getSearchFilter($params)
Expand Down