[BUGFIX] Make daterange filtering in EXT:belog work again 37/55037/7
authorSusanne Moog <susanne.moog@typo3.com>
Tue, 12 Dec 2017 07:30:52 +0000 (08:30 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 12 Dec 2017 14:36:34 +0000 (15:36 +0100)
Use ISO dates and date time objects consistently.

Change-Id: I1095f6690a3b73217657cc2577ebdaf6d7ff5fc0
Releases: master, 8.7
Resolves: #82126
Reviewed-on: https://review.typo3.org/55037
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benjamin Kott <benjamin.kott@outlook.com>
Tested-by: Benjamin Kott <benjamin.kott@outlook.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/belog/Classes/Controller/AbstractController.php
typo3/sysext/belog/Resources/Private/Partials/Content/Filter.html
typo3/sysext/belog/Resources/Private/Partials/Content/LogEntries.html

index 12ce846..effdec1 100644 (file)
@@ -357,12 +357,33 @@ abstract class AbstractController extends ActionController
                 $startTime = mktime(0, 0, 0) - 31 * 3600 * 24;
                 break;
             case self::TIMEFRAME_CUSTOM:
-                $startTime = $constraint->getStartTimestamp();
-                if ($constraint->getEndTimestamp() > $constraint->getStartTimestamp()) {
-                    $endTime = $constraint->getEndTimestamp();
-                } else {
-                    $endTime = $GLOBALS['EXEC_TIME'];
+                $startDate = $constraint->getManualDateStart();
+                $endDate = $constraint->getManualDateStop();
+                $endTime = $GLOBALS['EXEC_TIME'];
+                if (!$startDate) {
+                    $startDate = \DateTime::createFromFormat(
+                        'U',
+                        0
+                    );
+                    $constraint->setManualDateStart(
+                        $startDate
+                    );
                 }
+
+                if (!$endDate) {
+                    $endDate = \DateTime::createFromFormat(
+                        'U',
+                        $endTime
+                    )->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+                    $constraint->setManualDateStop(
+                        $endDate
+                    );
+                }
+                $startTime = $startDate->getTimestamp();
+                if ($endDate->getTimestamp() > $startDate->getTimestamp()) {
+                    $endTime = $endDate->getTimestamp();
+                }
+
                 break;
             default:
         }
index 9e2de80..9a0b546 100644 (file)
                        <div class="input-group input-group-sm">
                                <f:form.textfield
                                                name="manualDateStart"
-                                               value="{f:if(condition: constraint.startTimestamp, then: \"{f:format.date(format:'{settings.timeFormat} {settings.dateFormat}', date: '@{constraint.startTimestamp}')}\")}"
+                                               value="{f:if(condition: constraint.manualDateStart, then: \"{f:format.date(format:'{settings.timeFormat} {settings.dateFormat}', date: '{constraint.manualDateStart}')}\")}"
                                                id="manualDateStart"
                                                class="form-control input-sm t3js-datetimepicker t3js-clearable"
                                                data="{date-type: 'datetime'}"
                                                />
-                               <f:form.hidden property="startTimestamp" value="{constraint.startTimestamp}" />
+                               <f:form.hidden
+                                               property="manualDateStart"
+                                               value="{f:if(condition: constraint.manualDateStart, then: \"{f:format.date(format:'c', date: '{constraint.manualDateStart}')}\")}"
+                               />
                                <span class="input-group-btn">
                                        <label class="btn btn-default" for="manualDateStart">
                                                <span class="fa fa-calendar"></span>
                        <div class="input-group input-group-sm">
                                <f:form.textfield
                                                name="manualDateStop"
-                                               value="{f:format.date(format:'{settings.timeFormat} {settings.dateFormat}', date: '@{constraint.endTimestamp}')}"
+                                               value="{f:format.date(format:'{settings.timeFormat} {settings.dateFormat}', date: '{constraint.manualDateStop}')}"
                                                id="manualDateStop"
                                                class="form-control input-sm t3js-datetimepicker t3js-clearable"
                                                data="{date-type: 'datetime'}"
                                                />
-                               <f:form.hidden property="endTimestamp" />
+                               <f:form.hidden property="manualDateStop"
+                                               value="{f:format.date(format:'c', date: '{constraint.manualDateStop}')}"
+                               />
                                <span class="input-group-btn">
                                        <label class="btn btn-default" for="manualDateStop">
                                                <span class="fa fa-calendar"></span>
index 33b3a0f..5c832fc 100644 (file)
@@ -9,8 +9,8 @@
                <f:translate
                        key="timeInfo"
                        arguments="{
-                               0: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.startTimestamp}\')}',
-                               1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.endTimestamp}\')}'
+                               0: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStart}\')}',
+                               1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStop}\')}'
                        }"
                />
                <p>
@@ -42,8 +42,8 @@
                                                                        key="logForNonPageRelatedActionsOrRootLevelOrPage"
                                                                        arguments="{
                                                                                0: '{f:translate(key:\'forNonPageRelatedActions\')}',
-                                                                               1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.startTimestamp}\')}',
-                                                                               2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.endTimestamp}\')}'
+                                                                               1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStart}\')}',
+                                                                               2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStop}\')}'
                                                                        }"
                                                                />
                                                        </f:if>
@@ -52,8 +52,8 @@
                                                                        key="logForNonPageRelatedActionsOrRootLevelOrPage"
                                                                        arguments="{
                                                                                0: '{f:translate(key:\'forRootLevel\')}',
-                                                                               1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.startTimestamp}\')}',
-                                                                               2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.endTimestamp}\')}'
+                                                                               1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStart}\')}',
+                                                                               2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStop}\')}'
                                                                        }"
                                                                />
                                                        </f:if>
@@ -76,8 +76,8 @@
                                                                                        1:\\\'{pid}\\\'
                                                                                }\'
                                                                        )}',
-                                                                       1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.startTimestamp}\')}',
-                                                                       2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.endTimestamp}\')}'
+                                                                       1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStart}\')}',
+                                                                       2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStop}\')}'
                                                                }"
                                                                />
                                                        </f:format.raw>
@@ -89,8 +89,8 @@
                                                key="logForNonPageRelatedActionsOrRootLevelOrPage"
                                                arguments="{
                                                        0: '',
-                                                       1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.startTimestamp}\')}',
-                                                       2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'@{constraint.endTimestamp}\')}'
+                                                       1: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStart}\')}',
+                                                       2: '{f:format.date(format:\'{settings.dateFormat} {settings.timeFormat}\', date:\'{constraint.manualDateStop}\')}'
                                                }"
                                        />
                                </f:else>