mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Refactor regex to locale_helper to be used in other parts of the code.
This commit is contained in:
@@ -497,4 +497,8 @@ function dateformat_bootstrap($php_format)
|
||||
return strtr($php_format, $SYMBOLS_MATCHING);
|
||||
}
|
||||
|
||||
?>
|
||||
function valid_datetime($datetime)
|
||||
{
|
||||
return preg_match('/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9])(?:( [0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/', $datetime);
|
||||
}
|
||||
?>
|
||||
@@ -258,7 +258,7 @@ class Attribute extends CI_Model
|
||||
|
||||
foreach($this->db->get()->result_array() as $row)
|
||||
{
|
||||
if(!preg_match('/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9])(?:( [0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/', $row['attribute_value']))
|
||||
if(valid_datetime($row['attribute_value']) === FALSE)
|
||||
{
|
||||
log_message('ERROR', 'item_id: ' . $row['item_id'] . ' with attribute_value: ' . $row['attribute_value'] . ' cannot be converted to datetime');
|
||||
$success = FALSE;
|
||||
|
||||
Reference in New Issue
Block a user