aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/helper/DailyPageHelper.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/helper/DailyPageHelper.php')
-rw-r--r--application/helper/DailyPageHelper.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/application/helper/DailyPageHelper.php b/application/helper/DailyPageHelper.php
index 5fabc907..9bdb7ba5 100644
--- a/application/helper/DailyPageHelper.php
+++ b/application/helper/DailyPageHelper.php
@@ -154,16 +154,20 @@ class DailyPageHelper
154 * Get localized description of the time period depending on given datetime and type. 154 * Get localized description of the time period depending on given datetime and type.
155 * Example: for a month period, it returns `October, 2020`. 155 * Example: for a month period, it returns `October, 2020`.
156 * 156 *
157 * @param string $type month/week/day 157 * @param string $type month/week/day
158 * @param \DateTimeImmutable $requested DateTime extracted from request input 158 * @param \DateTimeImmutable $requested DateTime extracted from request input
159 * (should come from extractRequestedDateTime) 159 * (should come from extractRequestedDateTime)
160 * @param bool $includeRelative Include relative date description (today, yesterday, etc.)
160 * 161 *
161 * @return string Localized time period description 162 * @return string Localized time period description
162 * 163 *
163 * @throws \Exception Type not supported. 164 * @throws \Exception Type not supported.
164 */ 165 */
165 public static function getDescriptionByType(string $type, \DateTimeImmutable $requested): string 166 public static function getDescriptionByType(
166 { 167 string $type,
168 \DateTimeImmutable $requested,
169 bool $includeRelative = true
170 ): string {
167 switch ($type) { 171 switch ($type) {
168 case static::MONTH: 172 case static::MONTH:
169 return $requested->format('F') . ', ' . $requested->format('Y'); 173 return $requested->format('F') . ', ' . $requested->format('Y');
@@ -172,9 +176,9 @@ class DailyPageHelper
172 return t('Week') . ' ' . $requested->format('W') . ' (' . format_date($requested, false) . ')'; 176 return t('Week') . ' ' . $requested->format('W') . ' (' . format_date($requested, false) . ')';
173 case static::DAY: 177 case static::DAY:
174 $out = ''; 178 $out = '';
175 if ($requested->format('Ymd') === date('Ymd')) { 179 if ($includeRelative && $requested->format('Ymd') === date('Ymd')) {
176 $out = t('Today') . ' - '; 180 $out = t('Today') . ' - ';
177 } elseif ($requested->format('Ymd') === date('Ymd', strtotime('-1 days'))) { 181 } elseif ($includeRelative && $requested->format('Ymd') === date('Ymd', strtotime('-1 days'))) {
178 $out = t('Yesterday') . ' - '; 182 $out = t('Yesterday') . ' - ';
179 } 183 }
180 return $out . format_date($requested, false); 184 return $out . format_date($requested, false);