<commit_before>use std::fmt;

#[derive(PartialEq)]
pub struct Clock {
    hours: i32,
    minutes: i32,
}

impl Clock {
    pub fn new(hours: i32, minutes: i32) -> Self {
        return Clock { hours, minutes };
    }

    pub fn add_minutes(&self, minutes: i32) -> Self {
        return Clock::new(self.hours, self.minutes + minutes);
    }
}

impl fmt::Display for Clock {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let minutes = self.minutes % 60;
        let additional_hours = self.minutes / 60;
        let mut hours = self.hours + additional_hours;
        while hours < 0 {
            hours += 24
        }
        let hours = hours % 24;
        write!(f, "{:02}:{:02}", hours, minutes)
    }
}

impl fmt::Debug for Clock {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{:02}:{:02}", self.hours, self.minutes)
    }
}<commit_msg>Remove hours from internal state<commit_after>use std::fmt;

#[derive(PartialEq)]
pub struct Clock {
    minutes: i32,
}

impl Clock {
    pub fn new(hours: i32, minutes: i32) -> Self {
        return Clock {
            minutes: (hours * 60) + minutes,
        };
    }

    pub fn add_minutes(&self, minutes: i32) -> Self {
        return Clock::new(0, self.minutes + minutes);
    }
}

impl fmt::Display for Clock {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let mut minutes = self.minutes;
        let mut hours = 0;

        while minutes < 0 {
            hours -= 1;
            minutes += 60
        }
        while minutes >= 60 {
            hours += 1;
            minutes -= 60
        }
        while hours < 0 {
            hours += 24;
        }
        while hours >= 24 {
            hours -= 24;
        }

        write!(f, "{:02}:{:02}", hours, minutes)
    }
}

impl fmt::Debug for Clock {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.minutes)
    }
}
{'fraction_non_alphanumeric': 0.15282051282051282, 'fraction_numerical': 0.030256410256410255, 'mean_word_length': 1.9382530120481927, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 17, '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': '1420130', 'n_tokens_mistral': 688, 'n_tokens_neox': 618, 'n_words': 178}