Add wrapper around MD_STD::strtotime() that will throw an expected

exception
This commit is contained in:
Joshua Ramon Enslin 2024-01-30 01:21:51 +01:00
parent 2bea372973
commit 8c1050f40a
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -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. * Initializes a curl request with the given presets.
* *