1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:58:10 +00:00

Userland: Remove remaining users of Duration::now_realtime()

This is a clear sign that they want to use a UnixDateTime instead.

This also adds support for placing durations and date times into SQL
databases via their millisecond offset to UTC.
This commit is contained in:
kleines Filmröllchen 2023-03-13 22:35:22 +01:00 committed by Jelle Raaijmakers
parent 82c681e44b
commit effcd080ca
16 changed files with 62 additions and 45 deletions

View file

@ -12,9 +12,10 @@
namespace Web::Cookie {
static DeprecatedString time_to_string(Duration const& time)
static DeprecatedString time_to_string(UnixDateTime const& time)
{
auto local_time = Core::DateTime::from_timestamp(time.to_seconds());
// FIXME: This roundabout formatting should not be necessary; it also loses precision.
auto local_time = Core::DateTime::from_timestamp(time.seconds_since_epoch());
return local_time.to_deprecated_string("%Y-%m-%d %H:%M:%S %Z"sv);
}
@ -87,11 +88,11 @@ ErrorOr<Web::Cookie::Cookie> IPC::decode(Decoder& decoder)
auto value = TRY(decoder.decode<DeprecatedString>());
auto domain = TRY(decoder.decode<DeprecatedString>());
auto path = TRY(decoder.decode<DeprecatedString>());
auto creation_time = TRY(decoder.decode<Duration>());
auto expiry_time = TRY(decoder.decode<Duration>());
auto creation_time = TRY(decoder.decode<UnixDateTime>());
auto expiry_time = TRY(decoder.decode<UnixDateTime>());
auto host_only = TRY(decoder.decode<bool>());
auto http_only = TRY(decoder.decode<bool>());
auto last_access_time = TRY(decoder.decode<Duration>());
auto last_access_time = TRY(decoder.decode<UnixDateTime>());
auto persistent = TRY(decoder.decode<bool>());
auto secure = TRY(decoder.decode<bool>());
auto same_site = TRY(decoder.decode<Web::Cookie::SameSite>());