-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathORDERTIME.cpp
58 lines (46 loc) · 907 Bytes
/
ORDERTIME.cpp
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
56
57
58
#include "OrderTime.h"
int OrderTime::monthDays[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
OrderTime::OrderTime()
{
year = month = day = hour = min = 0;
}
OrderTime::~OrderTime()
{
clear();
}
int OrderTime:: analys(string& str)
{
int i= stoi(str);
const char* p = str.c_str();
for (; *p != '/' && *p != ' '&&*p!=':'; p++);
p++;
string s = p;
str = s;
return i;
}
void OrderTime::set_time(string str)
{
year = analys(str);
month = analys(str);
day = analys(str);
hour = analys(str);
min = analys(str);
//if (!time_right())
//standard_time();
}
int OrderTime::near_time(OrderTime &nOrderTime)const
{
return 0;
}
bool OrderTime::time_right()
{
if (month < 1 || month>13)
return 0;
if (day<1 || day>monthDays[month - 1])
return 0;
if (hour<0 || hour>23)
return 0;
if (min<0 || min>59)
return 0;
return 1;
}