System/Utilities/Time: Update for DST

This commit is contained in:
Alec Murphy 2025-03-08 16:28:12 -05:00
parent b0c1016955
commit b4e6abc79f

View file

@ -63,22 +63,40 @@ U0 @time_update(U8* date_str, I64 mS_delta, I64 hour_offset)
@time_cmos_update_byte(0x00, second);
}
Bool @is_dst(I64 month, I64 day, I64 day_of_week, I64 hour)
{
if (month < 3 || month > 11) {
return FALSE;
}
if (month > 3 && month < 11) {
return TRUE;
}
if (month == 3) {
if (day < (14 - day_of_week)) {
return FALSE;
}
if (day > (14 - day_of_week) && hour >= 2) {
return TRUE;
}
return FALSE;
}
if (month == 11) {
if (day < (7 - day_of_week)) {
return TRUE;
}
if (day == (7 - day_of_week) && hour < 1) {
return TRUE;
}
return FALSE;
}
return FALSE;
}
Bool @time_in_dst()
{
CDateStruct ds;
Date2Struct(&ds, Now);
if (ds.mon > 3 && ds.mon < 11)
return TRUE;
if (ds.mon < 3 || ds.mon > 11)
return FALSE;
if (ds.mon == 3 && ds.day_of_mon != 8)
return ds.day_of_mon > 8;
if (ds.mon == 3)
return ds.hour > 1;
if (ds.mon == 11 && ds.day_of_mon != 1)
return FALSE;
if (ds.mon == 11)
return ds.hour < 2;
return @is_dst(ds.mon, ds.day_of_mon, ds.day_of_week, ds.hour);
}
I64 @time_tz_offset()