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_internal.h>
#include <time.h>
#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))