#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[6], end[6]; sprintf(start, "%02d:%02d", (int)(this->start / 60), this->start % 60); sprintf(end, "%02d:%02d", (int)(this->end / 60), this->end % 60); result["start"] = std::string(start); result["end"] = std::string(end); 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; }