From 0813cad89e870fbf9e27c4d1293b188b2209ade6 Mon Sep 17 00:00:00 2001 From: Cleiton Perin Date: Tue, 30 Apr 2024 13:57:58 -0300 Subject: [PATCH] =?UTF-8?q?No=20commit=20do=20Sr.=20Giovani=20Paseto=20foi?= =?UTF-8?q?=20comentado=20o=20conteudo=20da=20funcao=20'toTimestamp'.=20Fo?= =?UTF-8?q?i=20revertido=20essa=20altera=C3=A7=C3=A3o,=20pois=20n=C3=A3o?= =?UTF-8?q?=20formata=20mais=20as=20datas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Legacy/Common.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Legacy/Common.php b/src/Legacy/Common.php index e6706cfe..aaed1271 100644 --- a/src/Legacy/Common.php +++ b/src/Legacy/Common.php @@ -106,16 +106,16 @@ protected function ymdTodmy($data = '') */ public function toTimestamp($input) { -// $regex = '^(2[0-9][0-9][0-9])[-](0?[1-9]' -// . '|1[0-2])[-](0?[1-9]' -// . '|[12][0-9]' -// . '|3[01])T(0[0-9]' -// . '|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]-(01|02|03|04|05):00$'; -// -// if (!preg_match("/$regex/", $input)) { -// return 0; -// } -// return \DateTime::createFromFormat("Y-m-d\TH:i:sP", $input)->getTimestamp(); + $regex = '^(2[0-9][0-9][0-9])[-](0?[1-9]' + . '|1[0-2])[-](0?[1-9]' + . '|[12][0-9]' + . '|3[01])T(0[0-9]' + . '|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]-(01|02|03|04|05):00$'; + + if (!preg_match("/$regex/", $input)) { + return 0; + } + return \DateTime::createFromFormat("Y-m-d\TH:i:sP", $input)->getTimestamp(); } /**