offpeak_time_info.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (c) Meta Platforms, Inc. and affiliates.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #pragma once
  6. #include <cstdint>
  7. #include <string>
  8. #include "rocksdb/rocksdb_namespace.h"
  9. namespace ROCKSDB_NAMESPACE {
  10. class SystemClock;
  11. struct OffpeakTimeInfo {
  12. bool is_now_offpeak = false;
  13. int seconds_till_next_offpeak_start = 0;
  14. };
  15. struct OffpeakTimeOption {
  16. static constexpr int kSecondsPerDay = 86400;
  17. static constexpr int kSecondsPerHour = 3600;
  18. static constexpr int kSecondsPerMinute = 60;
  19. OffpeakTimeOption();
  20. explicit OffpeakTimeOption(const std::string& offpeak_time_string);
  21. std::string daily_offpeak_time_utc = "";
  22. int daily_offpeak_start_time_utc = 0;
  23. int daily_offpeak_end_time_utc = 0;
  24. void SetFromOffpeakTimeString(const std::string& offpeak_time_string);
  25. OffpeakTimeInfo GetOffpeakTimeInfo(const int64_t& current_time) const;
  26. };
  27. } // namespace ROCKSDB_NAMESPACE