Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #38 from archdevil666pl/master
Browse files Browse the repository at this point in the history
More DateTime test fixes
  • Loading branch information
arius86 committed Jan 5, 2015
2 parents 9673a18 + a2030ac commit 15d867a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Util/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace Vegas\Util;

use Vegas\Exception;

class DateTime extends \DateTime implements \JsonSerializable
{
/**
Expand All @@ -26,6 +28,19 @@ class DateTime extends \DateTime implements \JsonSerializable
*/
private $defaultFormat;

/**
* @param string $time
* @param \DateTimeZone $timezone
* @throws Exception
*/
public function __construct($time = 'now', \DateTimeZone $timezone = null)
{
if (is_numeric($time)) {
throw new Exception('Invalid date format provided for DateTime: missing `@` prefix.');
}
return parent::__construct($time, $timezone);
}

/**
* Prints the object as string using default format available.
* @return string
Expand Down

0 comments on commit 15d867a

Please sign in to comment.