diff --git a/AK/Format.h b/AK/Format.h index 42e2a67a25..1766e510d1 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -715,6 +715,18 @@ struct Formatter> : Formatter { } }; +template +struct Formatter> : Formatter { + static constexpr bool is_debug_only() { return true; } + + ErrorOr format(FormatBuilder& builder, Optional const& optional) + { + if (optional.has_value()) + return Formatter::format(builder, "Optional({})"sv, *optional); + return builder.put_literal("OptionalNone"sv); + } +}; + } // namespace AK #if USING_AK_GLOBALLY 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 #include #include +#include #include #include #include @@ -74,3 +75,11 @@ StringView region_to_string(Region region); Vector time_zones_in_region(StringView region); } + +template<> +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, TimeZone::TimeZone const& time_zone) + { + return Formatter::format(builder, TimeZone::time_zone_to_string(time_zone)); + } +};