Skip to content

Commit

Permalink
Use setTimestamp instead of @timestamp in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Dec 11, 2015
1 parent 6cdf791 commit 0fac566
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ class Date extends Carbon {
*/
public function __construct($time = null, $timezone = null)
{
// Create Date from timestamp.
if (is_int($time))
{
$time = "@$time";
$timestamp = $time;
$time = null;
}
else
{
$timestamp = null;
}

parent::__construct($time, $timezone);

if ($timestamp !== null)
{
$this->setTimestamp($timestamp);
}
}

/**
Expand Down

0 comments on commit 0fac566

Please sign in to comment.