There is no built-in function that does it but this is easy to obtain:
1. Divide number of seconds by 3600.0: integer part is hours
2. Divide the rest of the operation by 60.0: integer part is minutes
3. The rest of the division is seconds.
In code:
double tt, hh, mm, ss;
tt = 17257.0;
DebugPrintf ("%.0f seconds are equivalent to ", tt);
modf (tt / 3600.0, &hh);
tt = fmod (tt, 3600.0);
modf (tt / 60.0, &mm);
ss = fmod (tt, 60.0);
DebugPrintf ("%.0fh %.0fm %.0fs\n", hh, mm, ss);
If on the contrary your seconds are time from midnight and you want to obtain the clock corresponding to this, you can rely on some SDK functions to obtain it.
1. Divide your seconds by 86400.0 (seconds in a day)
2. Pass the result to VariantTimeToSystemTime: it will return a SYSTEMTIME structure
3. wHour, wMinute and wSecond fields of the structure are what you want
Again, in code:
#include <windows.h>
#include <oleauto.h>
int err;
double tt, secs;
SYSTEMTIME dh;
secs = 17257.0;
tt = secs / 86400.0;
err = VariantTimeToSystemTime (tt, &dh);
DebugPrintf ("%.0f seconds are equivalent to %.0fh %.0fm %.0fs\n", secs,
dh.wHour, dh.wMinute, dh.wSecond);
Message Edited by Roberto Bozzolo on 07-14-2005 12:03 AM