-
Notifications
You must be signed in to change notification settings - Fork 0
/
TIMELOG.CPP
51 lines (37 loc) · 1.02 KB
/
TIMELOG.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
#include <string.h>
#include "proboard.hpp"
void
timelog::read()
{
memset(this,0,sizeof(timelog));
numdays=1;
File f(FN_TIMELOG_PRO);
if(f.opened()) f.read(this,sizeof(timelog));
if(!daysactive) daysactive = numdays;
}
void
timelog::update()
{
memset(this,0,sizeof(timelog));
File f(FN_TIMELOG_PRO,fmode_rw | fmode_excl | fmode_copen);
f.read(this,sizeof(timelog));
if(!daysactive) daysactive = numdays;
if(lastdate!=Date(TODAY))
{
if(cfg.usage_days && numdays>=cfg.usage_days)
{
for(int i=0;i<24;i++) hours[i] -= long(numdays-cfg.usage_days+1)*hours[i]/numdays;
for(i=0;i<7;i++) days [i] -= long(numdays-cfg.usage_days+1)*days [i]/numdays;
numdays = cfg.usage_days;
}
else numdays++;
daysactive++;
lastdate.today();
}
hours[login_time[0]%24]+=timer.online();
days[login_date.weekDay()%7]+=timer.online();
weeks[login_date.weekNum()%53]+=timer.online();
if(io.baud) totalcalls++;
f.rewind();
f.write(this,sizeof(timelog));
}