Conversation
pchalupa
left a comment
There was a problem hiding this comment.
Please check it. I've add some advice, maybe it will be helpfull.
| public static function isTimestamp(string $str): bool | ||
| { | ||
| $ts = \App\Lib\Util\Timestamp::timestampToArray($str); | ||
| if (checkdate($ts['m'], $ts['d'], $ts['y']) && |
There was a problem hiding this comment.
I think you can validate timestamp format by https://www.php.net/manual/en/function.strtotime.php it returns false if format is not valid.
There was a problem hiding this comment.
yes can be, but i dont think i could check for yyyy-mm-ddThh:ii and pass it accordingly, also we'd loose the ability of easy checks for separate values, like:
$ts = \App\Lib\Util\Timestamp::timestampToArray($str);
$hour = $ts['h'];
There was a problem hiding this comment.
It is true, but that is meant that 2021-01-01 will not be treated as valid timestamp despite the fact it can be converted into unix timestamp. Same with passing only time.
|
|
||
| /** | ||
| * Test if string is date | ||
| * |
| * @param string $str | ||
| * @return array<int> | ||
| */ | ||
| public static function timestampToArray(string $str): array |
There was a problem hiding this comment.
Did you check https://www.php.net/manual/en/book.datetime.php? If it has all the features, we can use that class instead.
|
the question is whether to use this format of date, or always turn the date to int a work with the int... |
I need to test it. Body data are always stringified, but when body is parsed, number stirng are overtyped. |
Should test is timestamp is valid
Also function for parsing timestamp to array using standart: y, m, d, h, i, s