-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from thecodingmachine/create-pull-request/reg…
…enerate-files Automatically regenerate the files
- Loading branch information
Showing
5 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
namespace Safe\Exceptions; | ||
|
||
class CalendarException extends \ErrorException implements SafeExceptionInterface | ||
{ | ||
public static function createFromPhpError(): self | ||
{ | ||
$error = error_get_last(); | ||
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Safe; | ||
|
||
use Safe\Exceptions\CalendarException; | ||
|
||
/** | ||
* This function will return a Unix timestamp corresponding to the | ||
* Julian Day given in jday or FALSE if | ||
* jday is outside of the allowed range. The time returned is | ||
* UTC. | ||
* | ||
* @param int $jday A julian day number between 2440588 and 106751993607888 | ||
* on 64bit systems, or between 2440588 and 2465443 on 32bit systems. | ||
* @return int The unix timestamp for the start (midnight, not noon) of the given Julian day. | ||
* @throws CalendarException | ||
* | ||
*/ | ||
function jdtounix(int $jday): int | ||
{ | ||
error_clear_last(); | ||
$result = \jdtounix($jday); | ||
if ($result === false) { | ||
throw CalendarException::createFromPhpError(); | ||
} | ||
return $result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters