Jacek Caban (@jacek) commented about dlls/vbscript/global.c:
+ + /* Use floor division so negative day numbers are handled correctly */ + result = (LONG)floor((double)(day2 - anchor) / 7.0) + - (LONG)floor((double)(day1 - anchor) / 7.0); + } + else if(!wcsicmp(interval, L"h") || !wcsicmp(interval, L"n") || !wcsicmp(interval, L"s")) + { + /* OLE DATE convention: integer part is the day (truncated toward zero), + * fractional part is the time-of-day as a positive offset within that + * day. For negative DATEs, plain D*units gives the wrong wall-clock + * count, so reconstruct as trunc(D)*units + |D - trunc(D)|*units. */ + double units = !wcsicmp(interval, L"h") ? 24.0 : !wcsicmp(interval, L"n") ? 1440.0 : 86400.0; + double t1 = trunc(date1) * units + fabs(date1 - trunc(date1)) * units; + double t2 = trunc(date2) * units + fabs(date2 - trunc(date2)) * units; + result = (LONG)(units == 86400.0 ? floor(t2 - t1 + 0.5) + : floor(t2) - floor(t1));
result = units == 86400.0 ? lround(t2 - t1) : floor(t2) - floor(t1);
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10459#note_139077