git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@403 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-17 19:44:55 +00:00
parent f9b061aac8
commit b608931b21
10 changed files with 79 additions and 80 deletions

View File

@@ -15,3 +15,22 @@ char* MwStringConcat(const char* str1, const char* str2) {
return r;
}
void MwStringSize(char* out, MwOffset size) {
if(size / 1024 == 0) {
sprintf(out, "%d", (int)size);
} else if(size / 1024 / 1024 == 0) {
sprintf(out, "%.1fK", (double)size / 1024);
} else if(size / 1024 / 1024 / 1024 == 0) {
sprintf(out, "%.1fM", (double)size / 1024 / 1024);
} else {
sprintf(out, "%.1fG", (double)size / 1024 / 1024 / 1024);
}
}
void MwStringTime(char* out, time_t t) {
struct tm* tm = localtime(&t);
const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
sprintf(out, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year);
}