diff options
author | Nico Weber <thakis@chromium.org> | 2020-08-17 11:23:09 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-17 21:23:11 +0200 |
commit | c0c7b4a0986024ea37e2b37c643d08abdeacba47 (patch) | |
tree | 6acd439404dc53eedab38b0400cebf385f72ed25 /MenuApplets | |
parent | a3908732ad0370091d31c0efb218440fbde6ae04 (diff) | |
download | serenity-c0c7b4a0986024ea37e2b37c643d08abdeacba47.zip |
Clock MenuApplet: Use Core::DateTime to simplify the code
Diffstat (limited to 'MenuApplets')
-rw-r--r-- | MenuApplets/Clock/main.cpp | 13 |
1 files 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 <LibCore/DateTime.h> #include <LibCore/Timer.h> #include <LibGUI/Application.h> #include <LibGUI/Painter.h> @@ -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()); |