import dateutil from '../dateutil' ; import Iterinfo from '../iterinfo/index' ; import { pymod , isPresent , includes } from '../helpers' ; import { Time } from '../datetime' ; export function buildPoslist ( bysetpos , timeset , start , end , ii , dayset ) { const poslist = [ ] ; for ( let j = 0 ; j < bysetpos . length ; j ++ ) { let daypos ; let timepos ; const pos = bysetpos [ j ] ; if ( pos < 0 ) { daypos = Math . floor ( pos / timeset . length ) ; timepos = pymod ( pos , timeset . length ) ; } else { daypos = Math . floor ( ( pos - 1 ) / timeset . length ) ; timepos = pymod ( pos - 1 , timeset . length ) ; } const tmp = [ ] ; for ( let k = start ; k < end ; k ++ ) { const val = dayset [ k ] ; if ( ! isPresent ( val ) ) continue ; tmp . push ( val ) ; } let i ; if ( daypos < 0 ) { i = tmp . slice ( daypos ) [ 0 ] ; } else { i = tmp [ daypos ] ; } const time = timeset [ timepos ] ; const date = dateutil . fromOrdinal ( ii . yearordinal + i ) ; const res = dateutil . combine ( date , time ) ; if ( ! includes ( poslist , res ) ) poslist . push ( res ) ; } dateutil . sort ( poslist ) ; return poslist ; }