Skip to content

Commit 9fa957f

Browse files
committed
Fix up construct time
1 parent d73e186 commit 9fa957f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/I18n/DateTimeHelper.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ public static function constructDate(array $time): string {
2626
*/
2727
public static function constructTime(array $time): string {
2828
$format = '';
29+
$time += [
30+
'minute' => 0,
31+
'second' => 0,
32+
];
33+
2934
if (
30-
isset($time['hour'], $time['minute'], $time['second']) &&
35+
isset($time['hour']) &&
3136
(is_numeric($time['hour']) && is_numeric($time['minute']) && is_numeric($time['second']))
3237
) {
3338
$format = sprintf('%02d:%02d:%02d', $time['hour'], $time['minute'], $time['second']);
@@ -43,9 +48,12 @@ public static function constructTime(array $time): string {
4348
public static function constructDatetime(array $time): string {
4449
$date = static::constructDate($time);
4550
$time = static::constructTime($time);
46-
if (!$date || !$time) {
51+
if (!$date) {
4752
return '';
4853
}
54+
if (!$time) {
55+
return $date . ' 00:00:00';
56+
}
4957

5058
return $date . ' ' . $time;
5159
}

0 commit comments

Comments
 (0)