#include <datetime.h>
Collaboration diagram for Wt::Time:
Public Member Functions | |
Time () | |
Time (int h, int m, int s=0, int ms=0) | |
bool | isNull () const |
bool | isValid () const |
int | hour () const |
int | minute () const |
int | second () const |
int | msec () const |
operator std::string () const | |
std::string | toString () const |
bool | setHMS (int h, int m, int s, int ms=0) |
Time | addSecs (int nsecs) const |
int | secsTo (const Time &t) const |
Time | addMSecs (int ms) const |
int | msecsTo (const Time &t) const |
bool | operator== (const Time &t) const |
bool | operator!= (const Time &t) const |
bool | operator< (const Time &t) const |
bool | operator<= (const Time &t) const |
bool | operator> (const Time &t) const |
bool | operator>= (const Time &t) const |
void | start () |
int | restart () |
int | elapsed () const |
Static Public Member Functions | |
static Time | currentTime () |
static Time | fromString (const std::string &s) |
static bool | isValid (int h, int m, int s, int ms=0) |
Private Member Functions | |
int | add_and_wrap (int &start, int duration, int range) const |
Private Attributes | |
int | hour_ |
int | minute_ |
int | second_ |
int | msec_ |
Definition at line 29 of file datetime.h.
Wt::Time::Time | ( | ) |
Definition at line 75 of file datetime.cpp.
References start().
Referenced by addMSecs(), and addSecs().
00075 { 00076 start += duration; 00077 int p = start % range; 00078 int wrap = (start != p) ? 1 : 0; 00079 start = p; 00080 return wrap; 00081 }
Here is the call graph for this function:
Definition at line 103 of file datetime.cpp.
References add_and_wrap(), hour_, minute_, msec_, and second_.
Referenced by currentTime().
00103 { 00104 int nh = ms / 3600000; 00105 int nm = (ms - nh * 3600000) / 60000; 00106 int ns = (ms - nh * 3600000 - nm * 60000) / 1000; 00107 int nms = (ms - nh * 3600000 - nm * 60000 - ns * 1000); 00108 00109 Time t = *this; 00110 int wrap; 00111 wrap = add_and_wrap(t.msec_, nms, 1000); 00112 wrap = add_and_wrap(t.second_, ns + wrap, 60); 00113 wrap = add_and_wrap(t.minute_, nm + wrap, 60); 00114 wrap = add_and_wrap(t.hour_, nh + wrap, 24); 00115 return t; 00116 }
Here is the call graph for this function:
Definition at line 83 of file datetime.cpp.
References add_and_wrap(), hour_, minute_, and second_.
00083 { 00084 int nh = nsecs / 3600; 00085 int nm = (nsecs - nh * 3600) / 60; 00086 int ns = (nsecs - nh * 3600 - nm * 60); 00087 00088 Time t = *this; 00089 int wrap; 00090 wrap = add_and_wrap(t.second_, ns, 60); 00091 wrap = add_and_wrap(t.minute_, nm + wrap, 60); 00092 wrap = add_and_wrap(t.hour_, nh + wrap, 24); 00093 return t; 00094 }
Here is the call graph for this function:
Time Wt::Time::currentTime | ( | ) | [static] |
Definition at line 204 of file datetime.cpp.
References addMSecs(), and trace.
Referenced by elapsed(), restart(), and start().
00204 { 00205 Time t; 00206 Uint32 ticks = SDL_GetTicks(); 00207 trace("time", "Ticks %u\n", ticks); 00208 return t.addMSecs(ticks); 00209 }
Here is the call graph for this function:
int Wt::Time::elapsed | ( | ) | const |
Definition at line 198 of file datetime.cpp.
References currentTime(), and msecsTo().
Referenced by Wt::TimerBlock::operator()().
00198 { 00199 Time t = currentTime(); 00200 int ms = msecsTo(t); 00201 return ms; 00202 }
Here is the call graph for this function:
Time Wt::Time::fromString | ( | const std::string & | s | ) | [static] |
Definition at line 211 of file datetime.cpp.
References Time().
00211 { 00212 std::istringstream iss(timedesctiption); 00213 std::string h, m, s, ms; 00214 std::getline(iss, h, ':'); 00215 std::getline(iss, m, ':'); 00216 std::getline(iss, s, '.'); 00217 std::getline(iss, ms, ' '); 00218 00219 return Time(atoi(h.c_str()), atoi(m.c_str()), 00220 atoi(s.c_str()), atoi(ms.c_str())); 00221 }
Here is the call graph for this function:
int Wt::Time::hour | ( | ) | const [inline] |
bool Wt::Time::isNull | ( | ) | const |
Definition at line 223 of file datetime.cpp.
References isValid().
00223 { 00224 Time t(h, m, s, ms); 00225 return t.isValid(); 00226 }
Here is the call graph for this function:
bool Wt::Time::isValid | ( | ) | const |
Definition at line 47 of file datetime.cpp.
References hour_, minute_, msec_, and second_.
Referenced by isValid(), and setHMS().
00047 { 00048 return (0 <= hour_ && hour_ <= 23 && 00049 0 <= minute_ && minute_ <= 59 && 00050 0 <= second_ && second_ <= 59 && 00051 0 <= msec_ && msec_ <= 999); 00052 }
int Wt::Time::minute | ( | ) | const [inline] |
int Wt::Time::msec | ( | ) | const [inline] |
Definition at line 118 of file datetime.cpp.
References msec_, and secsTo().
Referenced by elapsed(), Wt::SDLInput::EventInfo::operator==(), and restart().
Here is the call graph for this function:
Wt::Time::operator std::string | ( | ) | const |
Definition at line 54 of file datetime.cpp.
References hour_, minute_, msec_, and second_.
00054 { 00055 std::stringstream s; 00056 s << std::setw(2) << std::setfill('0') << hour_ << ":" 00057 << std::setw(2) << std::setfill('0') << minute_ << ":" 00058 << std::setw(2) << std::setfill('0') << second_ << "." 00059 << std::setw(3) << std::setfill('0') << msec_; 00060 return s.str(); 00061 }
bool Wt::Time::operator!= | ( | const Time & | t | ) | const |
bool Wt::Time::operator< | ( | const Time & | t | ) | const |
Definition at line 131 of file datetime.cpp.
References hour_, minute_, msec_, and second_.
00131 { 00132 if (hour_ < t.hour_) 00133 return true; 00134 if (hour_ > t.hour_) 00135 return false; 00136 00137 if (minute_ < t.minute_) 00138 return true; 00139 if (minute_ > t.minute_) 00140 return false; 00141 00142 if (second_ < t.second_) 00143 return true; 00144 if (second_ > t.second_) 00145 return false; 00146 00147 if (msec_ < t.msec_) 00148 return true; 00149 if (msec_ > t.msec_) 00150 return false; 00151 00152 return false; 00153 }
bool Wt::Time::operator<= | ( | const Time & | t | ) | const |
bool Wt::Time::operator== | ( | const Time & | t | ) | const |
bool Wt::Time::operator> | ( | const Time & | t | ) | const |
Definition at line 159 of file datetime.cpp.
References hour_, minute_, msec_, and second_.
00159 { 00160 if (hour_ > t.hour_) 00161 return true; 00162 if (hour_ < t.hour_) 00163 return false; 00164 00165 if (minute_ > t.minute_) 00166 return true; 00167 if (minute_ < t.minute_) 00168 return false; 00169 00170 if (second_ > t.second_) 00171 return true; 00172 if (second_ < t.second_) 00173 return false; 00174 00175 if (msec_ > t.msec_) 00176 return true; 00177 if (msec_ < t.msec_) 00178 return false; 00179 00180 return false; 00181 }
bool Wt::Time::operator>= | ( | const Time & | t | ) | const |
int Wt::Time::restart | ( | ) |
Definition at line 191 of file datetime.cpp.
References currentTime(), and msecsTo().
00191 { 00192 const Time& t = currentTime(); 00193 int ms = msecsTo(t); 00194 *this = t; 00195 return ms; 00196 }
Here is the call graph for this function:
int Wt::Time::second | ( | ) | const [inline] |
void Wt::Time::start | ( | ) |
Definition at line 187 of file datetime.cpp.
References currentTime().
Referenced by add_and_wrap(), Wt::SDLInput::EventInfo::EventInfo(), and Wt::TimerBlock::TimerBlock().
00187 { 00188 *this = currentTime(); 00189 }
Here is the call graph for this function:
std::string Wt::Time::toString | ( | ) | const |
int Wt::Time::hour_ [private] |
Definition at line 70 of file datetime.h.
Referenced by addMSecs(), addSecs(), hour(), isNull(), isValid(), operator std::string(), operator<(), operator==(), operator>(), secsTo(), and setHMS().
int Wt::Time::minute_ [private] |
Definition at line 71 of file datetime.h.
Referenced by addMSecs(), addSecs(), isNull(), isValid(), minute(), operator std::string(), operator<(), operator==(), operator>(), secsTo(), and setHMS().
int Wt::Time::msec_ [private] |
Definition at line 73 of file datetime.h.
Referenced by addMSecs(), isNull(), isValid(), msec(), msecsTo(), operator std::string(), operator<(), operator==(), operator>(), and setHMS().
int Wt::Time::second_ [private] |
Definition at line 72 of file datetime.h.
Referenced by addMSecs(), addSecs(), isNull(), isValid(), operator std::string(), operator<(), operator==(), operator>(), second(), secsTo(), and setHMS().
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.