Stop ignoring hours when using months for bandwidth accounting
The current monthly accounting code ignores hours when checking the monthly accounting start date/time. The fix is: ``` - (tm.tm_mday < cfg_start_day && before)) { + (tm.tm_mday == cfg_start_day && before)) { ``` For bonus points, write a unit test that catches the error. The original bug report was: ``` I could note just one warning out of all of them, which indicates an error. Let's consider the following code fragment: static time_t edge_of_accounting_period_containing(time_t now, int get_end) { .... case UNIT_MONTH: { if (tm.tm_mday < cfg_start_day || (tm.tm_mday < cfg_start_day && before)) { --tm.tm_mon; } .... } PVS-Studio warning: V686 A pattern was detected: (tm.tm_mday < cfg_start_day) || ((tm.tm_mday < cfg_start_day) && ...). The expression is excessive or contains a logical error. hibernate.c 333 The check can be simplified to: if (tm.tm_mday < cfg_start_day) { Perhaps, there is a typo or a logical error in this condition. ``` Reported by Andrey Karpov https://www.viva64.com/en/b/0507/
issue