<commit_before>package de.stephanlindauer.criticalmaps.helper;


import java.util.Date;

public class TimeToWordStringConverter {
    private static final int SECOND_MILLIS = 1000;
    private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
    private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
    private static final int DAY_MILLIS = 24 * HOUR_MILLIS;

    public static String getTimeAgo(Date date) {
        long past = date.getTime();
        long now = new Date().getTime();

        final long diff = now - past;
        if (diff < MINUTE_MILLIS) {
            return "just now";
        } else if (diff < 2 * MINUTE_MILLIS) {
            return "a minute ago";
        } else if (diff < 50 * MINUTE_MILLIS) {
            return diff / MINUTE_MILLIS + " minutes ago";
        } else if (diff < 90 * MINUTE_MILLIS) {
            return "an hour ago";
        } else if (diff < 24 * HOUR_MILLIS) {
            return diff / HOUR_MILLIS + " hours ago";
        } else if (diff < 48 * HOUR_MILLIS) {
            return "yesterday";
        } else {
            return diff / DAY_MILLIS + " days ago";
        }
    }
}<commit_msg>localization<commit_after>package de.stephanlindauer.criticalmaps.helper;


import android.content.Context;
import de.stephanlindauer.criticalmaps.R;

import java.util.Date;

public class TimeToWordStringConverter {
    private static final int SECOND_MILLIS = 1000;
    private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
    private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
    private static final int DAY_MILLIS = 24 * HOUR_MILLIS;

    public static String getTimeAgo(Date date, Context context) {
        long past = date.getTime();
        long now = new Date().getTime();

        final long diff = now - past;
        if (diff < MINUTE_MILLIS) {
            return context.getString( R.string.timetoword_justnow );
        } else if (diff < 2 * MINUTE_MILLIS) {
            return context.getString( R.string.timetoword_aminuteago );
        } else if (diff < 50 * MINUTE_MILLIS) {
            return String.format( context.getString( R.string.timetoword_minutesago ), diff / MINUTE_MILLIS );
        } else if (diff < 90 * MINUTE_MILLIS) {
            return context.getString( R.string.timetoword_anhourago );
        } else if (diff < 24 * HOUR_MILLIS) {
            return String.format( context.getString( R.string.timetoword_hoursago ), diff / HOUR_MILLIS);
        } else if (diff < 48 * HOUR_MILLIS) {
            return context.getString( R.string.timetoword_yesterday );
        } else {
            return String.format( context.getString( R.string.timetoword_daysago) , diff / DAY_MILLIS );
        }
    }
}
{'fraction_non_alphanumeric': 0.09272997032640949, 'fraction_numerical': 0.014094955489614243, 'mean_word_length': 2.466580976863753, 'pattern_counts': {'":': 0, '<': 15, '<?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': '7662170', 'n_tokens_mistral': 901, 'n_tokens_neox': 846, 'n_words': 224}