Leser: 1
4 Einträge, 1 Seite |
1 2 3 4 5 6 7
$secs = $dauer % 60; $dauer -= $secs; $dauer /= 60; $mins = $dauer % 60; $dauer -= $mins; $dauer /= 60; $hours = $dauer;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
class CUptime { public: CUptime(long time = 0); ~CUptime(void); //Memberfunktionen void setTime (long time); CString getTime (void); protected: int hours; int mins; int secs; }; #include <ctime> CUptime::CUptime(long time /* = 0 */) { setTime (time); } CUptime::~CUptime(void) { } void CUptime::setTime (long time) { secs = time % 60; time -= secs; time /= 60; mins = time % 60; time -= mins; time /= 60; hours = time; } CString CUptime::getTime (void) { CString str; str.Format ("%02d:%02d:%02d", hours, mins, secs); return str; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class CHTime
{
public:
CHTime();
~CHTime();
CHTime operator++(int);
CHTime operator+=(int sec);
void GetAsString(LPSTR lpTime, DWORD cbTime);
void Set(int y, int d, int h, int m, int s);
int GetDay();
int GetYear();
int GetHour();
int GetMinute();
int GetSecond();
int GetAllSeconds();
int GetSecondDifference(CHTime chtime);
private:
int iSec;
int iMin;
int iHour;
int iDay;
int iYear;
};
CHTime CHTime::operator++(int)
{
if(++iSec == 60)
{
iMin++;
iSec = 0;
}
if(iMin == 60)
{
iHour++;
iMin = 0;
}
if(iHour == 24)
{
iDay++;
iHour = 0;
}
if(iDay == 365)
{
iYear++;
iDay = 0;
}
return *this;
}
CHTime CHTime::operator+=(int sec)
{
iSec += sec;
iMin += (iSec / 60); iSec %= 60;
iHour += (iMin / 60); iMin %= 60;
iDay += (iHour / 24); iHour %= 24;
iYear += (iDay / 365); iDay %= 365;
return *this;
}
4 Einträge, 1 Seite |