Skip to content

Commit

Permalink
Provide more intuitive calendar controls (#152)
Browse files Browse the repository at this point in the history
resolves #113
  • Loading branch information
nilmerg authored Apr 18, 2024
2 parents 73ccbc7 + 39ff2e7 commit 0a3b06c
Show file tree
Hide file tree
Showing 3 changed files with 539 additions and 32 deletions.
6 changes: 3 additions & 3 deletions library/Notifications/Widget/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ protected function getModeStart(): DateTime
{
switch ($this->getControls()->getViewMode()) {
case self::MODE_MONTH:
$month = $this->getControls()->getValue('month') ?: (new DateTime())->format('Y-m');
$month = $this->getControls()->getValue('month') ?: (new DateTime())->format(Controls::MONTH_FORMAT);

return DateTime::createFromFormat('Y-m-d\TH:i:s', $month . '-01T00:00:00');
case self::MODE_WEEK:
$week = $this->getControls()->getValue('week') ?: (new DateTime())->format('Y-\WW');
$week = $this->getControls()->getValue('week') ?: (new DateTime())->format(Controls::WEEK_FORMAT);

return (new DateTime())->setTimestamp(strtotime($week));
default:
$day = $this->getControls()->getValue('day') ?: (new DateTime())->format('Y-m-d');
$day = $this->getControls()->getValue('day') ?: (new DateTime())->format(Controls::DAY_FORMAT);

return DateTime::createFromFormat('Y-m-d H:i:s', $day . ' 00:00:00');
}
Expand Down
Loading

0 comments on commit 0a3b06c

Please sign in to comment.