mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
AK: Calculate elapsed days in human_readable_time()
This commit is contained in:
parent
a473cfd71b
commit
25fa485dfb
Notes:
sideshowbarker
2024-07-17 05:23:40 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/25fa485dfb Pull-request: https://github.com/SerenityOS/serenity/pull/16568 Reviewed-by: https://github.com/AtkinsSJ ✅
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
Reference in a new issue