1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:17:34 +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

@ -115,7 +115,7 @@ private:
float m_rotation_speed = 60.f;
bool m_show_frame_rate = false;
int m_cycles = 0;
Time m_accumulated_time = {};
Duration m_accumulated_time = {};
RefPtr<GUI::Label> m_stats;
GLint m_wrap_s_mode = GL_REPEAT;
GLint m_wrap_t_mode = GL_REPEAT;

View file

@ -286,7 +286,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con
// 2. Create a new cookie with name cookie-name, value cookie-value. Set the creation-time and the last-access-time to the current date and time.
Web::Cookie::Cookie cookie { parsed_cookie.name, parsed_cookie.value, parsed_cookie.same_site_attribute };
cookie.creation_time = Time::now_realtime();
cookie.creation_time = Duration::now_realtime();
cookie.last_access_time = cookie.creation_time;
if (parsed_cookie.expiry_time_from_max_age_attribute.has_value()) {
@ -302,7 +302,7 @@ void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, con
} else {
// Set the cookie's persistent-flag to false. Set the cookie's expiry-time to the latest representable date.
cookie.persistent = false;
cookie.expiry_time = Time::max();
cookie.expiry_time = Duration::max();
}
// 4. If the cookie-attribute-list contains an attribute with an attribute-name of "Domain":
@ -421,7 +421,7 @@ Vector<Web::Cookie::Cookie> CookieJar::get_matching_cookies(const URL& url, Depr
});
// 3. Update the last-access-time of each cookie in the cookie-list to the current date and time.
auto now = Time::now_realtime();
auto now = Duration::now_realtime();
for (auto& cookie : cookie_list) {
cookie.last_access_time = now;
@ -462,7 +462,7 @@ static ErrorOr<Web::Cookie::Cookie> parse_cookie(ReadonlySpan<SQL::Value> row)
return Error::from_string_view(name);
auto time = value.to_int<i64>().value();
field = Time::from_seconds(time);
field = Duration::from_seconds(time);
return {};
};
@ -624,7 +624,7 @@ void CookieJar::select_all_cookies_from_database(OnSelectAllCookiesResult on_res
void CookieJar::purge_expired_cookies()
{
auto now = Time::now_realtime().to_seconds();
auto now = Duration::now_realtime().to_seconds();
m_storage.visit(
[&](PersistedStorage& storage) {

View file

@ -130,7 +130,7 @@ void StorageWidget::clear_session_storage_entries()
void StorageWidget::delete_cookie(Web::Cookie::Cookie cookie)
{
// Delete cookie by making its expiry time in the past.
cookie.expiry_time = Time::from_seconds(0);
cookie.expiry_time = Duration::from_seconds(0);
if (on_update_cookie)
on_update_cookie(move(cookie));
}

View file

@ -133,7 +133,7 @@ void TimeZoneSettingsWidget::set_time_zone_location()
m_time_zone_location = compute_time_zone_location();
auto locale = Locale::default_locale();
auto now = AK::Time::now_realtime();
auto now = AK::Duration::now_realtime();
auto name = Locale::format_time_zone(locale, m_time_zone, Locale::CalendarPatternStyle::Long, now).release_value_but_fixme_should_propagate_errors();
auto offset = Locale::format_time_zone(locale, m_time_zone, Locale::CalendarPatternStyle::LongOffset, now).release_value_but_fixme_should_propagate_errors();

View file

@ -229,7 +229,7 @@ bool HexDocumentUndoCommand::merge_with(GUI::Command const& other)
m_old[relative_start + i] = typed_other.m_old[i];
}
m_timestamp = Time::now_monotonic();
m_timestamp = Duration::now_monotonic();
return true;
}

View file

@ -15,7 +15,7 @@
#include <LibCore/Forward.h>
#include <LibGUI/Command.h>
constexpr Time COMMAND_COMMIT_TIME = Time::from_milliseconds(400);
constexpr Duration COMMAND_COMMIT_TIME = Duration::from_milliseconds(400);
class HexDocument : public Weakable<HexDocument> {
public:
@ -103,9 +103,9 @@ public:
ErrorOr<void> try_add_changed_bytes(ByteBuffer old_values, ByteBuffer new_values);
private:
bool commit_time_expired() const { return Time::now_monotonic() - m_timestamp >= COMMAND_COMMIT_TIME; }
bool commit_time_expired() const { return Duration::now_monotonic() - m_timestamp >= COMMAND_COMMIT_TIME; }
Time m_timestamp = Time::now_monotonic();
Duration m_timestamp = Duration::now_monotonic();
WeakPtr<HexDocument> m_document;
size_t m_position;
ByteBuffer m_old;

View file

@ -112,7 +112,7 @@ ErrorOr<void> AudioPlayerLoop::send_audio_to_server()
auto sample_rate = static_cast<double>(m_resampler->target());
auto buffer_play_time_ns = 1'000'000'000.0 / (sample_rate / static_cast<double>(Audio::AUDIO_BUFFER_SIZE));
auto good_sleep_time = Time::from_nanoseconds(static_cast<unsigned>(buffer_play_time_ns)).to_timespec();
auto good_sleep_time = Duration::from_nanoseconds(static_cast<unsigned>(buffer_play_time_ns)).to_timespec();
size_t start_of_chunk_to_write = 0;
while (start_of_chunk_to_write + Audio::AUDIO_BUFFER_SIZE <= m_remaining_samples.size()) {

View file

@ -347,7 +347,7 @@ void MainWidget::save_to_file(String const& filename, NonnullOwnPtr<Core::File>
if (sync_result.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save theme file: {}", sync_result.error()));
} else {
m_last_modified_time = Time::now_monotonic();
m_last_modified_time = Duration::now_monotonic();
set_path(filename.to_deprecated_string());
window()->set_modified(false);
}
@ -643,7 +643,7 @@ ErrorOr<void> MainWidget::load_from_file(String const& filename, NonnullOwnPtr<C
ENUMERATE_PATH_ROLES(__ENUMERATE_PATH_ROLE)
#undef __ENUMERATE_PATH_ROLE
m_last_modified_time = Time::now_monotonic();
m_last_modified_time = Duration::now_monotonic();
window()->set_modified(false);
return {};
}

View file

@ -124,7 +124,7 @@ private:
Optional<DeprecatedString> m_path;
Gfx::Palette m_current_palette;
Time m_last_modified_time { Time::now_monotonic() };
Duration m_last_modified_time { Duration::now_monotonic() };
RefPtr<AlignmentModel> m_alignment_model;

View file

@ -59,7 +59,7 @@ ErrorOr<void> VideoPlayerWidget::setup_interface()
update_seek_slider_max();
auto progress = value / static_cast<double>(m_seek_slider->max());
auto duration = m_playback_manager->duration().to_milliseconds();
Time timestamp = Time::from_milliseconds(static_cast<i64>(round(progress * static_cast<double>(duration))));
Duration timestamp = Duration::from_milliseconds(static_cast<i64>(round(progress * static_cast<double>(duration))));
auto seek_mode_to_use = m_seek_slider->knob_dragging() ? seek_mode() : Video::PlaybackManager::SeekMode::Accurate;
m_playback_manager->seek_to_timestamp(timestamp, seek_mode_to_use);
set_current_timestamp(m_playback_manager->current_playback_time());
@ -252,7 +252,7 @@ void VideoPlayerWidget::update_seek_slider_max()
m_seek_slider->set_enabled(true);
}
void VideoPlayerWidget::set_current_timestamp(Time timestamp)
void VideoPlayerWidget::set_current_timestamp(Duration timestamp)
{
set_time_label(timestamp);
if (!m_playback_manager)
@ -261,10 +261,10 @@ void VideoPlayerWidget::set_current_timestamp(Time timestamp)
m_seek_slider->set_value(static_cast<int>(round(progress * m_seek_slider->max())), GUI::AllowCallback::No);
}
void VideoPlayerWidget::set_time_label(Time timestamp)
void VideoPlayerWidget::set_time_label(Duration timestamp)
{
StringBuilder string_builder;
auto append_time = [&](Time time) {
auto append_time = [&](Duration time) {
auto seconds = (time.to_milliseconds() + 500) / 1000;
string_builder.append(human_readable_digital_time(seconds));
};

View file

@ -45,8 +45,8 @@ private:
ErrorOr<void> setup_interface();
void update_play_pause_icon();
void update_seek_slider_max();
void set_current_timestamp(Time);
void set_time_label(Time);
void set_current_timestamp(Duration);
void set_time_label(Duration);
void on_decoding_error(Video::DecoderError const&);
void cycle_sizing_modes();