<commit_before>import { Utils } from '../global/globalIncludes';

const formatTime = Utils.FormatTime;

function naivePlural(text: string, count: number): string {
    if (count > 1) {
        return text + 's';
    }
    return text;
}

function formatDuration(startMs: number, endMs: number): string {
    let ms = endMs - startMs;
    let minutes = ms / 1000 / 60;
    let hours = Math.floor(minutes / 60);

    if (hours > 2) {
        return 'Until ' + formatTime(endMs).toLowerCase();
    }

    let durationText = '';
    if (hours > 0) {
        durationText = `${hours} ${naivePlural('hour', hours)} `;
        minutes = minutes - hours * 60;
    }

    if (minutes > 0) {
        durationText = `${durationText}${Math.ceil(minutes)} min`;
    }

    return durationText.trim();
}

module.exports = formatDuration;
<commit_msg>Fix duration<commit_after>import { Utils } from '../global/globalIncludes';

const formatTime = Utils.FormatTime;

function naivePlural(text: string, count: number): string {
    if (count > 1) {
        return text + 's';
    }
    return text;
}

function formatDuration(startTime, endTime): string {
    const startMs = new Date(startTime).getTime();
    const endMs = new Date(endTime).getTime();
    let ms = endMs - startMs;
    let minutes = ms / 1000 / 60;
    let hours = Math.floor(minutes / 60);

    if (hours > 2) {
        return 'Until ' + formatTime(endMs).toLowerCase();
    }

    let durationText = '';
    if (hours > 0) {
        durationText = `${hours} ${naivePlural('hour', hours)} `;
        minutes = minutes - hours * 60;
    }

    if (minutes > 0) {
        durationText = `${durationText}${Math.ceil(minutes)} min`;
    }
    debugger;

    return durationText.trim();
}

module.exports = formatDuration;

{'fraction_non_alphanumeric': 0.14398644833427443, 'fraction_numerical': 0.015810276679841896, 'mean_word_length': 2.7148846960167714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2332748', 'n_tokens_mistral': 599, 'n_tokens_neox': 554, 'n_words': 146}