-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse Carbon objects #235
Parse Carbon objects #235
Conversation
if (! $time instanceof self) { | ||
$time = new static($time, $timezone); | ||
if (! $time instanceof static) { | ||
$time = Date::parse($time, $timezone); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allows Carbon objects to be passed to timespan()
.
@@ -274,8 +283,8 @@ public function timespan($time = null, $timezone = null) | |||
$lang = $this->getTranslator(); | |||
|
|||
// Create Date instance if needed | |||
if (! $time instanceof self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self
seemed inappropriate to me
); | ||
} | ||
|
||
if (! is_int($time)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If $time
is an integer, it's a Unix timestamp. By not sending it through translateTimeString()
, it remains an integer and is then correctly handled in the constructor.
Allows for rapid conversion of plain Carbon objects.
L85 also allows Unix timestamps to be passed to
parse()
.