@@ -22,8 +22,8 @@ namespace {
2222
2323auto TieSettings (const PeriodicTask::Settings& settings) {
2424 // Can't use Boost.Pfr, because Settings has custom constructors.
25- const auto & [f1, f2, f3, f4, f5, f6] = settings;
26- return std::tie (f1, f2, f3, f4, f5, f6);
25+ const auto & [f1, f2, f3, f4, f5, f6, f7 ] = settings;
26+ return std::tie (f1, f2, f3, f4, f5, f6, f7 );
2727}
2828
2929} // namespace
@@ -156,7 +156,21 @@ void PeriodicTask::Run() {
156156 if (!no_exception) period = exception_period;
157157
158158 std::chrono::steady_clock::time_point start;
159- if (settings->flags & Flags::kStrong ) {
159+
160+ if (settings->strong_mode_anchor ) {
161+ const auto now = utils::datetime::WallCoarseClock::now ();
162+ const auto today = std::chrono::time_point_cast<std::chrono::duration<long long , std::ratio<86400 >>>(now);
163+
164+ const auto [hours, minutes] = settings->strong_mode_anchor .value ();
165+ auto anchor_time_point = today + std::chrono::hours (hours) + std::chrono::minutes (minutes);
166+ if (now > anchor_time_point) {
167+ anchor_time_point += std::chrono::hours (24 );
168+ }
169+
170+ start = std::chrono::steady_clock::now ()
171+ + std::chrono::duration_cast<std::chrono::steady_clock::duration>(anchor_time_point - now);
172+ }
173+ else if (settings->flags & Flags::kStrong ) {
160174 start = before;
161175 } else {
162176 start = std::chrono::steady_clock::now ();
0 commit comments