lennym/moment-business-time

workingDiff fails if locale workinghours end at 24:00:00

Opened this issue · 0 comments

jow5 commented

When the working hours are all day Mon-Fri, like:
moment.updateLocale('en', { workinghours: { 0: null, 1: ['00:00:00', '24:00:00'], 2: ['00:00:00', '24:00:00'], 3: ['00:00:00', '24:00:00'], 4: ['00:00:00', '24:00:00'], 5: ['00:00:00', '24:00:00'], 6: null, }, holidays: [], })

A subsequent call to workingDiff with a 'to' time on a Saturday (non-working day) causes lastWorkingTime() to return friday @ 24:00:00 (which is also Saturday @ 00:00:00). This causes openingTimes(to) to return null, which causes an error on line 375 because there is no "pop" method of null:
375: if (!from.isAfter(openingTimes(from)[0][0]) && !to.isBefore(openingTimes(to).pop()[1])) {

Workaround: set workinghours to end at 23:59:59 -- not sure if there are negative side-effects of that