Advertisement

06.26.2003 at 02:13PM PDT, ID: 20661389
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

In Seconds

Asked by Dj_Fx8 in Windows MFC Programming

Hi
Is there a simple way to change a a given number of seconds into a formated string ie

float fSeconds = 5528.345     //1h  32m  8s  345mS

and change it into a CString  which will be "01:32:08.345"

Do I have done it like this but I thought there must be an easier way

CString CfvPlayers::SecondsToHMSmS(float fSeconds) const
{
      int nHours = 0;
      int nMins = 0;
      int nSeconds = 0;
      int nMilliSec = 0;
      int nTime = (int)fSeconds;
      //get the milliseconds
      nMilliSec = (int)((fSeconds - nTime) * 1000);
      // get hours
      nHours = nTime / 3600 ;
      //get mins
      nTime = nTime % 3600;
      nMins = nTime / 60;
      //get seconds
      nSeconds = nTime % 60;

      CString szResult, szTemp;
      //format the hours
      szTemp.Format("%d",nHours);
      if (nHours < 10) {szResult = _T("0");}
      szResult += szTemp + _T(":");
      //format mins
      szTemp.Format("%d", nMins);
      if (nMins < 10) {szResult += _T("0");}
      szResult += szTemp + _T(":");
      //format mins
      szTemp.Format("%d", nSeconds);
      if (nSeconds < 10) {szResult += _T("0");}
      szResult += szTemp + _T(".");
      //format milliseconds
      szTemp.Format("%d", nMilliSec);
      if (nMilliSec < 10)      {      return szResult += _T("00") + szTemp;}
      if (nMilliSec < 100) { return szResult += _T("0") + szTemp;}
      return szResult += szTemp;
}
Start Free Trial
[+][-]06.26.2003 at 03:16PM PDT, ID: 8809093

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Windows MFC Programming
Sign Up Now!
Solution Provided By: TheComputerWhisperer
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.26.2003 at 04:00PM PDT, ID: 8809341

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44