/*!
 * Built by ShiftSoftware
 * Copyright (c)
 */
'use strict';

var loaderIcon = require('./loader-icon-j5dMQ4bN.js');

function decodeTimeOffset({ offsets, type, date = loaderIcon.dateFnsExports.startOfDay(new Date()) }) {
    if (offsets.length > 0)
        date = loaderIcon.dateFnsExports.addYears(date, offsets[0]);
    if (offsets.length > 1)
        date = loaderIcon.dateFnsExports.addMonths(date, offsets[1]);
    if (offsets.length > 2)
        date = loaderIcon.dateFnsExports.addDays(date, offsets[2]);
    if (offsets.length > 3)
        date = loaderIcon.dateFnsExports.addHours(date, offsets[3]);
    if (offsets.length > 4)
        date = loaderIcon.dateFnsExports.addMinutes(date, offsets[4]);
    if (offsets.length > 5)
        date = loaderIcon.dateFnsExports.addSeconds(date, offsets[5]);
    if (type) {
        switch (type) {
            case 'date':
                return loaderIcon.dateFnsExports.format(date, 'yyyy-MM-dd');
            case 'time':
                return loaderIcon.dateFnsExports.format(date, 'HH:mm');
            case 'datetime-local':
                return loaderIcon.dateFnsExports.format(date, "yyyy-MM-dd'T'HH:mm");
            default:
                return date;
        }
    }
    return date;
}

exports.decodeTimeOffset = decodeTimeOffset;
