param items param columns export function gridify < T > ( items , columns ) { items = items . slice ( 0 ) ; const grid = [ ] ; while ( items . length ) { grid . push ( items . splice ( 0 , columns ) ) ; } return grid ; } param start param end export function range ( start , end ) { const list = [ ] ; for ( let idx = start ; idx <= end ; idx ++ ) { list . push ( idx ) ; } return list ; } param start param end export function dateRange ( start , end ) { start = new Date ( start ) ; const dates = [ ] ; while ( start <= end ) { dates . push ( new Date ( start ) ) ; start . setDate ( start . getDate ( ) + 1 ) ; } return dates ; } param day1 param day2 export function compareDays ( day1 , day2 ) { return day1 . getDate ( ) === day2 . getDate ( ) && day1 . getMonth ( ) === day2 . getMonth ( ) && day1 . getFullYear ( ) === day2 . getFullYear ( ) ; } /**
 * Date comparison for use primarily with distinctUntilChanged
 */ export function dateComparator ( dateOne , dateTwo ) { if ( ! dateOne && dateTwo || dateOne && ! dateTwo ) { return false ; } if ( ! dateOne && ! dateTwo ) { return true ; } return dateOne . getTime ( ) === dateTwo . getTime ( ) ; } param start param end param fullDay export function differenceBetweenDates ( start , end , fullDay = true ) { if ( ! start || ! end ) { return null ; } const millisecondsInDay = 86400000 ; const startDay = new Date ( start . getTime ( ) < end . getTime ( ) ? start : end ) ; const endDay = new Date ( start . getTime ( ) > end . getTime ( ) ? start : end ) ; if ( fullDay ) { startDay . setHours ( 0 , 0 , 0 , 0 ) ; endDay . setHours ( 23 , 59 , 59 , 0 ) ; } return Math . round ( ( endDay . getTime ( ) - startDay . getTime ( ) ) / millisecondsInDay ) ; } /**
 * Timezone comparison for use primarily with distinctUntilChanged
 */ export function timezoneComparator ( zoneOne , zoneTwo ) { return zoneOne . name === zoneTwo . name && zoneOne . offset === zoneTwo . offset ; } param date export function getStartOfDay ( date ) { const startOfDay = new Date ( date ) ; startOfDay . setHours ( 0 , 0 , 0 , 0 ) ; return startOfDay ; } export function isDateAfter ( date , after , isEqual = false ) { return isEqual ? getStartOfDay ( date ) . getTime ( ) >= getStartOfDay ( after ) . getTime ( ) : getStartOfDay ( date ) . getTime ( ) > getStartOfDay ( after ) . getTime ( ) ; } export function isDateBefore ( date , before , isEqual = false ) { return isEqual ? getStartOfDay ( date ) . getTime ( ) <= getStartOfDay ( before ) . getTime ( ) : getStartOfDay ( date ) . getTime ( ) < getStartOfDay ( before ) . getTime ( ) ; } /**
 * Export an array of all the available months
 */ export const months = [ 'January' , 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' ] ; export const monthsShort = getShortMonthNames ( ) ; function getShortMonthNames ( ) { return months . map ( month => month . substring ( 0 , 3 ) ) ; } /**
 * Export an array of all the available days of the week
 */ export const weekdays = [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' ] ; export const weekdaysShort = getShortWeekdayNames ( ) ; export const meridians = [ 'AM' , 'PM' ] ; function getShortWeekdayNames ( ) { return weekdays . map ( weekday => weekday . substring ( 0 , 3 ) ) ; } /** Export the default set of time zone */ export const timezones = [ { name : 'GMT-11' , offset : 660 } , { name : 'GMT-10' , offset : 600 } , { name : 'GMT-9' , offset : 540 } , { name : 'GMT-8' , offset : 480 } , { name : 'GMT-7' , offset : 420 } , { name : 'GMT-6' , offset : 360 } , { name : 'GMT-5' , offset : 300 } , { name : 'GMT-4' , offset : 240 } , { name : 'GMT-3' , offset : 180 } , { name : 'GMT-2' , offset : 120 } , { name : 'GMT-1' , offset : 60 } , { name : 'GMT' , offset : 0 } , { name : 'GMT+1' , offset : - 60 } , { name : 'GMT+2' , offset : - 120 } , { name : 'GMT+3' , offset : - 180 } , { name : 'GMT+4' , offset : - 240 } , { name : 'GMT+5' , offset : - 300 } , { name : 'GMT+6' , offset : - 360 } , { name : 'GMT+7' , offset : - 420 } , { name : 'GMT+8' , offset : - 480 } , { name : 'GMT+9' , offset : - 540 } , { name : 'GMT+10' , offset : - 600 } , { name : 'GMT+11' , offset : - 660 } , { name : 'GMT+12' , offset : - 720 } ] ; export interface DateTimePickerTimezone { name : string ; offset : number ; }