<commit_before>import Vue from 'vue';
import App from './components/App.vue';
import vClickOutside from 'v-click-outside';

Vue.use(vClickOutside);

Vue.directive('portal', {
    inserted(el) {
        document.body.appendChild(el);
    }
});

Vue.filter('date', function(value) {
    return (new Date(value * 1000)).toLocaleDateString([], { month: 'numeric', day: 'numeric' });
});

Vue.filter('time', function(value) {
    return (new Date(value * 1000)).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
});

Vue.filter('duration', function(value) {
    let days = Math.floor(value / 86400);
    value -= days * 86400;
    let hours = Math.floor(value / 3600) % 24;
    value -= hours * 3600;
    let minutes = Math.floor(value / 60) % 60;
    value -= minutes * 60;
    let seconds = value % 60;

    // Add leading zeros
    if (days || hours)
        minutes = ('0' + minutes).substr(-2);
    seconds = ('0' + seconds).substr(-2);

    if (days)
        return `${days}d ${hours}h ${minutes}m ${seconds}s`;
    if (hours)
        return `${hours}h ${minutes}m ${seconds}s`;
    return `${minutes}m ${seconds}s`;
});

new Vue(App).$mount('#app');<commit_msg>Fix issues with negative durations<commit_after>import Vue from 'vue';
import App from './components/App.vue';
import vClickOutside from 'v-click-outside';

Vue.use(vClickOutside);

Vue.directive('portal', {
    inserted(el) {
        document.body.appendChild(el);
    }
});

Vue.filter('date', function(value) {
    return (new Date(value * 1000)).toLocaleDateString([], { month: 'numeric', day: 'numeric' });
});

Vue.filter('time', function(value) {
    return (new Date(value * 1000)).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
});

Vue.filter('duration', function(value) {
    let negative = (value < 0) ? '-' : '';
    value = Math.abs(value);

    let days = Math.floor(value / 86400);
    value -= days * 86400;
    let hours = Math.floor(value / 3600) % 24;
    value -= hours * 3600;
    let minutes = Math.floor(value / 60) % 60;
    value -= minutes * 60;
    let seconds = value % 60;

    // Add leading zeros
    if (days || hours)
        minutes = ('0' + minutes).substr(-2);
    seconds = ('0' + seconds).substr(-2);

    if (days)
        return `${negative}${days}d ${hours}h ${minutes}m ${seconds}s`;
    if (hours)
        return `${negative}${hours}h ${minutes}m ${seconds}s`;
    return `${negative}${minutes}m ${seconds}s`;
});

new Vue(App).$mount('#app');
{'fraction_non_alphanumeric': 0.1950826279725917, 'fraction_numerical': 0.03345425231761386, 'mean_word_length': 3.331588132635253, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '2043353', 'n_tokens_mistral': 914, 'n_tokens_neox': 832, 'n_words': 199}