Skip to content
Snippets Groups Projects
Commit 4e990b47 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add minutes_to_str() function

Generates a "Dd Hh Mm" string from a specified number of minutes.
parent e635293c
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -131,6 +131,16 @@ char* seconds_to_str(uint seconds, char* str) ...@@ -131,6 +131,16 @@ char* seconds_to_str(uint seconds, char* str)
return p; 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) char* hhmmtostr(scfg_t* cfg, struct tm* tm, char* str)
......
...@@ -39,8 +39,9 @@ DLLEXPORT char * sectostr(uint sec, char *str); ...@@ -39,8 +39,9 @@ DLLEXPORT char * sectostr(uint sec, char *str);
DLLEXPORT char * seconds_to_str(uint, char*); DLLEXPORT char * seconds_to_str(uint, char*);
DLLEXPORT char * hhmmtostr(scfg_t* cfg, struct tm* tm, char* str); DLLEXPORT char * hhmmtostr(scfg_t* cfg, struct tm* tm, char* str);
DLLEXPORT char * timestr(scfg_t* cfg, time32_t intime, 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 #ifdef __cplusplus
} }
#endif #endif
#endif /* Don't add anything after this line */ #endif /* Don't add anything after this line */
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment