<commit_before>import moment from 'moment';

export const getTimePercentage = (start_time, purchase_time, expiry_time) => {
    const duration_from_purchase = moment.duration(moment.unix(expiry_time).diff(moment.unix(purchase_time)));
    const duration_from_now = moment.duration(moment.unix(expiry_time).diff(start_time));
    let percentage = 100;
    const duration_unit = getDurationUnit(duration_from_now);

    if (duration_unit === 'days') {
        percentage = (duration_from_now.asDays() / duration_from_purchase.asDays()) * 100;
    } else if (duration_unit === 'hours') {
        percentage = (duration_from_now.asHours() / duration_from_purchase.asHours()) * 100;
    } else if (duration_unit === 'minutes') {
        percentage = (duration_from_now.asMinutes() / duration_from_purchase.asMinutes()) * 100;
    } else if (duration_unit === 'seconds') {
        percentage = (duration_from_now.asSeconds() / duration_from_purchase.asSeconds()) * 100;
    }
    return percentage;
};

const getDurationUnit = (obj_duration) => {
    if (obj_duration) {
        if (obj_duration.asDays() > 1) {
            return 'days';
        } else if (obj_duration.asHours() > 1 && obj_duration.asDays() <= 1) {
            return 'hours';
        } else if (obj_duration.asMinutes() > 1 && obj_duration.asHours() <= 1) {
            return 'minutes';
        } else if (obj_duration.asSeconds() > 1 && obj_duration.asMinutes() <= 1) {
            return 'seconds';
        }
    }
    return null;
};<commit_msg>returned floor percentage<commit_after>import moment from 'moment';

export const getTimePercentage = (start_time, purchase_time, expiry_time) => {
    const duration_from_purchase = moment.duration(moment.unix(expiry_time).diff(moment.unix(purchase_time)));
    const duration_from_now = moment.duration(moment.unix(expiry_time).diff(start_time));
    let percentage = 0;
    const duration_unit = getDurationUnit(duration_from_now);

    if (duration_unit === 'days') {
        percentage = (duration_from_now.asDays() / duration_from_purchase.asDays()) * 100;
    } else if (duration_unit === 'hours') {
        percentage = (duration_from_now.asHours() / duration_from_purchase.asHours()) * 100;
    } else if (duration_unit === 'minutes') {
        percentage = (duration_from_now.asMinutes() / duration_from_purchase.asMinutes()) * 100;
    } else if (duration_unit === 'seconds') {
        percentage = (duration_from_now.asSeconds() / duration_from_purchase.asSeconds()) * 100;
    }
    return Math.floor(percentage);
};

const getDurationUnit = (obj_duration) => {
    if (obj_duration) {
        if (obj_duration.asDays() > 1) {
            return 'days';
        } else if (obj_duration.asHours() > 1 && obj_duration.asDays() <= 1) {
            return 'hours';
        } else if (obj_duration.asMinutes() > 1 && obj_duration.asHours() <= 1) {
            return 'minutes';
        } else if (obj_duration.asSeconds() > 1 && obj_duration.asMinutes() <= 1) {
            return 'seconds';
        }
    }
    return null;
};
{'fraction_non_alphanumeric': 0.13877952755905512, 'fraction_numerical': 0.013779527559055118, 'mean_word_length': 3.3681948424068766, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '4673332', 'n_tokens_mistral': 1011, 'n_tokens_neox': 952, 'n_words': 184}