修改650表盘时间获取错误
authorCaisking <Casiking@zhihuishixun.com>
Sat, 5 Jul 2025 08:59:23 +0000 (16:59 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Sat, 5 Jul 2025 08:59:23 +0000 (16:59 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTime.cpp

index 26a7b6f..a08366b 100644 (file)
@@ -11,6 +11,7 @@
 #include "DialModelTime.h"
 #include "components/root_view.h"
 #include "custom_runtime.h"
+
 #define REGIST_DIAL_MODULE_ANGLE_H(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_H)(type, func)
 #define REGIST_DIAL_MODULE_ANGLE_M(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_M)(type, func)
 #define REGIST_DIAL_MODULE_ANGLE_S(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_S)(type, func)
@@ -86,6 +87,12 @@ void DialModelTime::UpdateTime()
     localtime_s(tblock_, &time);
 #else
     tblock_ = localtime(&tv.tv_sec);
+    //需要判断显示的格式
+    if (uapi_dev_runtime_get_time_hour_show_model() ==  12)
+    {
+        if (tblock_->tm_hour > 12)
+            tblock_->tm_hour = tblock_->tm_hour - 12 ;
+    }
 #endif
     int realMS = tblock_->tm_sec * S_MS_US_TRANS + tv.tv_usec / S_MS_US_TRANS;
 
@@ -154,10 +161,10 @@ bool DialModelTime::GetDialFloatData(DialDataType& type, float& out)
             out = static_cast<float>(angleMS_);
             break;
         case OHOS::DialDataType::SOLAR_YEAR:
-            out = static_cast<float>(tblock_->tm_year);
+            out = static_cast<float>(tblock_->tm_year + 1900);
             break;
         case OHOS::DialDataType::MONTH:
-            out = static_cast<float>(tblock_->tm_mon);
+            out = static_cast<float>(tblock_->tm_mon + 1);
             break;
         case OHOS::DialDataType::WEEKDAY_DATA:
             out = static_cast<float>(tblock_->tm_wday);