Skip to content
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

Merged
merged 2 commits into from
Mar 12, 2017
Merged

Parse Carbon objects #235

merged 2 commits into from
Mar 12, 2017

Conversation

Propaganistas
Copy link
Contributor

@Propaganistas Propaganistas commented Feb 4, 2017

Allows for rapid conversion of plain Carbon objects.

$carbon = Carbon::now();
$date = Date::parse($carbon);

L85 also allows Unix timestamps to be passed to parse().

if (! $time instanceof self) {
$time = new static($time, $timezone);
if (! $time instanceof static) {
$time = Date::parse($time, $timezone);
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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)) {
Copy link
Contributor Author

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.

@jenssegers jenssegers merged commit 6a1376e into jenssegers:master Mar 12, 2017
@Propaganistas Propaganistas deleted the parse-carbon branch March 12, 2017 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants