mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-24 16:43:36 +00:00
Backport from xs.
This commit is contained in:
parent
6bad2355ef
commit
7b349dd001
2 changed files with 14 additions and 1 deletions
13
xs_time.h
13
xs_time.h
|
@ -12,6 +12,7 @@ xs_str *xs_str_time(time_t t, const char *fmt, int local);
|
|||
time_t xs_parse_time(const char *str, const char *fmt, int local);
|
||||
#define xs_parse_localtime(str, fmt) xs_parse_time(str, fmt, 1)
|
||||
#define xs_parse_utctime(str, fmt) xs_parse_time(str, fmt, 0)
|
||||
xs_str *xs_str_time_diff(time_t time_diff);
|
||||
|
||||
#ifdef XS_IMPLEMENTATION
|
||||
|
||||
|
@ -37,6 +38,18 @@ xs_str *xs_str_time(time_t t, const char *fmt, int local)
|
|||
}
|
||||
|
||||
|
||||
xs_str *xs_str_time_diff(time_t time_diff)
|
||||
/* returns time_diff in seconds to 'human' units (d:hh:mm:ss) */
|
||||
{
|
||||
int secs = time_diff % 60;
|
||||
int mins = (time_diff /= 60) % 60;
|
||||
int hours = (time_diff /= 60) % 24;
|
||||
int days = (time_diff /= 24);
|
||||
|
||||
return xs_fmt("%d:%02d:%02d:%02d", days, hours, mins, secs);
|
||||
}
|
||||
|
||||
|
||||
char *strptime(const char *s, const char *format, struct tm *tm);
|
||||
|
||||
time_t xs_parse_time(const char *str, const char *fmt, int local)
|
||||
|
|
|
@ -1 +1 @@
|
|||
/* dfdd729248d7169b80cb6a7462fe6c0ba6efeb16 */
|
||||
/* b4f118990f3b8327a033a28bd9ca687c75b23dee */
|
||||
|
|
Loading…
Reference in a new issue