<commit_before>const MONTHS_TO_YEAR: i32 = 12;
const MICROS_TO_HOUR: i64 = 3600000000;
const MICROS_TO_MINUTE: i64 = 60000000;
const MICROS_TO_SECOND: i64 = 1000000;

pub fn get_year_month_interval(months: i32) -> (i32, i8) {
    let years: i32 = months/MONTHS_TO_YEAR;
    let months: i8 = (months - (years * MONTHS_TO_YEAR)) as i8;
    (years, months)
}

pub fn get_day_time_interval(microseconds: i64) -> (i64, i8, f64) {
    let hours: i64 = microseconds/MICROS_TO_HOUR;
    let current_hours: i64 = hours * MICROS_TO_HOUR;
    let minutes: i64 = (microseconds - current_hours)/MICROS_TO_MINUTE;
    let seconds: f64 = (microseconds - (current_hours+(minutes * MICROS_TO_MINUTE))) as f64/MICROS_TO_SECOND as f64;
    (hours, minutes as i8, seconds)
}<commit_msg>test(helpers): add tests for deriving the year month interval and day time interval<commit_after>const MONTHS_TO_YEAR: i32 = 12;
const MICROS_TO_HOUR: i64 = 3600000000;
const MICROS_TO_MINUTE: i64 = 60000000;
const MICROS_TO_SECOND: i64 = 1000000;

pub fn get_year_month_interval(months: i32) -> (i32, i8) {
    let years: i32 = months/MONTHS_TO_YEAR;
    let months: i8 = (months - (years * MONTHS_TO_YEAR)) as i8;
    (years, months)
}

pub fn get_day_time_interval(microseconds: i64) -> (i64, i8, f64) {
    let hours: i64 = microseconds/MICROS_TO_HOUR;
    let current_hours: i64 = hours * MICROS_TO_HOUR;
    let minutes: i64 = (microseconds - current_hours)/MICROS_TO_MINUTE;
    let seconds: f64 = (microseconds - (current_hours+(minutes * MICROS_TO_MINUTE))) as f64/MICROS_TO_SECOND as f64;
    (hours, minutes as i8, seconds)
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn negative_year_month_interval() {
        let months = i32::min_value();
        let (years, months) = get_year_month_interval(months);
        assert!(years == -178956970);
        assert!(months == -8);
    }

    #[test]
    fn positive_year_month_interval() {
        let months = i32::max_value();
        let (years, months) = get_year_month_interval(months);
        assert!(years == 178956970);
        assert!(months == 7);
    }

    #[test]
    fn negative_day_time_interval() {
        let microseconds = -7199000000;
        let (hours, minutes, seconds) = get_day_time_interval(microseconds);
        assert!(hours == -1);
        assert!(minutes == -59);
        assert!(seconds == -59.0);
    }

    #[test]
    fn postive_day_time_interval() {
        let microseconds = 7199000000;
        let (hours, minutes, seconds) = get_day_time_interval(microseconds);
        assert!(hours == 1);
        assert!(minutes == 59);
        assert!(seconds == 59.0);
    }

    #[test]
    fn day_time_remaining_milliseconds() {
        let microseconds = 7199001000;
        let (hours, minutes, seconds) = get_day_time_interval(microseconds);
        assert!(hours == 1);
        assert!(minutes == 59);
        assert!(seconds == 59.001);
    }

    #[test]
    fn day_time_remaining_millisecond() {
        let microseconds = 7199000001;
        let (hours, minutes, seconds) = get_day_time_interval(microseconds);
        assert!(hours == 1);
        assert!(minutes == 59);
        assert!(seconds == 59.000001);
    }
}
{'fraction_non_alphanumeric': 0.12390488110137672, 'fraction_numerical': 0.0697747183979975, 'mean_word_length': 3.297043010752688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '4067832', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1125, 'n_words': 257}