Typescript history pager

Date: 2019-06-24
const dateAdd = (date: Date, ms: number) => new Date(date.getTime() + ms);
const getToday = () => {
    const d = new Date();
    d.setHours(23, 59, 59);
    return d;
};

export interface IPageInfo { from: Date; to: Date; page: number; }
type Pager = (page: number) => IPageInfo;

const historyPager = (msRange: number): Pager => {
    const today = getToday();
    return (page: number) => {
        const from = dateAdd(today, -msRange * (page + 1));
        from.setHours(0, 0, 0);
        let to = dateAdd(today, -msRange * page);
        if (page < 1) {
            to = null;
        }
        return {
            from,
            to,
            page
        };
    };
};
22620cookie-checkTypescript history pager