From c0c7b4a0986024ea37e2b37c643d08abdeacba47 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 17 Aug 2020 11:23:09 -0400 Subject: [PATCH] Clock MenuApplet: Use Core::DateTime to simplify the code --- MenuApplets/Clock/main.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/MenuApplets/Clock/main.cpp b/MenuApplets/Clock/main.cpp index a85cee6279..66c0b1df6d 100644 --- a/MenuApplets/Clock/main.cpp +++ b/MenuApplets/Clock/main.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -65,17 +66,7 @@ private: virtual void paint_event(GUI::PaintEvent& event) override { - time_t now = time(nullptr); - auto* tm = localtime(&now); - - auto time_text = String::format("%4u-%02u-%02u %02u:%02u:%02u", - tm->tm_year + 1900, - tm->tm_mon + 1, - tm->tm_mday, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); - + auto time_text = Core::DateTime::now().to_string(); GUI::Painter painter(*this); painter.fill_rect(event.rect(), palette().window()); painter.draw_text(event.rect(), time_text, Gfx::Font::default_font(), Gfx::TextAlignment::Center, palette().window_text());