mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
AK+Userland: Return String from human_readable_[digital_]time()
This commit is contained in:
committed by
Andreas Kling
parent
b12541b286
commit
7e8cfb60eb
@@ -5,10 +5,8 @@
|
||||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@@ -75,7 +73,7 @@ ByteString human_readable_size_long(u64 size, UseThousandsSeparator use_thousand
|
||||
return ByteString::formatted("{} ({} bytes)", human_readable_size_string, size);
|
||||
}
|
||||
|
||||
ByteString human_readable_time(i64 time_in_seconds)
|
||||
String human_readable_time(i64 time_in_seconds)
|
||||
{
|
||||
auto days = time_in_seconds / 86400;
|
||||
time_in_seconds = time_in_seconds % 86400;
|
||||
@@ -99,10 +97,10 @@ ByteString human_readable_time(i64 time_in_seconds)
|
||||
|
||||
builder.appendff("{} second{}", time_in_seconds, time_in_seconds == 1 ? "" : "s");
|
||||
|
||||
return builder.to_byte_string();
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
ByteString human_readable_digital_time(i64 time_in_seconds)
|
||||
String human_readable_digital_time(i64 time_in_seconds)
|
||||
{
|
||||
auto hours = time_in_seconds / 3600;
|
||||
time_in_seconds = time_in_seconds % 3600;
|
||||
@@ -117,7 +115,7 @@ ByteString human_readable_digital_time(i64 time_in_seconds)
|
||||
builder.appendff("{:02}:", minutes);
|
||||
builder.appendff("{:02}", time_in_seconds);
|
||||
|
||||
return builder.to_byte_string();
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user