-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bugfix]auto config timezone for Jackson #2197
base: master
Are you sure you want to change the base?
[bugfix]auto config timezone for Jackson #2197
Conversation
…hub.com/cdphantom/hertzbeat into bugfix/auto-config-timezone-for-Jackson
} | ||
LocalTime silentStart = alertSilence.getPeriodStart().toLocalTime(); | ||
LocalTime silentEnd = alertSilence.getPeriodEnd().toLocalTime(); | ||
// 判断是否为静默时间段 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be translated into Chinese.
cc @Calvin979 hi, please help take a review if have time. |
@@ -23,6 +23,7 @@ spring: | |||
static-path-pattern: /** | |||
jackson: | |||
default-property-inclusion: ALWAYS | |||
time-zone: ${TZ:Asia/Shanghai} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due the #2122 support config time-zone in webui, can this be removed? @Calvin979 @cdphantom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due the #2122 support config time-zone in webui, can this be removed? @Calvin979 @cdphantom
Yes, it can be removed. @cdphantom
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@tomsun28 The coding is right. It can apply to cross-day configuration as well. |
What's changed?
Checklist
Add or update API