-
Notifications
You must be signed in to change notification settings - Fork 0
/
EVENT.CPP
73 lines (49 loc) · 1.11 KB
/
EVENT.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "proboard.hpp"
int
event::minutesleft()
{
Date today(TODAY);
Time now(NOW);
int nowminutes=now[0]*60+now[1];
int min=10080;
if(enabled)
for(int i=0;i<7;i++)
{
int day = today.weekDay()+i;
if(day>6) day-=7;
if(!(days&(1<<day))) continue;
int m=start[0]*60+start[1]+i*60*24;
if((m+duration+1) <= nowminutes)
m += 10080;
m -= nowminutes;
if(m < min)
min = m;
}
return min;
}
int
event::nextday()
{
Date today(TODAY);
Time now(NOW);
int nowminutes=now[0]*60+now[1];
int min=10080;
int retday=0;
if(enabled)
for(int i=0;i<7;i++)
{
int day = today.weekDay()+i;
if(day>6) day -= 7;
if(!(days&(1<<day))) continue;
int m = start[0]*60 + start[1] + i*60*24;
if(m<=nowminutes)
m += 10080;
m -= nowminutes;
if(m<min)
{
min = m;
retday = day;
}
}
return retday;
}