#include #include #include #include #include "period.h" period::period(uint16_t start, uint16_t end) { this->start = start; this->end = end; } Json::Value period::to_json() { Json::Value result; char start_str[8], end_str[8]; sprintf(start_str, "%02d:%02d", this->start / 60, this->start % 60); sprintf(end_str, "%02d:%02d", this->end / 60, this->end % 60); result["start"] = std::string(start_str); result["end"] = std::string(end_str); return result; } bool period::is_in_period(uint16_t timestamp) { if(this->start < this->end) { return this->start <= timestamp and timestamp <= this->end; } if(this->start > this->end) { return this->end <= timestamp and timestamp <= this->start; } return this->start == timestamp; }