Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help!!!!!!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
What i have is a Text ie(schedule.txt) look like one below.

6.00 my game
8.00 your game
9.30 his game
12.45 our game
1.00 my game
1.50 his game
.
.
.
11.55 our game
1.00 my game
and so on....

can someone please help me with some code that will convert the time into 24 hour clock. please, would appreciate any help as i am beginner in c++.
 
first you need to signify wether or not it is am or pm if using 12 hour time. if pm add 12 to time. If time == 24 time = 0

Matt
 
Thanks for replying Zyrenthian, but i didn't get what you were tyring to say here, could be because of the way i have asked my question. I have written a short program with txt files as above, and the only i am unable to write code is for converting the time into 24 hour clock.
ie. code for converting time in by question before, to give me the result as below.

6.00 my game
8.00 your game
9.30 his game
12.45 our game
13.00 my game
13.50 his game
.
.
.
23.55 our game
1.00 my game
and so on....

all i want is a sort code that will do the above so that i don't have to do it manually, please help....

thanks in advance.
 
convertTime(float *tm, int count)
{
int nAmPmFlag = 0;
float nTmpTime = 0.0;
for (int i =0 ; i< count; i++){
if (tm < nTmpTime){
if (!nAmPmFlag) nAmPmFlag = 1;
else nAmPmFlag = 0;
}
nTmpTime = tm;
if (nAmPmFlag)tm +=12.0;
}
}

tm is an array to store the origial time, when this function finished it contains the converted time. nAmPmFlag is a flag to indicate if it is AM or PM.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top