diff --git a/zhctproject/store/application/p/logic/DishCustomCategory.php b/private/tmp/cdx-store-custom-category-20261010/source/application/p/logic/DishCustomCategory.php index e5cfbc1..3fbff6d 100644 --- a/zhctproject/store/application/p/logic/DishCustomCategory.php +++ b/private/tmp/cdx-store-custom-category-20261010/source/application/p/logic/DishCustomCategory.php @@ -61,11 +61,38 @@ class DishCustomCategory unset($row); return [ - 'rows' => $rows, + 'rows' => self::normalizeListDateTimes($rows, ltrim((string)Config::get('database.type'), '\\') === \app\cores\database\Dm::class), 'total' => (int)$this->categoryModel->where($where)->count(), ]; } + /** This list exposes MySQL DATETIME(0) text; keep other drivers and fields untouched. */ + private static function normalizeListDateTimes(array $rows, bool $isDm): array + { + if (!$isDm) { + return $rows; + } + foreach ($rows as &$row) { + foreach (['create_time', 'update_time'] as $field) { + $value = $row[$field] ?? null; + if (!is_string($value) + || !preg_match('/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\.\d{1,6}$/D', $value, $parts) + ) { + continue; + } + $date = \DateTime::createFromFormat('!Y-m-d H:i:s', $parts[1]); + $errors = \DateTime::getLastErrors(); + if ($date && ($errors === false || ($errors['warning_count'] === 0 && $errors['error_count'] === 0)) + && $date->format('Y-m-d H:i:s') === $parts[1] + ) { + $row[$field] = $parts[1]; + } + } + } + unset($row); + return $rows; + } + public function getOptions(string $usage = 'form', int $includeId = 0): array { $query = $this->categoryModel->where('is_delete', 0);