Skip to content

Commit

Permalink
Fix #682 - add hourly and minutely increment incl. tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed May 20, 2022
1 parent 77bbe92 commit 31ec3e3
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 111 deletions.
88 changes: 66 additions & 22 deletions Classes/Domain/Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ public function getType(): string
*
* @param string $type
*/
public function setType(string $type): void
public function setType(string $type): self
{
$this->type = $type;

return $this;
}

/**
Expand All @@ -239,9 +241,11 @@ public function isAllDay(): bool
*
* @param bool $allDay
*/
public function setAllDay(bool $allDay): void
public function setAllDay(bool $allDay): self
{
$this->allDay = $allDay;

return $this;
}

/**
Expand All @@ -259,9 +263,11 @@ public function getEndDate(): ?\DateTime
*
* @param \DateTime|null $endDate
*/
public function setEndDate(?\DateTime $endDate): void
public function setEndDate(?\DateTime $endDate): self
{
$this->endDate = DateTimeUtility::fixDateTimeForDb($endDate);

return $this;
}

/**
Expand All @@ -279,9 +285,11 @@ public function getEndDateDynamic(): string
*
* @param string $endDateDynamic
*/
public function setEndDateDynamic(string $endDateDynamic): void
public function setEndDateDynamic(string $endDateDynamic): self
{
$this->endDateDynamic = $endDateDynamic;

return $this;
}

/**
Expand All @@ -299,9 +307,11 @@ public function getEndTime(): int
*
* @param int $endTime
*/
public function setEndTime(int $endTime): void
public function setEndTime(int $endTime): self
{
$this->endTime = $endTime;

return $this;
}

/**
Expand All @@ -319,9 +329,11 @@ public function getStartDate(): ?\DateTime
*
* @param \DateTime|null $startDate
*/
public function setStartDate(?\DateTime $startDate): void
public function setStartDate(?\DateTime $startDate): self
{
$this->startDate = DateTimeUtility::fixDateTimeForDb($startDate);

return $this;
}

/**
Expand All @@ -339,9 +351,11 @@ public function getStartTime(): int
*
* @param int $startTime
*/
public function setStartTime(int $startTime): void
public function setStartTime(int $startTime): self
{
$this->startTime = $startTime;

return $this;
}

/**
Expand All @@ -359,9 +373,11 @@ public function getGroups(): ObjectStorage
*
* @param ObjectStorage $groups
*/
public function setGroups(ObjectStorage $groups): void
public function setGroups(ObjectStorage $groups): self
{
$this->groups = $groups;

return $this;
}

/**
Expand All @@ -379,9 +395,11 @@ public function getFrequency(): string
*
* @param string $frequency
*/
public function setFrequency(string $frequency): void
public function setFrequency(string $frequency): self
{
$this->frequency = $frequency;

return $this;
}

/**
Expand All @@ -399,9 +417,11 @@ public function getTillDate(): ?\DateTime
*
* @param \DateTime|null $tillDate
*/
public function setTillDate(?\DateTime $tillDate): void
public function setTillDate(?\DateTime $tillDate): self
{
$this->tillDate = DateTimeUtility::fixDateTimeForDb($tillDate);

return $this;
}

/**
Expand All @@ -419,9 +439,11 @@ public function getTillDays(): ?int
*
* @param int|null $tillDays
*/
public function setTillDays(?int $tillDays): void
public function setTillDays(?int $tillDays): self
{
$this->tillDays = $tillDays;

return $this;
}

/**
Expand All @@ -439,9 +461,11 @@ public function isTillDaysRelative(): bool
*
* @param bool $tillDaysRelative
*/
public function setTillDaysRelative(bool $tillDaysRelative): void
public function setTillDaysRelative(bool $tillDaysRelative): self
{
$this->tillDaysRelative = $tillDaysRelative;

return $this;
}

/**
Expand All @@ -459,9 +483,11 @@ public function getTillDaysPast(): ?int
*
* @param int|null $tillDaysPast
*/
public function setTillDaysPast(?int $tillDaysPast): void
public function setTillDaysPast(?int $tillDaysPast): self
{
$this->tillDaysPast = $tillDaysPast;

return $this;
}

