diff options
Diffstat (limited to 'Userland/Libraries/LibWeb/Cookie/Cookie.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Cookie/Cookie.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Cookie/Cookie.cpp b/Userland/Libraries/LibWeb/Cookie/Cookie.cpp index 229ca38090..bbef4fb5c6 100644 --- a/Userland/Libraries/LibWeb/Cookie/Cookie.cpp +++ b/Userland/Libraries/LibWeb/Cookie/Cookie.cpp @@ -1,15 +1,38 @@ /* * Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org> + * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ #include "Cookie.h" +#include <LibCore/DateTime.h> #include <LibIPC/Decoder.h> #include <LibIPC/Encoder.h> namespace Web::Cookie { +static DeprecatedString time_to_string(Time const& time) +{ + auto local_time = Core::DateTime::from_timestamp(time.to_seconds()); + return local_time.to_deprecated_string("%Y-%m-%d %H:%M:%S %Z"sv); +} + +DeprecatedString Cookie::creation_time_to_string() const +{ + return time_to_string(creation_time); +} + +DeprecatedString Cookie::last_access_time_to_string() const +{ + return time_to_string(last_access_time); +} + +DeprecatedString Cookie::expiry_time_to_string() const +{ + return time_to_string(expiry_time); +} + StringView same_site_to_string(SameSite same_site) { switch (same_site) { @@ -64,11 +87,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<Core::DateTime>()); - auto expiry_time = TRY(decoder.decode<Core::DateTime>()); + auto creation_time = TRY(decoder.decode<Time>()); + auto expiry_time = TRY(decoder.decode<Time>()); auto host_only = TRY(decoder.decode<bool>()); auto http_only = TRY(decoder.decode<bool>()); - auto last_access_time = TRY(decoder.decode<Core::DateTime>()); + auto last_access_time = TRY(decoder.decode<Time>()); auto persistent = TRY(decoder.decode<bool>()); auto secure = TRY(decoder.decode<bool>()); auto same_site = TRY(decoder.decode<Web::Cookie::SameSite>()); |