76 lines
2.4 KiB
C++
76 lines
2.4 KiB
C++
#include "Test.h"
|
|
#include "Trigger.h"
|
|
#include <Logging.h>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
|
|
namespace Timer {
|
|
namespace Test {
|
|
|
|
std::string print(time_t t)
|
|
{
|
|
std::tm * ptm = std::localtime(&t);
|
|
char buffer[32];
|
|
std::strftime(buffer, 32, "%Y-%m-%d %H:%M:%S", ptm);
|
|
return buffer;
|
|
}
|
|
|
|
bool TestTrigger()
|
|
{
|
|
std::stringstream ss;
|
|
ss << "----------------------------------" << std::endl;
|
|
ss << "| TestTrigger |" << std::endl;
|
|
ss << "----------------------------------" << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
ss.str("");
|
|
auto second = std::chrono::system_clock::to_time_t(Trigger::Second());
|
|
ss << "Second: " << print(second) << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
ss.str("");
|
|
auto minute = std::chrono::system_clock::to_time_t(Trigger::Minute());
|
|
ss << "Minute: " << print(minute) << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
ss.str("");
|
|
auto hour = std::chrono::system_clock::to_time_t(Trigger::Hour());
|
|
ss << "Hour: " << print(hour) << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
ss.str("");
|
|
auto day = std::chrono::system_clock::to_time_t(Trigger::Day());
|
|
ss << "Day: " << print(day) << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
/*
|
|
ss.str("");
|
|
auto target = std::chrono::system_clock::now() - std::chrono::hours(9);
|
|
auto test = std::chrono::system_clock::to_time_t(Trigger::Day(target));
|
|
ss << "Test: " << print(test) << " ( " << print(std::chrono::system_clock::to_time_t(target)) << " )" << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
ss.str("");
|
|
target = std::chrono::system_clock::now() - std::chrono::hours(8);
|
|
test = std::chrono::system_clock::to_time_t(Trigger::Day(target));
|
|
ss << "Test: " << print(test) << " ( " << print(std::chrono::system_clock::to_time_t(target)) << " )" << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
ss.str("");
|
|
target = std::chrono::system_clock::now() - std::chrono::hours(10);
|
|
test = std::chrono::system_clock::to_time_t(Trigger::Day(target));
|
|
ss << "Test: " << print(test) << " ( " << print(std::chrono::system_clock::to_time_t(target)) << " )" << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
*/
|
|
|
|
ss.str("");
|
|
ss << "==================================" << std::endl << std::endl;
|
|
Logging::Log(Logging::Severity::Info, ss.str());
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace Test
|
|
} // namespace Timer
|