[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
*/
public function setEnd($end)
public function setEnd(\DateTime $end)
{
$this->end = $end;
}

View file

@ -86,7 +86,8 @@ class DateRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
]
);
} 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() !== '') {

View file

@ -346,15 +346,15 @@ class DestinationDataImportService {
$this->dateRepository->remove($currentDate);
}
$now = new \DateTime();
$now = $now->getTimestamp();
$today = new \DateTime('today');
$today = $today->getTimestamp();
foreach ($timeIntervals as $date) {
// Check if dates are given as interval or not
if (empty($date['interval'])) {
if (strtotime($date['start']) > $now) {
if (strtotime($date['start']) > $today) {
$this->logger->info('Setup single date');
$dateObj = $this->objectManager->get(\Wrm\Events\Domain\Model\Date::class);
$start = new \DateTime($date['start'], new \DateTimeZone($date['tz']));
@ -369,13 +369,14 @@ class DestinationDataImportService {
} else {
if ($date['freq'] == 'Daily' && empty($date['weekdays'])) {
$this->logger->info('Setup daily interval dates');
$this->logger->info('Start ' . $date['start']);
$this->logger->info('End ' . $date['repeatUntil']);
$start = new \DateTime($date['start'], 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)) {
if ($i > $now) {
if ($i >= $today) {
$eventStart = new \DateTime();
$eventStart->setTimestamp($i);
$eventStart->setTime($start->format('H'), $start->format('i'));
@ -388,6 +389,7 @@ class DestinationDataImportService {
$this->tmpCurrentEvent->addDate($dateObj);
}
}
}
else if ($date['freq'] == 'Weekly' && !empty($date['weekdays'])) {
@ -397,9 +399,8 @@ class DestinationDataImportService {
$this->logger->info('End ' . $date['repeatUntil']);
$start = new \DateTime($date['start'], 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)) {
if ($i > $now) {
if ($i >= $today) {
$eventStart = new \DateTime();
$eventStart->setTimestamp($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,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.start',
'config' => [
'dbType' => 'datetime',
//'dbType' => 'datetime',
'type' => 'input',
'renderType' => 'inputDateTime',
'size' => 12,
@ -132,7 +132,7 @@ return [
'exclude' => true,
'label' => 'LLL:EXT:events/Resources/Private/Language/locallang_db.xlf:tx_events_domain_model_date.end',
'config' => [
'dbType' => 'datetime',
//'dbType' => 'datetime',
'type' => 'input',
'renderType' => 'inputDateTime',
'size' => 12,
@ -141,14 +141,6 @@ return [
],
],
/*
'event' => [
'config' => [
'type' => 'passthrough',
],
],
*/
'event' => array(
'exclude' => 1,
'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'
#
CREATE TABLE tx_events_domain_model_date (
event int(11) unsigned DEFAULT '0' NOT NULL,
start datetime DEFAULT NULL,
end datetime DEFAULT NULL,
start int(11) DEFAULT NULL,
end int(11) DEFAULT NULL,
KEY event (event),
KEY dataHandler (event, t3ver_wsid, pid)
);