/**
Expand All @@ -479,9 +505,11 @@ public function getCounterAmount(): int
*
* @param int $counterAmount
*/
public function setCounterAmount(int $counterAmount): void
public function setCounterAmount(int $counterAmount): self
{
$this->counterAmount = $counterAmount;

return $this;
}

/**
Expand All @@ -499,9 +527,11 @@ public function getCounterInterval(): int
*
* @param int $counterInterval
*/
public function setCounterInterval(int $counterInterval): void
public function setCounterInterval(int $counterInterval): self
{
$this->counterInterval = $counterInterval;

return $this;
}

/**
Expand All @@ -519,9 +549,11 @@ public function getExternalIcsUrl(): string
*
* @param string $externalIcsUrl
*/
public function setExternalIcsUrl(string $externalIcsUrl): void
public function setExternalIcsUrl(string $externalIcsUrl): self
{
$this->externalIcsUrl = $externalIcsUrl;

return $this;
}

/**
Expand All @@ -539,9 +571,11 @@ public function getDay(): string
*
* @param string $day
*/
public function setDay(string $day): void
public function setDay(string $day): self
{
$this->day = $day;

return $this;
}

/**
Expand All @@ -559,9 +593,11 @@ public function getRecurrence(): string
*
* @param string $recurrence
*/
public function setRecurrence(string $recurrence): void
public function setRecurrence(string $recurrence): self
{
$this->recurrence = $recurrence;

return $this;
}

/**
Expand All @@ -579,9 +615,11 @@ public function getHandling(): string
*
* @param string $handling
*/
public function setHandling(string $handling): void
public function setHandling(string $handling): self
{
$this->handling = $handling;

return $this;
}

/**
Expand All @@ -599,9 +637,11 @@ public function getState(): string
*
* @param string $state
*/
public function setState(string $state): void
public function setState(string $state): self
{
$this->state = $state;

return $this;
}

/**
Expand All @@ -615,9 +655,11 @@ public function isOpenEndTime(): bool
/**
* @param bool $openEndTime
*/
public function setOpenEndTime(bool $openEndTime): void
public function setOpenEndTime(bool $openEndTime): self
{
$this->openEndTime = $openEndTime;

return $this;
}

/**
Expand All @@ -631,8 +673,10 @@ public function isHidden(): bool
/**
* @param bool $hidden
*/
public function setHidden(bool $hidden): void
public function setHidden(bool $hidden): self
{
$this->hidden = $hidden;

return $this;
}
}
29 changes: 20 additions & 9 deletions Classes/Service/TimeTable/TimeTimeTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,26 @@ protected function addFrequencyItems(array &$times, Configuration $configuration
*/
protected function createNextLoopEntry(array $loopEntry, string $modification): array
{
/** @var $startDate \DateTime */
$startDate = clone $loopEntry['start_date'];
$startDate->modify($modification);
$loopEntry['start_date'] = $startDate;

/** @var $endDate \DateTime */
$endDate = clone $loopEntry['end_date'];
$endDate->modify($modification);
$loopEntry['end_date'] = $endDate;
// Time modification
if (str_contains($modification, 'minutes') || str_contains($modification, 'hours')) {
$startTime = new \DateTime('@' . $loopEntry['start_time']);
$startTime->modify($modification);
$loopEntry['start_time'] = $startTime->getTimestamp();

$endTime = new \DateTime('@' . $loopEntry['end_time']);
$endTime->modify($modification);
$loopEntry['end_time'] = $endTime->getTimestamp();
} else {
/** @var $startDate \DateTime */
$startDate = clone $loopEntry['start_date'];
$startDate->modify($modification);
$loopEntry['start_date'] = $startDate;

/** @var $endDate \DateTime */
$endDate = clone $loopEntry['end_date'];
$endDate->modify($modification);
$loopEntry['end_date'] = $endDate;
}

return $loopEntry;
}
Expand Down
1 change: 1 addition & 0 deletions Tests/Functional/Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
<const name="TYPO3_MODE" value="BE" />
<ini name="display_errors" value="1" />
<env name="TYPO3_CONTEXT" value="Testing" />
<env name="typo3DatabaseDriver" value="pdo_sqlite" />
</php>
</phpunit>
Loading

0 comments on commit 31ec3e3

Please sign in to comment.