mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
AK: Calculate elapsed days in human_readable_time()
This commit is contained in:
parent
a473cfd71b
commit
25fa485dfb
1 changed files with 6 additions and 0 deletions
|
@ -44,6 +44,9 @@ static inline DeprecatedString human_readable_size_long(u64 size)
|
|||
|
||||
static inline DeprecatedString human_readable_time(i64 time_in_seconds)
|
||||
{
|
||||
auto days = time_in_seconds / 86400;
|
||||
time_in_seconds = time_in_seconds % 86400;
|
||||
|
||||
auto hours = time_in_seconds / 3600;
|
||||
time_in_seconds = time_in_seconds % 3600;
|
||||
|
||||
|
@ -52,6 +55,9 @@ static inline DeprecatedString human_readable_time(i64 time_in_seconds)
|
|||
|
||||
StringBuilder builder;
|
||||
|
||||
if (days > 0)
|
||||
builder.appendff("{} day{} ", days, days == 1 ? "" : "s");
|
||||
|
||||
if (hours > 0)
|
||||
builder.appendff("{} hour{} ", hours, hours == 1 ? "" : "s");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue