blob: 89644b2c1331dc8e0be527dfbdfe7c701c458e50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#pragma once
#include <al/lib.h>
static inline s32 camu_print_time(char *buf, size_t size, u64 nanoseconds, bool always_show_hour, u32 hour_padding)
{
u32 hours = nanoseconds / 3600000000u;
u32 minutes = nanoseconds / 60000000u;
bool show_hour = always_show_hour || minutes >= 60u;
u32 seconds = nanoseconds / 1000000u;
seconds -= minutes * 60u;
minutes -= hours * 60u;
s32 offset = 0;
if (show_hour && hour_padding >= 2 && hour_padding <= 4) {
static const char *padding_table[] = { "%.2u:", "%.3u:", "%.4u:" };
offset += al_snprintf(buf, size, padding_table[hour_padding - 2u], hours);
}
offset += al_snprintf(buf + offset, size - offset, "%.2u:%.2u", minutes, seconds);
return offset;
}
|