[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

@ -3,32 +3,32 @@
# #
CREATE TABLE tx_events_domain_model_event ( CREATE TABLE tx_events_domain_model_event (
title varchar(255) DEFAULT '' NOT NULL, title varchar(255) DEFAULT '' NOT NULL,
global_id varchar(255) DEFAULT '' NOT NULL, global_id varchar(255) DEFAULT '' NOT NULL,
slug varchar(255) DEFAULT '' NOT NULL, slug varchar(255) DEFAULT '' NOT NULL,
highlight smallint(5) unsigned DEFAULT '0' NOT NULL, highlight smallint(5) unsigned DEFAULT '0' NOT NULL,
teaser text, teaser text,
details text, details text,
price_info text, price_info text,
street varchar(255) DEFAULT '' NOT NULL, street varchar(255) DEFAULT '' NOT NULL,
district varchar(255) DEFAULT '' NOT NULL, district varchar(255) DEFAULT '' NOT NULL,
city varchar(255) DEFAULT '' NOT NULL, city varchar(255) DEFAULT '' NOT NULL,
zip varchar(255) DEFAULT '' NOT NULL, zip varchar(255) DEFAULT '' NOT NULL,
country varchar(255) DEFAULT '' NOT NULL, country varchar(255) DEFAULT '' NOT NULL,
web varchar(255) DEFAULT '' NOT NULL, web varchar(255) DEFAULT '' NOT NULL,
booking varchar(255) DEFAULT '' NOT NULL, booking varchar(255) DEFAULT '' NOT NULL,
ticket varchar(255) DEFAULT '' NOT NULL, ticket varchar(255) DEFAULT '' NOT NULL,
facebook varchar(255) DEFAULT '' NOT NULL, facebook varchar(255) DEFAULT '' NOT NULL,
youtube varchar(255) DEFAULT '' NOT NULL, youtube varchar(255) DEFAULT '' NOT NULL,
latitude varchar(255) DEFAULT '' NOT NULL, latitude varchar(255) DEFAULT '' NOT NULL,
longitude varchar(255) DEFAULT '' NOT NULL, longitude varchar(255) DEFAULT '' NOT NULL,
images int(11) unsigned NOT NULL default '0', images int(11) unsigned NOT NULL default '0',
categories int(11) DEFAULT '0' NOT NULL, categories int(11) DEFAULT '0' NOT NULL,
dates int(11) unsigned DEFAULT '0' NOT NULL, dates int(11) unsigned DEFAULT '0' NOT NULL,
organizer int(11) unsigned DEFAULT '0', organizer int(11) unsigned DEFAULT '0',
region int(11) unsigned DEFAULT '0', region int(11) unsigned DEFAULT '0',
KEY dataHandler (l10n_parent, t3ver_oid, deleted, t3ver_wsid, t3ver_state) KEY dataHandler (l10n_parent, t3ver_oid, deleted, t3ver_wsid, t3ver_state)
); );
# #
@ -36,30 +36,27 @@ CREATE TABLE tx_events_domain_model_event (
# #
CREATE TABLE tx_events_domain_model_organizer ( CREATE TABLE tx_events_domain_model_organizer (
name varchar(255) DEFAULT '' NOT NULL, name varchar(255) DEFAULT '' NOT NULL,
street varchar(255) DEFAULT '' NOT NULL, street varchar(255) DEFAULT '' NOT NULL,
district varchar(255) DEFAULT '' NOT NULL, district varchar(255) DEFAULT '' NOT NULL,
city varchar(255) DEFAULT '' NOT NULL, city varchar(255) DEFAULT '' NOT NULL,
zip varchar(255) DEFAULT '' NOT NULL, zip varchar(255) DEFAULT '' NOT NULL,
phone varchar(255) DEFAULT '' NOT NULL, phone varchar(255) DEFAULT '' NOT NULL,
web varchar(255) DEFAULT '' NOT NULL, web varchar(255) DEFAULT '' NOT NULL,
email varchar(255) DEFAULT '' NOT NULL, email varchar(255) DEFAULT '' NOT NULL,
KEY dataHandler (l10n_parent, sys_language_uid, deleted) KEY dataHandler (l10n_parent, sys_language_uid, deleted)
); );
# #
# 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,
end int(11) DEFAULT NULL,
start datetime DEFAULT NULL, KEY event (event),
end datetime DEFAULT NULL, KEY dataHandler (event, t3ver_wsid, pid)
KEY event (event),
KEY dataHandler (event, t3ver_wsid, pid)
); );
# #
@ -67,7 +64,7 @@ CREATE TABLE tx_events_domain_model_date (
# #
CREATE TABLE tx_events_domain_model_region ( CREATE TABLE tx_events_domain_model_region (
title varchar(255) DEFAULT '' NOT NULL, title varchar(255) DEFAULT '' NOT NULL,
); );
@ -76,6 +73,6 @@ CREATE TABLE tx_events_domain_model_region (
# #
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,
); );