<commit_before>package com.alexstyl.specialdates.date;

import android.content.res.Resources;

import com.alexstyl.specialdates.R;
import com.alexstyl.specialdates.contact.Contact;
import com.alexstyl.specialdates.events.peopleevents.EventType;

/**
 * A representation of an event, affiliated to a contact
 */
public final class ContactEvent {

    private final EventType eventType;
    private final Contact contact;
    private final Date date;

    public ContactEvent(EventType eventType, Date date, Contact contact) {
        this.eventType = eventType;
        this.date = date;
        this.contact = contact;
    }

    public String getLabel(Resources resources) {
        if (eventType == EventType.BIRTHDAY) {
            Date birthday = contact.getDateOfBirth();
            if (birthday.hasYear()) {
                int age = date.getYear() - birthday.getYear();
                if (age > 0) {
                    return resources.getString(R.string.turns_age, age);
                }
            }
        }
        return resources.getString(eventType.nameRes());<commit_msg>Use existing date to calculate<commit_after>package com.alexstyl.specialdates.date;

import android.content.res.Resources;

import com.alexstyl.specialdates.R;
import com.alexstyl.specialdates.contact.Contact;
import com.alexstyl.specialdates.events.peopleevents.EventType;

/**
 * A representation of an event, affiliated to a contact
 */
public final class ContactEvent {

    private final EventType eventType;
    private final Contact contact;
    private final Date date;

    public ContactEvent(EventType eventType, Date date, Contact contact) {
        this.eventType = eventType;
        this.date = date;
        this.contact = contact;
    }

    public String getLabel(Resources resources) {
        if (eventType == EventType.BIRTHDAY) {
            if (date.hasYear()) {
                int age = Date.CURRENT_YEAR - date.getYear();
                if (age > 0) {
                    return resources.getString(R.string.turns_age, age);
                }
            }
        }
        return resources.getString(eventType.nameRes());
{'fraction_non_alphanumeric': 0.0919701213818861, 'fraction_numerical': 0.0009337068160597573, 'mean_word_length': 2.5246710526315788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6036479', 'n_tokens_mistral': 597, 'n_tokens_neox': 569, 'n_words': 144}