mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 02:16:10 +01:00
Allow to define midnight or now for todays dates
This commit is contained in:
parent
4d79220444
commit
58d602c153
5 changed files with 65 additions and 3 deletions
|
@ -61,6 +61,11 @@ class DateDemand
|
||||||
*/
|
*/
|
||||||
protected $end = null;
|
protected $end = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $useMidnight = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -272,6 +277,25 @@ class DateDemand
|
||||||
$this->end = $end;
|
$this->end = $end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setUseMidnight(bool $useMidnight): void
|
||||||
|
{
|
||||||
|
$this->useMidnight = $useMidnight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldShowFromNow(): bool
|
||||||
|
{
|
||||||
|
return $this->getStart() === null
|
||||||
|
&& $this->getEnd() === null
|
||||||
|
&& $this->useMidnight === false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldShowFromMidnight(): bool
|
||||||
|
{
|
||||||
|
return $this->getStart() === null
|
||||||
|
&& $this->getEnd() === null
|
||||||
|
&& $this->useMidnight === true;
|
||||||
|
}
|
||||||
|
|
||||||
public function getConsiderDate(): bool
|
public function getConsiderDate(): bool
|
||||||
{
|
{
|
||||||
return $this->considerDate;
|
return $this->considerDate;
|
||||||
|
|
|
@ -73,6 +73,9 @@ class DateDemandFactory
|
||||||
if (!empty($settings['end'])) {
|
if (!empty($settings['end'])) {
|
||||||
$demand->setEnd((int)$settings['end']);
|
$demand->setEnd((int)$settings['end']);
|
||||||
}
|
}
|
||||||
|
if (isset($settings['useMidnight'])) {
|
||||||
|
$demand->setUseMidnight((bool)$settings['useMidnight']);
|
||||||
|
}
|
||||||
if (!empty($settings['limit'])) {
|
if (!empty($settings['limit'])) {
|
||||||
$demand->setLimit($settings['limit']);
|
$demand->setLimit($settings['limit']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ class DateRepository extends Repository
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($demand->getStart() === null && $demand->getEnd() === null) {
|
if ($demand->shouldShowFromNow() || $demand->shouldShowFromMidnight()) {
|
||||||
$now = $this->context->getPropertyFromAspect(
|
$now = $this->context->getPropertyFromAspect(
|
||||||
'date',
|
'date',
|
||||||
'full',
|
'full',
|
||||||
|
@ -106,7 +106,13 @@ class DateRepository extends Repository
|
||||||
1639382648
|
1639382648
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$now = $now->modify('midnight');
|
|
||||||
|
$now = $now->setTimezone(new \DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
|
if ($demand->shouldShowFromMidnight()) {
|
||||||
|
$now = $now->modify('midnight');
|
||||||
|
}
|
||||||
|
|
||||||
$constraints['nowAndFuture'] = $query->logicalOr([
|
$constraints['nowAndFuture'] = $query->logicalOr([
|
||||||
$query->greaterThanOrEqual('start', $now),
|
$query->greaterThanOrEqual('start', $now),
|
||||||
$query->greaterThanOrEqual('end', $now)
|
$query->greaterThanOrEqual('end', $now)
|
||||||
|
|
29
Documentation/Changelog/2.4.0.rst
Normal file
29
Documentation/Changelog/2.4.0.rst
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
2.3.0
|
||||||
|
=====
|
||||||
|
|
||||||
|
Breaking
|
||||||
|
--------
|
||||||
|
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
* New Option `useMidnight = 0` is available.
|
||||||
|
This allows to explicitly show dates from now instead of midnight which is kept as
|
||||||
|
default.
|
||||||
|
|
||||||
|
Fixes
|
||||||
|
-----
|
||||||
|
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
Tasks
|
||||||
|
-----
|
||||||
|
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
Deprecation
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Nothing
|
|
@ -9,7 +9,7 @@ $EM_CONF['events'] = [
|
||||||
'state' => 'alpha',
|
'state' => 'alpha',
|
||||||
'createDirs' => '',
|
'createDirs' => '',
|
||||||
'clearCacheOnLoad' => 0,
|
'clearCacheOnLoad' => 0,
|
||||||
'version' => '2.3.3',
|
'version' => '2.4.0',
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
'depends' => [
|
'depends' => [
|
||||||
'typo3' => '10.4.00-10.4.99',
|
'typo3' => '10.4.00-10.4.99',
|
||||||
|
|
Loading…
Reference in a new issue