From eccfcaa78e38d3cc9f4417aaf2b759fe9e63039d Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Thu, 11 Jan 2024 16:53:40 +0800 Subject: [PATCH] * Fix generate zero metric record of week. --- module/metric/calc.class.php | 2 +- module/metric/model.php | 1 + module/metric/zen.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/module/metric/calc.class.php b/module/metric/calc.class.php index aeab8ae893..997c32105f 100644 --- a/module/metric/calc.class.php +++ b/module/metric/calc.class.php @@ -297,7 +297,7 @@ class baseCalc if(strlen($dateStr) > 10) $dateStr = substr($dateStr, 0, 10); $date = DateTime::createFromFormat('Y-m-d', $dateStr); - return $date->format('W'); + return substr($date->format('oW'), -2); } /** diff --git a/module/metric/model.php b/module/metric/model.php index eb585077d5..4cce26b098 100755 --- a/module/metric/model.php +++ b/module/metric/model.php @@ -1914,6 +1914,7 @@ class metricModel extends model $month = date('m', $timestamp); $day = date('d', $timestamp); $week = date('oW', $timestamp); + $week = substr($week, -2); $dateValues = new stdClass(); diff --git a/module/metric/zen.php b/module/metric/zen.php index f37a29be52..f788e07678 100644 --- a/module/metric/zen.php +++ b/module/metric/zen.php @@ -179,7 +179,7 @@ class metricZen extends metric */ protected function prepareMetricRecord($calcList) { - $options = array('year' => date('Y'), 'month' => date('n'), 'week' => date('W'), 'day' => date('j')); + $options = array('year' => date('Y'), 'month' => date('n'), 'week' => substr(date('oW'), -2), 'day' => date('j')); $now = helper::now(); $dateValues = $this->metric->generateDateValues($now);