Add wrapper around MD_STD::strtotime() that will throw an expected
exception
This commit is contained in:
parent
2bea372973
commit
8c1050f40a
@ -303,6 +303,27 @@ final class MD_STD {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around self::strtotime() that will return MDParseException (an expected
|
||||
* exception) rather than MDInvalidInputDate (an unexpected exception).
|
||||
*
|
||||
* @param string $datetime String to convert.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function strtotime_for_public_apis(string $datetime):int {
|
||||
|
||||
try {
|
||||
$output = self::strtotime($datetime);
|
||||
}
|
||||
catch (MDInvalidInputDate $e) {
|
||||
throw new MDParseException($e->getMessage());
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a curl request with the given presets.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user