1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:37:34 +00:00

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.
This commit is contained in:
MacDue 2023-04-18 18:31:00 +01:00 committed by Andreas Kling
parent fc1fd907b4
commit 454ecf24ea
2 changed files with 21 additions and 0 deletions

View file

@ -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));
}
};