From: Caisking <3449750381@qq.com> Date: Tue, 3 Sep 2024 02:20:04 +0000 (+0800) Subject: 屏蔽睡眠时间戳为0的数据不做字符串处理 X-Git-Tag: release_V1.2.70_20241020_135402~540^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=4d9ca268dfe4936a006aca2797683dbf8f902b60;p=mirrors%2FFD230.git 屏蔽睡眠时间戳为0的数据不做字符串处理 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp index b86e0e83a..1db41a71f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -536,16 +536,24 @@ namespace OHOS return true; } + // 时间戳->字符串 void SleepModel::update_time_info(uint32_t timestamp, std::string &timeStr) { + // 如果时间戳为0,设置时间字符串为默认值 + if (timestamp == 0) + { + timeStr = "--"; + return; + } + // 解析时间戳 char labelTime[20]; if (uapi_get_TIME_STR(timestamp, labelTime, '.', ':', DATE_H_M) == ERRCODE_SUCC) { - timeStr = std::string(labelTime); + timeStr.assign(labelTime); } else { - timeStr = "--"; + timeStr = "--"; // 如果获取失败,设置为默认值 } }