PhoenixLecture  2.0.0
Set of tools to make lectures
ptimetable_updateEndTime.cpp File Reference
+ Include dependency graph for ptimetable_updateEndTime.cpp:

Go to the source code of this file.

Functions

PLatexTime addTime (const PLatexTime &beginTime, const PLatexTime &durationTime)
 Add two PLatexTime together. More...
 
void ptimetable_updateDate (PLatexDate &lastDate, PLatexDate &blockDate)
 Update the date of the block. More...
 
void ptimetable_updateEndTime (PTimeTable &timetable)
 Update the end time of the blocks. More...
 
void ptimetable_updateTime (PLatexTime &lastTime, PLatexTime &blockBegin)
 Update the date of the block. More...
 

Function Documentation

◆ addTime()

PLatexTime addTime ( const PLatexTime beginTime,
const PLatexTime durationTime 
)

Add two PLatexTime together.

Parameters
beginTime: time of the bock begining
durationTime: duration of the block
Returns
sum of two previous PLatexTime

Definition at line 14 of file ptimetable_updateEndTime.cpp.

14  {
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 }
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

References PLatexTime::getHour(), PLatexTime::getMinute(), PLatexTime::setHour(), and PLatexTime::setMinute().

Referenced by ptimetable_updateEndTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ptimetable_updateDate()

void ptimetable_updateDate ( PLatexDate lastDate,
PLatexDate blockDate 
)

Update the date of the block.

Parameters
[out]lastDate: last initialised date
[out]blockDate: date of the block 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

Definition at line 30 of file ptimetable_updateEndTime.cpp.

30  {
31  if(blockDate.getDay() != 0lu || blockDate.getMonth() != 0lu || blockDate.getYear() != 0lu){
32  lastDate = blockDate;
33  }else{
34  blockDate = lastDate;
35  }
36 }
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

References PLatexDate::getDay(), PLatexDate::getMonth(), and PLatexDate::getYear().

Referenced by ptimetable_updateEndTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ptimetable_updateEndTime()

void ptimetable_updateEndTime ( PTimeTable timetable)

Update the end time of the blocks.

Parameters
[out]timetable: PTimeTable to be udpated

Definition at line 54 of file ptimetable_updateEndTime.cpp.

54  {
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 }
Describes a date.
Definition: PTimeTable.h:58
Describe a latex object.
Definition: PLatexObj.h:40
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
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_updateDate(PLatexDate &lastDate, PLatexDate &blockDate)
Update the date of the block.
PLatexTime addTime(const PLatexTime &beginTime, const PLatexTime &durationTime)
Add two PLatexTime together.

References addTime(), PTimeTable::getBeginDate(), PTimeTableBlock::getBeginTime(), PTimeTableBlock::getDate(), PTimeTableBlock::getDuration(), PTimeTable::getLocation(), PTimeTable::getMainUrl(), PTimeTable::getVecBlock(), ptimetable_updateDate(), ptimetable_updateTime(), PTimeTableBlock::setEndTime(), PLatexTime::setHour(), and PLatexTime::setMinute().

Referenced by PConfigParser::parseTimeTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ptimetable_updateTime()

void ptimetable_updateTime ( PLatexTime lastTime,
PLatexTime blockBegin 
)

Update the date of the block.

Parameters
[out]lastDate: last initialised date
[out]blockDate: date of the block 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

Definition at line 43 of file ptimetable_updateEndTime.cpp.

43  {
44  if(blockBegin.getHour() != 0lu || blockBegin.getMinute() != 0lu){
45  lastTime = blockBegin;
46  }else{
47  blockBegin = lastTime;
48  }
49 }

References PLatexTime::getHour(), and PLatexTime::getMinute().

Referenced by ptimetable_updateEndTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: