whole 1st line done basically

This commit is contained in:
2026-05-04 23:04:30 +02:00
parent a90a65ba96
commit a82fdd3d33
3 changed files with 32 additions and 1 deletions

18
src/sys.c Normal file
View File

@@ -0,0 +1,18 @@
#include "sys.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void sys_get_time(struct time_date_t *td) {
constexpr char months[][4] = {"sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paz", "lis", "gru"};
constexpr char wdays[][4] = {"Nie", "Pon", "Wto", "Sro", "Czw", "Pia", "Sob"};
const time_t t = time(nullptr);
const struct tm *tm = localtime(&t);
snprintf(td->time, sizeof(td->time), "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
snprintf(td->date, sizeof(td->date), "%s, %02d %s", wdays[tm->tm_wday], tm->tm_mday, months[tm->tm_mon]);
}
void sys_get_load_avg(double *load_avg) {
getloadavg(load_avg, 3);
}