admin
2023-03-07 8b06b1cbf112d55307ea8a6efe711db4e7506d89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <ctime>
#include <string>
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;
    }
 
 
};