refactor announce

This commit is contained in:
xiaomlove
2022-03-17 18:46:49 +08:00
parent 3ad8fabe7b
commit 6665c98169
16 changed files with 1486 additions and 27 deletions
+16
View File
@@ -21,4 +21,20 @@ class NexusModel extends Model
return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
}
/**
* Check is valid date string
*
* @see https://stackoverflow.com/questions/19271381/correctly-determine-if-date-string-is-a-valid-date-in-that-format
* @param $name
* @param string $format
* @return bool
*/
public function isValidDate($name, $format = 'Y-m-d H:i:s'): bool
{
$date = $this->getRawOriginal($name);
$d = \DateTime::createFromFormat($format, $date);
// The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
return $d && $d->format($format) === $date;
}
}