X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Ftimekeeper.h;fp=src%2Ftimekeeper.h;h=831d643393f3b66f0bd8b47321f22be7c005ac2c;hb=820183c689df1ac8836f05634f0055480a3acb84;hp=0000000000000000000000000000000000000000;hpb=f2bf362b48af28406e3a4cf36deed71e53e0cc03;p=push-it diff --git a/src/timekeeper.h b/src/timekeeper.h new file mode 100644 index 0000000..831d643 --- /dev/null +++ b/src/timekeeper.h @@ -0,0 +1,73 @@ +/* + Copyright (C) <2010> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +#ifndef TIMEKEEPER_H +#define TIMEKEEPER_H +#include +#include +#include +#include + +class timeKeeper +{ +public: + timeKeeper(); + int resetTimes(); + int start(); + int stop(); + int update(); + int pause(); + int isPaused(); + bool enableDateForStrings(); + bool disableDateForStrings(); + bool isDateForStringsEnabled(); + double getDeltaLastToStart(); + double getDeltaLastToPrev(); + double getDeltaNowToStart(); + double getDeltalNowToPrev(); + std::string getStartTimeString(); + std::string getLastTimeString(); + std::string getNowTimeString(); + std::string getPreviousTimeString(); + +private: + double getDelta(struct timeval tvLater, struct timeval tvEarlier); + std::string makeString(time_t timer); + int startPause(); + int stopPause(); + + time_t timeStart; + time_t timeStop; + struct timeval tvStart; + struct timeval tvStop; + + time_t timePrev; + time_t timeLast; + struct timeval tvPrev; + struct timeval tvLast; + + struct timeval tvPauseStart; + struct timeval tvPauseStop; + double pauseTotalTimeSec; + double pauseTimeSec; + + bool isRunning; + bool isPauseActive; + bool wasLastPauseLogged; + bool dateForStrings; +}; + +#endif // TIMEKEEPER_H