Directory: | ./ |
---|---|
File: | tmp_project/PhoenixTex2Html/src/PTimeTable/ptimetable_updateEndTime.cpp |
Date: | 2025-03-24 18:12:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 38 | 38 | 100.0% |
Branches: | 54 | 59 | 91.5% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "ptimetable_updateEndTime.h" | ||
8 | |||
9 | ///Add two PLatexTime together | ||
10 | /** @param beginTime : time of the bock begining | ||
11 | * @param durationTime : duration of the block | ||
12 | * @return sum of two previous PLatexTime | ||
13 | */ | ||
14 | 277 | PLatexTime addTime(const PLatexTime & beginTime, const PLatexTime & durationTime){ | |
15 | 277 | PLatexTime res; | |
16 |
3/3✓ Branch 1 taken 277 times.
✓ Branch 4 taken 277 times.
✓ Branch 7 taken 277 times.
|
277 | res.setMinute(beginTime.getMinute() + durationTime.getMinute()); |
17 |
3/3✓ Branch 1 taken 277 times.
✓ Branch 4 taken 277 times.
✓ Branch 7 taken 277 times.
|
277 | res.setHour(beginTime.getHour() + durationTime.getHour()); |
18 |
3/3✓ Branch 1 taken 277 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 202 times.
|
277 | if(res.getMinute() >= 60lu){ |
19 |
2/2✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
|
75 | res.getHour() += res.getMinute()/60lu; |
20 |
2/2✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
|
75 | res.setMinute(res.getMinute() % 60lu); |
21 | } | ||
22 | 277 | return res; | |
23 | } | ||
24 | |||
25 | ///Update the date of the block | ||
26 | /** @param[out] lastDate : last initialised date | ||
27 | * @param[out] blockDate : date of the block | ||
28 | * This function will update the lastDate with the blockDate if the blockDate is set and update the blockDate with the lastDate if the lastDate is set | ||
29 | */ | ||
30 | 277 | void ptimetable_updateDate(PLatexDate & lastDate, PLatexDate & blockDate){ | |
31 |
6/8✓ Branch 1 taken 226 times.
✓ Branch 2 taken 51 times.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 226 times.
✓ Branch 9 taken 51 times.
✓ Branch 10 taken 226 times.
|
277 | if(blockDate.getDay() != 0lu || blockDate.getMonth() != 0lu || blockDate.getYear() != 0lu){ |
32 | 51 | lastDate = blockDate; | |
33 | }else{ | ||
34 | 226 | blockDate = lastDate; | |
35 | } | ||
36 | 277 | } | |
37 | |||
38 | ///Update the date of the block | ||
39 | /** @param[out] lastDate : last initialised date | ||
40 | * @param[out] blockDate : date of the block | ||
41 | * This function will update the lastDate with the blockDate if the blockDate is set and update the blockDate with the lastDate if the lastDate is set | ||
42 | */ | ||
43 | 277 | void ptimetable_updateTime(PLatexTime & lastTime, PLatexTime & blockBegin){ | |
44 |
5/6✓ Branch 1 taken 220 times.
✓ Branch 2 taken 57 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 220 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 220 times.
|
277 | if(blockBegin.getHour() != 0lu || blockBegin.getMinute() != 0lu){ |
45 | 57 | lastTime = blockBegin; | |
46 | }else{ | ||
47 | 220 | blockBegin = lastTime; | |
48 | } | ||
49 | 277 | } | |
50 | |||
51 | ///Update the end time of the blocks | ||
52 | /** @param[out] timetable : PTimeTable to be udpated | ||
53 | */ | ||
54 | 4 | void ptimetable_updateEndTime(PTimeTable & timetable){ | |
55 |
1/1✓ Branch 1 taken 4 times.
|
4 | std::vector<PTimeTableBlock> & vecBlock = timetable.getVecBlock(); |
56 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if(vecBlock.size() == 0lu){return;} //Nothing to do |
57 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | PLatexObj defaultLocation = timetable.getLocation(); |
58 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | PString mainUrl(timetable.getMainUrl()); |
59 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | PLatexDate lastDate = timetable.getBeginDate(); |
60 |
1/1✓ Branch 1 taken 4 times.
|
4 | PLatexTime lastTime; |
61 |
1/1✓ Branch 1 taken 4 times.
|
4 | lastTime.setHour(0lu); |
62 |
1/1✓ Branch 1 taken 4 times.
|
4 | lastTime.setMinute(0lu); |
63 |
2/2✓ Branch 4 taken 277 times.
✓ Branch 5 taken 4 times.
|
281 | for(std::vector<PTimeTableBlock>::iterator it(vecBlock.begin()); it != vecBlock.end(); ++it){ |
64 | 277 | PTimeTableBlock & block = *it; | |
65 |
2/2✓ Branch 1 taken 277 times.
✓ Branch 4 taken 277 times.
|
277 | ptimetable_updateTime(lastTime, block.getBeginTime()); |
66 |
4/4✓ Branch 1 taken 277 times.
✓ Branch 4 taken 277 times.
✓ Branch 7 taken 277 times.
✓ Branch 10 taken 277 times.
|
277 | lastTime = addTime(block.getBeginTime(), block.getDuration()); |
67 |
1/1✓ Branch 1 taken 277 times.
|
277 | block.setEndTime(lastTime); |
68 |
2/2✓ Branch 1 taken 277 times.
✓ Branch 4 taken 277 times.
|
277 | ptimetable_updateDate(lastDate, block.getDate()); |
69 |
4/4✓ Branch 2 taken 277 times.
✓ Branch 5 taken 277 times.
✓ Branch 8 taken 184 times.
✓ Branch 9 taken 93 times.
|
277 | if(it->getLocation().getVecContent().size() == 0lu){ |
70 |
1/1✓ Branch 2 taken 184 times.
|
184 | it->setLocation(defaultLocation); |
71 | } | ||
72 |
2/3✓ Branch 2 taken 277 times.
✓ Branch 5 taken 277 times.
✗ Branch 6 not taken.
|
277 | if(it->getMainUrl() == ""){ |
73 |
1/1✓ Branch 2 taken 277 times.
|
277 | it->setMainUrl(mainUrl); |
74 | } | ||
75 | } | ||
76 | 4 | } | |
77 | |||
78 | |||
79 |