2020-05-03 01:30:09 -03:00
|
|
|
/*
|
2022-12-10 05:52:46 -03:00
|
|
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
2020-05-03 01:30:09 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-03 01:30:09 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2026-02-16 10:31:37 -03:00
|
|
|
#include <AK/Forward.h>
|
2024-01-24 08:49:55 -03:00
|
|
|
#include <AK/String.h>
|
2020-05-03 01:30:09 -03:00
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
2022-12-15 10:31:38 -03:00
|
|
|
enum class HumanReadableBasedOn {
|
|
|
|
|
Base2,
|
|
|
|
|
Base10
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-06 14:31:50 -03:00
|
|
|
enum class UseThousandsSeparator {
|
|
|
|
|
Yes,
|
|
|
|
|
No
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-24 09:16:32 -03:00
|
|
|
String human_readable_size(u64 size, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
|
|
|
|
|
String human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, StringView unit = "B"sv, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
|
2022-12-10 06:01:10 -03:00
|
|
|
|
2024-01-24 09:16:32 -03:00
|
|
|
String human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
|
2024-11-16 14:43:27 -03:00
|
|
|
String human_readable_time(Duration);
|
2025-11-10 08:35:30 -03:00
|
|
|
String human_readable_short_time(Duration);
|
2024-01-24 08:49:55 -03:00
|
|
|
String human_readable_digital_time(i64 time_in_seconds);
|
2022-08-04 10:36:18 -03:00
|
|
|
|
2020-05-03 01:30:09 -03:00
|
|
|
}
|
|
|
|
|
|
2022-11-26 08:18:30 -03:00
|
|
|
#if USING_AK_GLOBALLY
|
2022-08-04 10:36:18 -03:00
|
|
|
using AK::human_readable_digital_time;
|
2022-12-10 06:01:10 -03:00
|
|
|
using AK::human_readable_quantity;
|
2025-11-10 08:35:30 -03:00
|
|
|
using AK::human_readable_short_time;
|
2020-08-22 15:50:48 -03:00
|
|
|
using AK::human_readable_size;
|
2021-03-24 17:06:08 -03:00
|
|
|
using AK::human_readable_size_long;
|
2022-01-05 18:19:08 -03:00
|
|
|
using AK::human_readable_time;
|
2023-03-06 14:31:50 -03:00
|
|
|
using AK::UseThousandsSeparator;
|
2022-11-26 08:18:30 -03:00
|
|
|
#endif
|