import * as moment from 'moment';
import { IUrlTimeRange } from '@typings/common/url';
import { toTimeString } from './time';

// should be invoked only if user permitted
// geolocation (location subject in UserLocationService
// emitted non-null value)
export function getDefaultTimeRangeOnMobile(): IUrlTimeRange {
    const minusOne = moment().add(-1, 'hour');
    const plusThree = moment().add(3, 'hour');

    const minusOneHours = minusOne.hours();
    const plusThreeHours = plusThree.hours();

    return {
        timeFrom: `${toTimeString(minusOneHours)}00`,
        timeTo: `${toTimeString(plusThreeHours)}00`,
    };
}
