summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-04-18 18:31:00 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-28 09:42:28 +0200
commit454ecf24ea90057666d0e75e4473e7f6d551a985 (patch)
tree65f0a09b131831b00a651637353177be0164dce3 /Userland/Libraries
parentfc1fd907b4fa21331a2f6b364b5fff351bf513a3 (diff)
downloadserenity-454ecf24ea90057666d0e75e4473e7f6d551a985.zip
AK+LibTimeZone: Add debug only formatter for Optional
I found this handy for debugging, and so might others. This now also adds a formatter for TimeZone::TimeZone. This is needed for FormatIfSupported<Optional<TimeZone::TimeZone>> to compile. As FormatIfSupported sees a formatter for Optional exists, but not that there's not one for TimeZone::TimeZone.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibTimeZone/TimeZone.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibTimeZone/TimeZone.h b/Userland/Libraries/LibTimeZone/TimeZone.h
index e813c9d7ad..52e20170f3 100644
--- a/Userland/Libraries/LibTimeZone/TimeZone.h
+++ b/Userland/Libraries/LibTimeZone/TimeZone.h
@@ -9,6 +9,7 @@
#include <AK/Array.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
+#include <AK/Format.h>
#include <AK/Optional.h>
#include <AK/StringView.h>
#include <AK/Time.h>
@@ -74,3 +75,11 @@ StringView region_to_string(Region region);
Vector<StringView> time_zones_in_region(StringView region);
}
+
+template<>
+struct AK::Formatter<TimeZone::TimeZone> : Formatter<FormatString> {
+ ErrorOr<void> format(FormatBuilder& builder, TimeZone::TimeZone const& time_zone)
+ {
+ return Formatter<FormatString>::format(builder, TimeZone::time_zone_to_string(time_zone));
+ }
+};