Commit 4e990b47 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Add minutes_to_str() function

Generates a "Dd Hh Mm" string from a specified number of minutes.
parent e635293c
......@@ -131,6 +131,16 @@ char* seconds_to_str(uint seconds, char* str)
return p;
}
/* Returns a duration in minutes into a string */
char* minutes_to_str(uint min, char* str, size_t size)
{
safe_snprintf(str, size, "%ud %uh %um"
,min / (24 *60)
,(min % (24 * 60)) / 60
,min % 60);
return str;
}
/****************************************************************************/
/****************************************************************************/
char* hhmmtostr(scfg_t* cfg, struct tm* tm, char* str)
......
......@@ -39,8 +39,9 @@ DLLEXPORT char * sectostr(uint sec, char *str);
DLLEXPORT char * seconds_to_str(uint, char*);
DLLEXPORT char * hhmmtostr(scfg_t* cfg, struct tm* tm, char* str);
DLLEXPORT char * timestr(scfg_t* cfg, time32_t intime, char* str);
DLLEXPORT char* minutes_to_str(uint min, char* str, size_t);
#ifdef __cplusplus
}
#endif
#endif /* Don't add anything after this line */
\ No newline at end of file
#endif /* Don't add anything after this line */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment