add current year as starting year

#4
This commit is contained in:
Ammerhai 2025-08-23 11:25:45 +02:00
parent 9daff74e9e
commit ccf34d2aa9

View File

@ -1,10 +1,20 @@
#include <imgui.h> #include <imgui.h>
#include <imgui_internal.h> #include <imgui_internal.h>
#include <time.h>
#include "inter.h" #include "inter.h"
//standard year
int year = 2025; 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) { bool is_leap_year(int year) {
return ((year % 4) == 0 && (year % 100) != 0) || year % 400 == 0; return ((year % 4) == 0 && (year % 100) != 0) || year % 400 == 0;
} }
@ -62,6 +72,8 @@ void per_frame(){
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
year = get_current_year();
ImGui::BeginGroup(); ImGui::BeginGroup();
if (ImGui::ArrowButton("##left", ImGuiDir_Left)) if (ImGui::ArrowButton("##left", ImGuiDir_Left))
year--; year--;