Skip to content

Commit f328a33

Browse files
update
1 parent 14fea42 commit f328a33

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Time.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,18 @@ public function __timeDifference($mode = null)
264264

265265
/**
266266
* Get a greeting based on the current time.
267+
* @param string|int $date
268+
*
267269
* @return string
268270
*/
269-
public function __greeting()
271+
public function __greeting($date = 'now')
270272
{
271-
$now = new DateTime('now', new DateTimeZone($this->timezone));
273+
$dateTime = new DateTime();
274+
$dateTime->setTimestamp(
275+
TimeHelper::setPassedDate($date)
276+
);
277+
278+
$now = new DateTime($dateTime->format('M d Y H:i:s'), new DateTimeZone($this->timezone));
272279
$hour = (int) $now->format('H');
273280
$text = self::getText();
274281

Traits/TimeTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Closure;
88
use Tamedevelopers\Support\Str;
9+
use Tamedevelopers\Support\Time;
910
use Tamedevelopers\Support\Country;
1011
use Tamedevelopers\Support\Capsule\TimeHelper;
1112

@@ -126,7 +127,7 @@ static public function setTimezone($timezone = null)
126127
{
127128
if(!self::isTimeInstance()){
128129
new static(timezone: $timezone);
129-
}
130+
}
130131

131132
// set timezone
132133
self::$staticData->timezone = TimeHelper::setPassedTimezone($timezone);

0 commit comments

Comments
 (0)