1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 07:17:53 +00:00
Commit Graph

26 Commits

Author SHA1 Message Date
Sam Atkins
388856dc7e AK+Userland: Return String from human_readable_size() functions 2024-01-25 09:07:32 +01:00
Sam Atkins
7e8cfb60eb AK+Userland: Return String from human_readable_[digital_]time() 2024-01-25 09:07:32 +01:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Tim Ledbetter
54539c42c2 AK: Allow human_readable_size_long to use a thousands separator 2023-04-11 13:03:30 +02:00
Arda Cinar
0dbb1be81c AK: Add an option to format numbers with 1000 based units
Instead of only allowing 1024-based units.
2023-01-02 20:11:18 +00:00
Arda Cinar
c8fadff9b1 AK: Add a human_readable_quantity helper to NumberFormat.h
This can be used for displaying large quantities that are not measured
in bytes in a more human-readable format.
2023-01-02 20:11:18 +00:00
Arda Cinar
3e924e2a37 AK: Move the functions in NumberFormat.h out of line 2023-01-02 20:11:18 +00:00
Karol Kosek
25fa485dfb AK: Calculate elapsed days in human_readable_time() 2022-12-21 08:41:34 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Andreas Kling
ae3ffdd521 AK: Make it possible to not using AK classes into the global namespace
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by
default, but can be overridden by build flags.

This is a step towards integrating Jakt and AK types.
2022-11-26 15:51:34 +01:00
thankyouverycool
75b6097c55 AK: Add human_readable_digital_time() helper
Converts seconds into a readable digital format. For example:
30 seconds	= "00:30"
90 seconds	= "01:30"
86401 seconds	= "24:00:01"
And so on.
2022-08-05 13:55:13 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Rafał Babiarz
0012c03eb5 AK: Added human_readable_time() method for "unsaved changes" dialogs 2022-01-09 20:25:48 -08:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
David Isaksson
17c0349d23 AK: Add longer human readable size to string helper function
Wraps the existing AK::human_readable_size function but will always
display the bytes in the base unit as well as the shorter string with
one decimal. E.g. "14 KiB (14396 bytes)".
2021-03-25 10:59:11 +01:00
Jean-Baptiste Boric
607fac662d AK: Implement terabytes, petabytes, exabytes 2021-03-17 23:22:42 +01:00
Ben Wiederhake
cc89606ba8 Everywhere: Remove unnecessary headers 3/4
Arbitrarily split up to make git bisect easier.

These unnecessary #include's were found by combining an automated tool (which
determined likely candidates) and some brain power (which decided whether
the #include is also semantically superfluous).
2021-02-08 18:03:57 +01:00
asynts
1d96d5eea4 AK: Use new format functions. 2020-10-08 09:59:55 +02:00
Ben Wiederhake
0944f56181 AK: Fix human_readable_size corner cases
In particular: consistent rounding and extreme values.

Before, rounding was something like 'away from 0.999...', which led to
surprising corner cases in which the value was rounded up.

Now, rounding is always 'down'.
This even works for 0xffffffff, and also for 0xffffffffffffffffULL on 64-bit.
2020-08-23 11:24:55 +02:00
Ben Wiederhake
2a2630edc9 Meta: Fix wrong 'using namespace X' usages
Apart from causing All AK:: and Crypto:: symbols being suddenly visible even though
they might not be supposed to be, the style guide also says this is wrong:

https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md#using-statements
2020-08-23 00:53:16 +02:00
Nico Weber
f47dbb6a58 AK: Use IEC prefixes in human_readable_format
Windows uses "KB", "MB", "GB" as powers of two.
macOS uses "kB", "MB", "GB" as powers of ten.

"k", "M", "G" are standard SI prefixes that normally refer to powers of
ten.

The IEC introduced "KiB", "MiB", "GiB" to unambiguously refer to
powers of two. It admittedly hasn't caught on that much, but it
does have the advantage that it's unabigious what it means.
So let's use it for user-visible sizes in SerenityOS.

(Linux does all of the above in different places, depending on app and
toolkit.)
2020-08-16 16:33:28 +02:00
Nico Weber
aa97166739 Everywhere: Consolidate human_readable_size() implementations
Let's use the one in AK/NumberFormat.h everywhere.

It has slightly different behavior than some of the copies this
removes, but it's probably nice to have uniform human readable
size outputs across the system.
2020-08-16 16:33:28 +02:00
Nico Weber
430b265cd4 AK: Rename KB, MB, GB to KiB, MiB, GiB
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9".
The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30".

Let's use the correct name, at least in code.

Only changes the name of the constants, no other behavior change.
2020-08-16 16:33:28 +02:00
AnotherTest
c6825a96c7 AK+FileManager: Move out human_readable_size to AK::NumberFormat 2020-05-03 12:59:26 +02:00