1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

AK: Rename Time to Duration

That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
This commit is contained in:
kleines Filmröllchen 2023-03-13 16:30:34 +01:00 committed by Jelle Raaijmakers
parent 82ddc813d5
commit 213025f210
140 changed files with 634 additions and 628 deletions

View file

@ -298,7 +298,7 @@ static i64 clip_bigint_to_sane_time(Crypto::SignedBigInteger const& value)
static Crypto::SignedBigInteger const min_bigint { NumericLimits<i64>::min() };
static Crypto::SignedBigInteger const max_bigint { NumericLimits<i64>::max() };
// The provided epoch (nano)seconds value is potentially out of range for AK::Time and subsequently
// The provided epoch (nano)seconds value is potentially out of range for AK::Duration and subsequently
// get_time_zone_offset(). We can safely assume that the TZDB has no useful information that far
// into the past and future anyway, so clamp it to the i64 range.
if (value < min_bigint)
@ -314,7 +314,7 @@ static i64 clip_bigint_to_sane_time(Crypto::SignedBigInteger const& value)
Vector<Crypto::SignedBigInteger> get_named_time_zone_epoch_nanoseconds(StringView time_zone_identifier, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond)
{
auto local_nanoseconds = get_utc_epoch_nanoseconds(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond);
auto local_time = Time::from_nanoseconds(clip_bigint_to_sane_time(local_nanoseconds));
auto local_time = Duration::from_nanoseconds(clip_bigint_to_sane_time(local_nanoseconds));
// FIXME: LibTimeZone does not behave exactly as the spec expects. It does not consider repeated or skipped time points.
auto offset = TimeZone::get_time_zone_offset(time_zone_identifier, local_time);
@ -332,10 +332,10 @@ i64 get_named_time_zone_offset_nanoseconds(StringView time_zone_identifier, Cryp
auto time_zone = TimeZone::time_zone_from_string(time_zone_identifier);
VERIFY(time_zone.has_value());
// Since Time::from_seconds() and Time::from_nanoseconds() both take an i64, converting to
// Since Duration::from_seconds() and Duration::from_nanoseconds() both take an i64, converting to
// seconds first gives us a greater range. The TZDB doesn't have sub-second offsets.
auto seconds = epoch_nanoseconds.divided_by(s_one_billion_bigint).quotient;
auto time = Time::from_seconds(clip_bigint_to_sane_time(seconds));
auto time = Duration::from_seconds(clip_bigint_to_sane_time(seconds));
auto offset = TimeZone::get_time_zone_offset(*time_zone, time);
VERIFY(offset.has_value());