import moment from "moment";
export function format(first, middle, last) {
    return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
}
export function getTimeDifferFormNow(t1) {
    const start = moment(t1);
    const end = moment();
    const duration = moment.duration(start.diff(end));
    const days = Math.floor(duration.asDays());
    const hours = duration.hours();
    const minutes = duration.minutes();
    const seconds = duration.seconds();
    // Format with leading zeros
    return [days, hours, minutes, seconds]
        .map(val => ('0' + val).slice(-2))
        .join(':');
}
export function getTheDay1MonthAgo() {
    const end = moment().utc().subtract(1, 'month');
    return end.format('YYYY-MM-DD');
}
export const getDevice = () => {
    let userAgent = window.navigator.userAgent;
    if (userAgent.toLowerCase().match(/android/i)) {
        return 'Android';
    }
    if (userAgent.toLowerCase().match(/iphone/i)) {
        return 'iPhone';
    }
    if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
        return 'iPad';
    }
    return 'PC';
};
