PhoenixLecture  2.0.0
Set of tools to make lectures
ptimetable_updateEndTime.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
8 
10 
14 PLatexTime addTime(const PLatexTime & beginTime, const PLatexTime & durationTime){
15  PLatexTime res;
16  res.setMinute(beginTime.getMinute() + durationTime.getMinute());
17  res.setHour(beginTime.getHour() + durationTime.getHour());
18  if(res.getMinute() >= 60lu){
19  res.getHour() += res.getMinute()/60lu;
20  res.setMinute(res.getMinute() % 60lu);
21  }
22  return res;
23 }
24 
26 
30 void ptimetable_updateDate(PLatexDate & lastDate, PLatexDate & blockDate){
31  if(blockDate.getDay() != 0lu || blockDate.getMonth() != 0lu || blockDate.getYear() != 0lu){
32  lastDate = blockDate;
33  }else{
34  blockDate = lastDate;
35  }
36 }
37 
39 
43 void ptimetable_updateTime(PLatexTime & lastTime, PLatexTime & blockBegin){
44  if(blockBegin.getHour() != 0lu || blockBegin.getMinute() != 0lu){
45  lastTime = blockBegin;
46  }else{
47  blockBegin = lastTime;
48  }
49 }
50 
52 
55  std::vector<PTimeTableBlock> & vecBlock = timetable.getVecBlock();
56  if(vecBlock.size() == 0lu){return;} //Nothing to do
57  PLatexObj defaultLocation = timetable.getLocation();
58  PString mainUrl(timetable.getMainUrl());
59  PLatexDate lastDate = timetable.getBeginDate();
60  PLatexTime lastTime;
61  lastTime.setHour(0lu);
62  lastTime.setMinute(0lu);
63  for(std::vector<PTimeTableBlock>::iterator it(vecBlock.begin()); it != vecBlock.end(); ++it){
64  PTimeTableBlock & block = *it;
65  ptimetable_updateTime(lastTime, block.getBeginTime());
66  lastTime = addTime(block.getBeginTime(), block.getDuration());
67  block.setEndTime(lastTime);
68  ptimetable_updateDate(lastDate, block.getDate());
69  if(it->getLocation().getVecContent().size() == 0lu){
70  it->setLocation(defaultLocation);
71  }
72  if(it->getMainUrl() == ""){
73  it->setMainUrl(mainUrl);
74  }
75  }
76 }
77 
78 
Describes a date.
Definition: PTimeTable.h:58
size_t getMonth() const
Gets the month of the PLatexDate.
Definition: PTimeTable.cpp:245
size_t getYear() const
Gets the year of the PLatexDate.
Definition: PTimeTable.cpp:231
size_t getDay() const
Gets the day of the PLatexDate.
Definition: PTimeTable.cpp:259
Describe a latex object.
Definition: PLatexObj.h:40
Describes a date.
Definition: PTimeTable.h:86
size_t getMinute() const
Gets the minute of the PLatexTime.
Definition: PTimeTable.cpp:343
void setMinute(size_t minute)
Sets the minute of the PLatexTime.
Definition: PTimeTable.cpp:322
void setHour(size_t hour)
Sets the hour of the PLatexTime.
Definition: PTimeTable.cpp:315
size_t getHour() const
Gets the hour of the PLatexTime.
Definition: PTimeTable.cpp:329
Extends the std::string.
Definition: PString.h:16
Block of a Timetable.
Definition: PTimeTable.h:109
const PLatexDate & getDate() const
Gets the date of the PTimeTableBlock.
Definition: PTimeTable.cpp:586
void setEndTime(const PLatexTime &endTime)
Sets the endTime of the PTimeTableBlock.
Definition: PTimeTable.cpp:453
const PLatexTime & getBeginTime() const
Gets the beginTime of the PTimeTableBlock.
Definition: PTimeTable.cpp:600
const PLatexTime & getDuration() const
Gets the duration of the PTimeTableBlock.
Definition: PTimeTable.cpp:628
Timetable.
Definition: PTimeTable.h:197
const PLatexDate & getBeginDate() const
Gets the beginDate of the PTimeTable.
Definition: PTimeTable.cpp:873
const PLatexObj & getLocation() const
Gets the location of the PTimeTable.
Definition: PTimeTable.cpp:915
const std::vector< PTimeTableBlock > & getVecBlock() const
Gets the vecBlock of the PTimeTable.
Definition: PTimeTable.cpp:929
const PString & getMainUrl() const
Gets the mainUrl of the PTimeTable.
Definition: PTimeTable.cpp:831
void ptimetable_updateTime(PLatexTime &lastTime, PLatexTime &blockBegin)
Update the date of the block.
void ptimetable_updateEndTime(PTimeTable &timetable)
Update the end time of the blocks.
void ptimetable_updateDate(PLatexDate &lastDate, PLatexDate &blockDate)
Update the date of the block.
PLatexTime addTime(const PLatexTime &beginTime, const PLatexTime &durationTime)
Add two PLatexTime together.