svvitch
digital signage player
D:/vs_workspace/switch_sf/src/svvitch/Schedule.cpp
Go to the documentation of this file.
00001 #include "Schedule.h"
00002 
00003 #include <Poco/format.h>
00004 
00005 
00006 Schedule::Schedule(const string id, const int year, const int month, const int day, const int hour, const int minute, const int second, const int week, const string command):
00007     _log(Poco::Logger::get("")),
00008     _id(id), _year(year), _month(month), _day(day), _hour(hour), _minute(minute), _second(second), _week(week), _command(command)
00009 {
00010     string time = Poco::format("%02d/%02d/%02d %02d:%02d:%02d", _year, _month, _day, _hour, _minute, _second);
00011     _log.information(Poco::format("schedule %s(%d)->%s", time, _week, _command));
00012 }
00013 
00014 Schedule::‾Schedule() {
00015 }
00016 
00017 bool Schedule::matchDate(LocalDateTime time) {
00018     if (_year >= 0 && _year != time.year()) return false;
00019     if (_month >= 0 && _month != time.month()) return false;
00020     if (_week >= 0 && _week != time.dayOfWeek()) return false;
00021     if (_day >= 0 && _day != time.day()) return false;
00022     return true;
00023 }
00024 
00025 bool Schedule::match(LocalDateTime time) {
00026     if (matchDate(time)) {
00027         if (_hour >= 0 && _hour != time.hour()) return false;
00028         if (_minute >= 0 && _minute != time.minute()) return false;
00029         if (_second >= 0 && _second != time.second()) return false;
00030         return true;
00031     }
00032     return false;
00033 }
00034 
00035 bool Schedule::matchPast(LocalDateTime time) {
00036     if (matchDate(time)) {
00037         if (_hour >= 0 && _hour < time.hour()) return true;
00038         if (_hour >= 0 && _hour > time.hour()) return false;
00039         if (_minute >= 0 && _minute < time.minute()) return true;
00040         if (_minute >= 0 && _minute > time.minute()) return false;
00041         if (_second >= 0 && _second > time.second()) return false;
00042         return true;
00043     }
00044     return false;
00045 }
00046 
00047 const string& Schedule::command() const {
00048     return _command;
00049 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines