05-22-2014 02:55 AM
05-22-2014 04:12 AM - edited 05-22-2014 04:17 AM
Please be more specific: do you want to convert
In the first case functions in Time Related Functions class in the User Interface Library can be of help, specifically FormatDateTimeString
In the second case you'll have to develop your own function. I have a very simple one I can share if you're interested to.
05-22-2014 04:31 AM
hi
thanks
ya this is what i need
"A interval in seconds in the corresponding h:m:s format (e.g. 63930 sec => 17:45:30)" can share this ?
05-22-2014 04:50 AM
Here it is. As I told you, it is very simple:
//---------------------------------------------------------------------- // Function secToHMSstring () //---------------------------------------------------------------------- /// HIFN secToHMSstring () /// HIFN The function takes an amount of seconds and returns a string with /// HIFN the corresponding value in H:M:S format /// HIPAR sec/Value in seconds to convert /// HIPAR verbose/If True use "hms" separators; if not, use ":" separator /// HIPAR string/The output string. It is responsibility of the programmer /// HIPAR string/that the string is large enough to keep the resulting text /// OUT string void secToHMSstring (int sec, int verbose, char *string) { int hh = 0, mm = 0, ss = 0; if (sec >= 3600) { hh = sec / 3600; sec -= hh * 3600; } if (sec >= 60) mm = sec / 60; ss = sec - mm * 60; strcpy (string, ""); if (verbose) { if (hh > 0) sprintf (string, "%s%dh", string, hh); if (mm > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%dm", string, mm); } if (ss > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%ds", string, ss); } } else { if (hh > 0) sprintf (string, "%s%d:", string, hh); if (mm > 0) { if (strlen (string)) sprintf (string, "%s%02d:", string, mm); else sprintf (string, "%d:", mm); } else if (strlen (string)) strcat (string, "00:"); if (strlen (string)) sprintf (string, "%s%02d", string, ss); else sprintf (string, "%d", ss); } return; }
05-22-2014 07:26 PM
Thanks alots.. 🙂 RobertoBozzolo