[TASK] Fix DateTime Issue

This commit is contained in:
Dirk 2019-10-11 15:12:07 +02:00
parent bc5801452b
commit bd4409fd76
5 changed files with 55 additions and 64 deletions

View file

@ -49,10 +49,10 @@ class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
} }
/** /**
* @param string $end * @param \DateTime $end
* @return void * @return void
*/ */
public function setEnd($end) public function setEnd(\DateTime $end)
{ {
$this->end = $end; $this->end = $end;
} }

View file

@ -86,7 +86,8 @@ class DateRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
] ]
); );
} else { } else {
$constraints['untilnow'] = $query->greaterThanOrEqual('start', date("Y-m-d H:i:s")); $now = new \DateTime('now', new \DateTimeZone('Europe/Berlin'));
$constraints['untilnow'] = $query->greaterThanOrEqual('start', $now);
} }
if ($demand->getLimit() !== '') { if ($demand->getLimit() !== '') {

View file

@ -346,15 +346,15 @@ class DestinationDataImportService {
$this->dateRepository->remove($currentDate); $this->dateRepository->remove($currentDate);
} }
$now = new \DateTime(); $today = new \DateTime('today');
$now = $now->getTimestamp(); $today = $today->getTimestamp();
foreach ($timeIntervals as $date) { foreach ($timeIntervals as $date) {
// Check if dates are given as interval or not // Check if dates are given as interval or not
if (empty($date['interval'])) { if (empty($date['interval'])) {
if (strtotime($date['start']) > $now) { if (strtotime($date['start']) > $today) {
$this->logger->info('Setup single date'); $this->logger->info('Setup single date');
$dateObj = $this->objectManager->get(\Wrm\Events\Domain\Model\Date::class); $dateObj = $this->objectManager->get(\Wrm\Events\Domain\Model\Date::class);
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz'])); $start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
@ -369,13 +369,14 @@ class DestinationDataImportService {
} else { } else {
if ($date['freq'] == 'Daily' && empty($date['weekdays'])) { if ($date['freq'] == 'Daily' && empty($date['weekdays'])) {
$this->logger->info('Setup daily interval dates'); $this->logger->info('Setup daily interval dates');
$this->logger->info('Start ' . $date['start']); $this->logger->info('Start ' . $date['start']);
$this->logger->info('End ' . $date['repeatUntil']); $this->logger->info('End ' . $date['repeatUntil']);
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz'])); $start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
$until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz'])); $until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz']));
for($i = strtotime($start->format('l'), $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 day', $i)) { for($i = strtotime($start->format('l'), $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 day', $i)) {
if ($i > $now) { if ($i >= $today) {
$eventStart = new \DateTime(); $eventStart = new \DateTime();
$eventStart->setTimestamp($i); $eventStart->setTimestamp($i);
$eventStart->setTime($start->format('H'), $start->format('i')); $eventStart->setTime($start->format('H'), $start->format('i'));
@ -388,6 +389,7 @@ class DestinationDataImportService {
$this->tmpCurrentEvent->addDate($dateObj); $this->tmpCurrentEvent->addDate($dateObj);
} }
} }
} }
else if ($date['freq'] == 'Weekly' && !empty($date['weekdays'])) { else if ($date['freq'] == 'Weekly' && !empty($date['weekdays'])) {
@ -397,9 +399,8 @@ class DestinationDataImportService {
$this->logger->info('End ' . $date['repeatUntil']); $this->logger->info('End ' . $date['repeatUntil']);
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz'])); $start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
$until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz'])); $until = new \DateTime($date['repeatUntil'], new \DateTimeZone($date['tz']));
for($i = strtotime($day, $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 week', $i)) { for($i = strtotime($day, $start->getTimestamp()); $i <= $until->getTimestamp(); $i = strtotime('+1 week', $i)) {
if ($i > $now) { if ($i >= $today) {
$eventStart = new \DateTime(); $eventStart = new \DateTime();
$eventStart->setTimestamp($i); $eventStart->setTimestamp($i);
$eventStart->setTime($start->format('H'), $start->format('i')); $eventStart->setTime($start->format('H'), $start->format('i'));
@ -415,8 +416,8 @@ class DestinationDataImportService {
} }
} }
} }
$this->logger->info('Finished setup dates');
} }
$this->logger->info('Finished setup dates');
} }
/** /**

View file

@ -120,7 +120,7 @@ return [
'exclude' => true, 'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.start', 'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.start',
'config' => [ 'config' => [
'dbType' => 'datetime', //'dbType' => 'datetime',
'type' => 'input', 'type' => 'input',
'renderType' => 'inputDateTime', 'renderType' => 'inputDateTime',
'size' => 12, 'size' => 12,
@ -132,7 +132,7 @@ return [
'exclude' => true, 'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.end', 'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.end',
'config' => [ 'config' => [
'dbType' => 'datetime', //'dbType' => 'datetime',
'type' => 'input', 'type' => 'input',
'renderType' => 'inputDateTime', 'renderType' => 'inputDateTime',
'size' => 12, 'size' => 12,
@ -141,14 +141,6 @@ return [
], ],
], ],
/*
'event' => [
'config' => [
'type' => 'passthrough',
],
],
*/
'event' => array( 'event' => array(
'exclude' => 1, 'exclude' => 1,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.event', 'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.event',

View file

@ -52,12 +52,9 @@ CREATE TABLE tx_events_domain_model_organizer (
# Table structure for table 'tx_events_domain_model_date' # Table structure for table 'tx_events_domain_model_date'
# #
CREATE TABLE tx_events_domain_model_date ( CREATE TABLE tx_events_domain_model_date (
event int(11) unsigned DEFAULT '0' NOT NULL, event int(11) unsigned DEFAULT '0' NOT NULL,
start int(11) DEFAULT NULL,
start datetime DEFAULT NULL, end int(11) DEFAULT NULL,
end datetime DEFAULT NULL,
KEY event (event), KEY event (event),
KEY dataHandler (event, t3ver_wsid, pid) KEY dataHandler (event, t3ver_wsid, pid)
); );