import { Record } from "immutable" ; import * as moment from "moment-mini-ts" ; import { Moment } from "moment-mini-ts" ; let uniqueId = 1 ; export class Week extends Record ( { startDate : moment ( ) , uniqueId : 0 , days : [ ] as Date [ ] } ) { static from ( date ) { date = date . startOf ( 'isoWeek' ) ; return new Week ( { startDate : date , uniqueId : uniqueId ++ , days : Week . getDays ( date ) } ) ; } static getDays ( startDate ) { return [ startDate . clone ( ) . toDate ( ) , startDate . clone ( ) . add ( { days : 1 } ) . toDate ( ) , startDate . clone ( ) . add ( { days : 2 } ) . toDate ( ) , startDate . clone ( ) . add ( { days : 3 } ) . toDate ( ) , startDate . clone ( ) . add ( { days : 4 } ) . toDate ( ) , startDate . clone ( ) . add ( { days : 5 } ) . toDate ( ) , startDate . clone ( ) . add ( { days : 6 } ) . toDate ( ) , ] ; } includes ( day ) { return day . isoWeek ( ) === this . startDate . isoWeek ( ) ; } }