import { localizeWithPath } from '../../nls.js';
const _moduleId = "vs/base/common/date";
const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
function fromNow(date, appendAgoLabel, useFullTimeWords, disallowNow) {
    if (typeof date !== 'number') {
        date = date.getTime();
    }
    const seconds = Math.round((( (new Date())).getTime() - date) / 1000);
    if (seconds < -30) {
        return ( localizeWithPath(
            _moduleId,
            0,
            'in {0}',
            fromNow(( (new Date())).getTime() + seconds * 1000, false)
        ));
    }
    if (!disallowNow && seconds < 30) {
        return ( localizeWithPath(_moduleId, 1, 'now'));
    }
    let value;
    if (seconds < minute) {
        value = seconds;
        if (appendAgoLabel) {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 2, '{0} second ago', value))
                    : ( localizeWithPath(_moduleId, 3, '{0} sec ago', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 4, '{0} seconds ago', value))
                    : ( localizeWithPath(_moduleId, 5, '{0} secs ago', value));
            }
        }
        else {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 6, '{0} second', value))
                    : ( localizeWithPath(_moduleId, 7, '{0} sec', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 8, '{0} seconds', value))
                    : ( localizeWithPath(_moduleId, 9, '{0} secs', value));
            }
        }
    }
    if (seconds < hour) {
        value = Math.floor(seconds / minute);
        if (appendAgoLabel) {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 10, '{0} minute ago', value))
                    : ( localizeWithPath(_moduleId, 11, '{0} min ago', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 12, '{0} minutes ago', value))
                    : ( localizeWithPath(_moduleId, 13, '{0} mins ago', value));
            }
        }
        else {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 14, '{0} minute', value))
                    : ( localizeWithPath(_moduleId, 15, '{0} min', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 16, '{0} minutes', value))
                    : ( localizeWithPath(_moduleId, 17, '{0} mins', value));
            }
        }
    }
    if (seconds < day) {
        value = Math.floor(seconds / hour);
        if (appendAgoLabel) {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 18, '{0} hour ago', value))
                    : ( localizeWithPath(_moduleId, 19, '{0} hr ago', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 20, '{0} hours ago', value))
                    : ( localizeWithPath(_moduleId, 21, '{0} hrs ago', value));
            }
        }
        else {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 22, '{0} hour', value))
                    : ( localizeWithPath(_moduleId, 23, '{0} hr', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 24, '{0} hours', value))
                    : ( localizeWithPath(_moduleId, 25, '{0} hrs', value));
            }
        }
    }
    if (seconds < week) {
        value = Math.floor(seconds / day);
        if (appendAgoLabel) {
            return value === 1
                ? ( localizeWithPath(_moduleId, 26, '{0} day ago', value))
                : ( localizeWithPath(_moduleId, 27, '{0} days ago', value));
        }
        else {
            return value === 1
                ? ( localizeWithPath(_moduleId, 28, '{0} day', value))
                : ( localizeWithPath(_moduleId, 29, '{0} days', value));
        }
    }
    if (seconds < month) {
        value = Math.floor(seconds / week);
        if (appendAgoLabel) {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 30, '{0} week ago', value))
                    : ( localizeWithPath(_moduleId, 31, '{0} wk ago', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 32, '{0} weeks ago', value))
                    : ( localizeWithPath(_moduleId, 33, '{0} wks ago', value));
            }
        }
        else {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 34, '{0} week', value))
                    : ( localizeWithPath(_moduleId, 35, '{0} wk', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 36, '{0} weeks', value))
                    : ( localizeWithPath(_moduleId, 37, '{0} wks', value));
            }
        }
    }
    if (seconds < year) {
        value = Math.floor(seconds / month);
        if (appendAgoLabel) {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 38, '{0} month ago', value))
                    : ( localizeWithPath(_moduleId, 39, '{0} mo ago', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 40, '{0} months ago', value))
                    : ( localizeWithPath(_moduleId, 41, '{0} mos ago', value));
            }
        }
        else {
            if (value === 1) {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 42, '{0} month', value))
                    : ( localizeWithPath(_moduleId, 43, '{0} mo', value));
            }
            else {
                return useFullTimeWords
                    ? ( localizeWithPath(_moduleId, 44, '{0} months', value))
                    : ( localizeWithPath(_moduleId, 45, '{0} mos', value));
            }
        }
    }
    value = Math.floor(seconds / year);
    if (appendAgoLabel) {
        if (value === 1) {
            return useFullTimeWords
                ? ( localizeWithPath(_moduleId, 46, '{0} year ago', value))
                : ( localizeWithPath(_moduleId, 47, '{0} yr ago', value));
        }
        else {
            return useFullTimeWords
                ? ( localizeWithPath(_moduleId, 48, '{0} years ago', value))
                : ( localizeWithPath(_moduleId, 49, '{0} yrs ago', value));
        }
    }
    else {
        if (value === 1) {
            return useFullTimeWords
                ? ( localizeWithPath(_moduleId, 50, '{0} year', value))
                : ( localizeWithPath(_moduleId, 51, '{0} yr', value));
        }
        else {
            return useFullTimeWords
                ? ( localizeWithPath(_moduleId, 52, '{0} years', value))
                : ( localizeWithPath(_moduleId, 53, '{0} yrs', value));
        }
    }
}
function getDurationString(ms, useFullTimeWords) {
    const seconds = Math.abs(ms / 1000);
    if (seconds < 1) {
        return useFullTimeWords
            ? ( localizeWithPath(_moduleId, 54, '{0} milliseconds', ms))
            : ( localizeWithPath(_moduleId, 55, '{0}ms', ms));
    }
    if (seconds < minute) {
        return useFullTimeWords
            ? ( localizeWithPath(_moduleId, 56, '{0} seconds', Math.round(ms) / 1000))
            : ( localizeWithPath(_moduleId, 57, '{0}s', Math.round(ms) / 1000));
    }
    if (seconds < hour) {
        return useFullTimeWords
            ? ( localizeWithPath(_moduleId, 58, '{0} minutes', Math.round(ms / (1000 * minute))))
            : ( localizeWithPath(_moduleId, 59, '{0} mins', Math.round(ms / (1000 * minute))));
    }
    if (seconds < day) {
        return useFullTimeWords
            ? ( localizeWithPath(_moduleId, 60, '{0} hours', Math.round(ms / (1000 * hour))))
            : ( localizeWithPath(_moduleId, 61, '{0} hrs', Math.round(ms / (1000 * hour))));
    }
    return ( localizeWithPath(_moduleId, 62, '{0} days', Math.round(ms / (1000 * day))));
}
function toLocalISOString(date) {
    return date.getFullYear() +
        '-' + String(date.getMonth() + 1).padStart(2, '0') +
        '-' + String(date.getDate()).padStart(2, '0') +
        'T' + String(date.getHours()).padStart(2, '0') +
        ':' + String(date.getMinutes()).padStart(2, '0') +
        ':' + String(date.getSeconds()).padStart(2, '0') +
        '.' + (date.getMilliseconds() / 1000).toFixed(3).slice(2, 5) +
        'Z';
}
export { fromNow, getDurationString, toLocalISOString };
