解决喝水提醒跨天设置问题
authorluozheng <1732036298@qq.com>
Fri, 19 Jul 2024 06:53:32 +0000 (14:53 +0800)
committerluozheng <1732036298@qq.com>
Fri, 19 Jul 2024 06:53:32 +0000 (14:53 +0800)
code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp

index 2e9a112..c21d3ad 100644 (file)
@@ -72,8 +72,10 @@ extern "C"
 #define SEDENTARY_TIME_RANGE (((curTime.tm_hour > sedentary_start_hour) || (curTime.tm_hour == sedentary_start_hour && curTime.tm_min >= sedentary_start_min)) && \\r
                               ((curTime.tm_hour < sedentary_stop_hour) || (curTime.tm_hour == sedentary_stop_hour && curTime.tm_min < sedentary_stop_min)))\r
 \r
-#define DRINKREMIND_TIME_RANGE (((curTime.tm_hour > drinkreminder_start_hour) || (curTime.tm_hour == drinkreminder_start_hour && curTime.tm_min >= drinkreminder_start_min)) && \\r
-                              ((curTime.tm_hour < drinkreminder_end_hour) || (curTime.tm_hour == drinkreminder_end_hour && curTime.tm_min < drinkreminder_end_min)))\r
+#define DRINKREMIND_TIME_RANGE ((((curTime.tm_hour > drinkreminder_start_hour && curTime.tm_hour < 24) || (curTime.tm_hour == drinkreminder_start_hour && curTime.tm_min >= drinkreminder_start_min)) && \\r
+                                 ((curTime.tm_hour < drinkreminder_end_hour && curTime.tm_hour >= 0) || (curTime.tm_hour == drinkreminder_end_hour && curTime.tm_min < drinkreminder_end_min))) ||       \\r
+                                ((curTime.tm_hour >= 0 && curTime.tm_hour < drinkreminder_end_hour) || (curTime.tm_hour == drinkreminder_end_hour && curTime.tm_min < drinkreminder_end_min)) &&         \\r
+                                    ((curTime.tm_hour > drinkreminder_start_hour - 24 || (curTime.tm_hour == drinkreminder_start_hour - 24 && curTime.tm_min >= drinkreminder_start_min))))\r
 \r
 #define WAKE_TIME_RANGE (((wake_time_hour < sleep_time_hour) &&                                              \\r
                           ((curTime.tm_hour > wake_time_hour) ||                                             \\r
@@ -428,6 +430,7 @@ extern "C"
                 // 判断当前时间是否在提醒时间段内\r
                 if (DRINKREMIND_TIME_RANGE)\r
                 {\r
+                    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " curTime.tm_sec = %d", curTime.tm_sec);\r
                     double interval_time = (drinkreminder_freq == 0) ? 0.5 : drinkreminder_freq;             // 频率设置\r
                     int interval_time_seconds = static_cast<int>(interval_time * 60) * 60;                   // 设置的间隔时间秒数\r
                     int start_time_seconds = (drinkreminder_start_hour * 60 + drinkreminder_start_min) * 60; // 开始时间秒数\r
@@ -439,7 +442,7 @@ extern "C"
                         drinkremind_expectedTime = start_time_seconds + interval_time_seconds;\r
                         if (drinkremind_expectedTime >= hour_24_seconds)\r
                         {\r
-                            drinkremind_expectedTime = hour_24_seconds - drinkremind_expectedTime;\r
+                            drinkremind_expectedTime = drinkremind_expectedTime - hour_24_seconds;\r
                         }\r
                     }\r
                     else\r