#pragma once #include #include using namespace std; class GPUtil { private: //½«µ±Ç°Ê±¼ä»»Ëã³ÉÃë static int getNowSecondTime() { time_t timep; time(&timep); char tmp_h[64]; strftime(tmp_h, sizeof(tmp_h), "%H", localtime(&timep)); char tmp_m[64]; strftime(tmp_m, sizeof(tmp_m), "%M", localtime(&timep)); char tmp_s[64]; strftime(tmp_s, sizeof(tmp_s), "%S", localtime(&timep)); return std::stoi(string(tmp_h)) * 3600 + stoi(string(tmp_m)) * 60 + stoi(string(tmp_s)); }; public: //ÊÇ·ñΪ½»Ò×ʱ¶Î static bool isTradeTime() { int time = getNowSecondTime(); //9:20-11:31 12:59-15:01 bool in = false; if ((time >= 9 * 3600 + 20 * 60 && time <= 11 * 3600 + 31 * 60) || (time >= 12 * 3600 + 59 * 60 && time <= 15 * 3600 + 1 * 60)) { in = true; } return in; }; //ÊÇ·ñΪԤ½»Ò×ʱ¼ä static bool isPreTradeTime() { //9:25-9:31 int time = getNowSecondTime(); bool in = false; if ((time >= 9 * 3600 + 25 * 60 && time < 9 * 3600 + 31 * 60)) { in = true; } return in; } static bool isBeforeTradeTime() { //9:25-9:31 int time = getNowSecondTime(); bool in = false; if (time < 9 * 3600 + 29 * 60) { in = true; } return in; } };