fixed DateTime_get bugs and added FMT_DateTime

This commit is contained in:
2025-11-18 16:00:50 +05:00
parent bc41577248
commit c68e4e87b3
2 changed files with 28 additions and 15 deletions

View File

@@ -51,21 +51,21 @@ void sleepMsec(msec_t time){
void DateTime_get(DateTime* dt, bool utc_time){
time_t c_time = time(NULL);
struct tm c_tm;
struct timespec c_timespec;
if(utc_time){
portable_gmtime_s(&c_time, &c_tm);
}
else {
portable_localtime_s(&c_time, &c_tm);
}
struct timespec c_timespec;
clock_gettime(CLOCK_REALTIME, &c_timespec);
dt->t.nsec = c_timespec.tv_nsec;
dt->t.sec = c_timespec.tv_sec;
dt->t.sec = c_tm.tm_sec;
dt->t.min = c_tm.tm_min;
dt->t.hour = c_tm.tm_hour;
dt->d.month_day = c_tm.tm_mday;
dt->d.month = c_tm.tm_mon;
dt->d.year = c_tm.tm_year;
dt->d.week_day = c_tm.tm_wday;
dt->d.year_day = c_tm.tm_yday;
dt->d.month = c_tm.tm_mon + 1;
dt->d.year = c_tm.tm_year + 1900;
dt->d.week_day = c_tm.tm_wday + 1;
dt->d.year_day = c_tm.tm_yday + 1;
}