配速秒数补零避免误解
authorCaisking <Casiking@zhihuishixun.com>
Thu, 5 Feb 2026 12:52:22 +0000 (20:52 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Thu, 5 Feb 2026 12:52:22 +0000 (20:52 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingEnddataView.cpp

index 379033a..c419710 100644 (file)
@@ -14,7 +14,8 @@
 #include "ui_resource_image.h"
 #include "ui_resource_string.h"
 #include "uicomponents/UIComponents.h"
-#include <cmath> // 包含数学函数库,用于四舍五入
+#include <cmath>   // 包含数学函数库,用于四舍五入
+#include <iomanip> // 用于 std::setfill / setw 配速补零
 #include <iostream>
 #include <sstream> // 用于 std::ostringstream
 #include <string>  // 包含字符串处理库,用于使用 std::to_string
@@ -676,15 +677,13 @@ void TraingEnddataView::InitData() {
 
   //特殊配置
   if (TraingModel::GetInstance()->GetIsSpecial()) {
-    // 平均配速
-    // 需要计算一下 是秒 需要显示 分钟''秒''
-    int totalSeconds = enddata->apc; // 总秒数
-    int minutes = totalSeconds / 60; // 计算分钟
-    int seconds = totalSeconds % 60; // 计算剩余秒数
-    // 格式化为字符串
+    // 平均配速:显示为 分钟'秒"(如 5'05"),秒数补零避免误解
+    int totalSeconds = enddata->apc;  // 总秒数(秒/公里)
+    int minutes = totalSeconds / 60;
+    int seconds = totalSeconds % 60;
     std::ostringstream oss;
-    oss << minutes << "'" << seconds << "\""; // 生成 "X'Y\"" 格式的字符串
-    std::string avpaceStr = oss.str();        // 得到字符串
+    oss << minutes << "'" << std::setfill('0') << std::setw(2) << seconds << "\"";
+    std::string avpaceStr = oss.str();
     if (labelavpace)                          // 检查标签是否为空
     {
       labelavpace->SetText(avpaceStr.c_str());