Thread Sekunden in Stunden,Minuten,Sekunden umwandeln (3 answers)
Opened by SirLant at 2004-04-14 03:11

esskar
 2004-04-14 04:05
#10935 #10935
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
hatte da auch noch nur ur-alt-version
hier mal ein ansatz zum ideen holen:
Code: (dl )
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;
}

View full thread Sekunden in Stunden,Minuten,Sekunden umwandeln