From ccf34d2aa973fcd5f834a772a9f3934dafc82394 Mon Sep 17 00:00:00 2001 From: Ammerhai Date: Sat, 23 Aug 2025 11:25:45 +0200 Subject: [PATCH] add current year as starting year #4 --- src/work-calendar.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/work-calendar.cpp b/src/work-calendar.cpp index 46e3335..0f72751 100644 --- a/src/work-calendar.cpp +++ b/src/work-calendar.cpp @@ -1,10 +1,20 @@ #include #include +#include #include "inter.h" +//standard year int year = 2025; +int get_current_year(){ + time_t t = time(NULL); + struct tm tm = *localtime(&t); + + // tm_year is years since 1900 + return year = tm.tm_year + 1900; +} + bool is_leap_year(int year) { return ((year % 4) == 0 && (year % 100) != 0) || year % 400 == 0; } @@ -61,6 +71,8 @@ void per_frame(){ if(ImGui::BeginTable("Calendar", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoHostExtendX)) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); + + year = get_current_year(); ImGui::BeginGroup(); if (ImGui::ArrowButton("##left", ImGuiDir_Left))