tomsun28 commented on code in PR #2197:
URL: https://github.com/apache/hertzbeat/pull/2197#discussion_r1667623317


##########
alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmSilenceReduce.java:
##########
@@ -117,4 +123,27 @@ public boolean filterSilence(Alert alert) {
         }
         return true;
     }
+
+    /**
+     * 是否为静默时间段
+     *
+     * @param silentStart 静默开始时间
+     * @param silentEnd 静默结束时间
+     * @return 是/否
+     */
+    private boolean isSilentPeriod(LocalTime silentStart, LocalTime silentEnd) 
{
+        if (null == silentStart || null == silentEnd) {
+            return false;
+        }
+        LocalTime nowLocalTime = ZonedDateTime.now().toLocalTime();
+        log.info("nowLocalTime:{}, silentStart:{}, silentEnd:{}, 
SystemDefaultTimeZoneId:{}", nowLocalTime, silentStart, silentEnd, 
ZoneId.systemDefault());
+        // 如果静默结束时间小于静默开始时间,意味着静默期跨越了午夜
+        if (silentEnd.isBefore(silentStart)) {
+            // 当前时间在午夜之前且大于等于静默开始时间,或者在午夜之后且小于静默结束时间
+            return nowLocalTime.isAfter(silentStart) || 
nowLocalTime.isBefore(silentEnd);
+        } else {
+            // 当前时间在静默开始和结束时间之间
+            return nowLocalTime.isAfter(silentStart) && 
nowLocalTime.isBefore(silentEnd);

Review Comment:
   hi the code comments need to be in English, and suggest use `log.debug` or 
`trace` instead of `log.info("nowLocalTime` to aviod too many repeated, 
unimportant logs. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to