File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,24 +129,21 @@ export const isWithinSchedule = (schedule, date) => {
129129 const weekly = schedule ?. weekly ;
130130 if ( ! Array . isArray ( weekly ) || weekly . length === 0 ) return true ;
131131
132- const day = date . getDay ( ) ;
133- const minutes = date . getHours ( ) * 60 + date . getMinutes ( ) ;
132+ const WEEK = 7 * 1440 ;
133+ const nowInWeek = date . getDay ( ) * 1440 + date . getHours ( ) * 60 + date . getMinutes ( ) ;
134134
135135 for ( const slot of weekly ) {
136136 const slotDay = parseDay ( slot . day ) ;
137137 if ( slotDay === null ) continue ;
138138
139- if ( slotDay !== day ) continue ;
140-
141139 const startMin = parseTime ( slot . start ) ;
142140 if ( startMin === null || typeof slot . duration !== 'number' || slot . duration <= 0 ) continue ;
143- const endMin = startMin + slot . duration * 60 ;
144141
145- if ( startMin <= endMin ) {
146- if ( minutes >= startMin && minutes < endMin ) return true ;
147- } else {
148- if ( minutes >= startMin || minutes < endMin ) return true ;
149- }
142+ const slotStart = slotDay * 1440 + startMin ;
143+ const durationMin = slot . duration * 60 ;
144+ const elapsed = ( nowInWeek - slotStart + WEEK ) % WEEK ;
145+
146+ if ( elapsed < durationMin ) return true ;
150147 }
151148
152149 return false ;
You can’t perform that action at this time.
0 commit comments