Prehľad
Nástroje obsahu
Popis
Trieda, ktorá reprezentuje absolútny čas. Čas je reprezentovaný ako počet sekúnd od UTC času 1972-01-01 00:00:00. Pretože absolútny čas v D2000 používa iný počiatok ako je štandardná Unix epocha (1970-01-01 00:00:00 UTC), ktorú používa C++ typ std::time_t, trieda poskytuje jednoduché konverzné funkcie. Pre maximálizáciu výkonu, sú všetky metódy definované inline.
Deklarácia
class D2Time { public: D2Time (const double seconds = 0.0) { this->seconds = seconds; } D2Time (const std::time_t time) { this->seconds = double(time - TimeDifference); } D2Time (const D2Time& time) { this->seconds = time.seconds; } void setSeconds (const double seconds) { this->seconds = seconds; } double getSeconds () const { return this->seconds; } void setTime (const std::time_t time) { this->seconds = double (time - TimeDifference); } std::time_t getTime () const { return std::time_t (this->seconds) + TimeDifference; } static D2Time now () { return D2Time (std::time(NULL)); } private: double seconds; static const std::time_t TimeDifference = (1972 - 1970) * 365 * 24 * 3600; };
Pridať komentár