"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const date_fns_1 = require("date-fns");
const sumOnlineTimeNow = (oldOnlineTimeSum) => {
    let onlineTime = new Date();
    onlineTime.setUTCHours(new Date(oldOnlineTimeSum.onlineTime).getHours());
    onlineTime.setUTCMinutes(new Date(oldOnlineTimeSum.onlineTime).getMinutes());
    onlineTime.setUTCSeconds(new Date(oldOnlineTimeSum.onlineTime).getSeconds());
    let newtTime = date_fns_1.intervalToDuration({ start: new Date(oldOnlineTimeSum.updatedAt), end: new Date() });
    if (newtTime.hours && +newtTime.hours > 0) {
        onlineTime = date_fns_1.addHours(onlineTime, newtTime.hours);
    }
    if (newtTime.minutes && +newtTime.minutes > 0) {
        onlineTime = date_fns_1.addMinutes(onlineTime, newtTime.minutes);
    }
    if (newtTime.seconds && +newtTime.seconds > 0) {
        onlineTime = date_fns_1.addSeconds(onlineTime, newtTime.seconds);
    }
    const isoDate = new Date(onlineTime);
    const newOnlinetime = isoDate.toJSON().slice(0, 19).replace('T', ' ');
    return newOnlinetime;
};
exports.default = sumOnlineTimeNow;
