Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Regression fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreu Correa Casablanca committed Jun 3, 2016
1 parent d3dbffa commit 99cdbf4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/UniversalTimestamp.php
Expand Up @@ -84,10 +84,15 @@ public static function fromDateTimeInterface(\DateTimeInterface $dateTime)
*/
public static function fromStringTimestamp($strTimestamp, $tz = 'UTC')
{
return self::fromDateTimeInterface(new \DateTimeImmutable(
$strTimestamp,
($tz instanceof \DateTimeZone) ? $tz : new \DateTimeZone($tz)
));
try {
$dt = new \DateTimeImmutable(
$strTimestamp,
($tz instanceof \DateTimeZone) ? $tz : new \DateTimeZone($tz)
);
} catch (\Exception $e) {
throw new JiffyException('The provided value cannot be interpreted as a timestamp');
}
return self::fromDateTimeInterface($dt);
}

/**
Expand Down

0 comments on commit 99cdbf4

Please sign in to comment.