Repository: awslabs/llrt
File: modules/llrt_intl/src/pattern_formatter.rs (Rust)

Code before:
        if hours >= 0 {
            result.push('+');
        }
        let mut buf = itoa::Buffer::new();
        result.push_str(buf.format(hours));
        if mins != 0 {
            result.push(':');
            if mins < 10 {
                result.push('0');
            }
            result.push_str(buf.format(mins));
        }
    }
}

/// Combine date and time strings using a datetime pattern
pub fn combine_datetime(date: &str, time: &str, pattern: &str) -> String {
    pattern.replace("{1}", date).replace("{0}", time)
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::cldr_data::get_locale_data;
    use jiff::{civil::Date, tz::TimeZone, Zoned};

    fn make_dt(year: i16, month: i8, day: i8, hour: i8, min: i8, sec: i8) -> Zoned {
        let tz = TimeZone::get("UTC").unwrap();

        Date::new(year, month, day)
            .unwrap()
            .at(hour, min, sec, 0)
            .to_zoned(tz)
            .unwrap()
    }

    #[test]
    fn test_format_year() {
        let dt = make_dt(2024, 3, 15, 10, 30, 45);
        let locale = get_locale_data("en-US");

        assert!(format_with_pattern(&dt, "y", locale, None).contains("2024"));
        assert!(format_with_pattern(&dt, "yy", locale, None).contains("24"));
        assert!(format_with_pattern(&dt, "yyyy", locale, None).contains("2024"));
    }

    #[test]
    fn test_format_month() {
        let dt = make_dt(2024, 3, 15, 10, 30, 45);
        let locale = get_locale_data("en-US");


Review comment (suggestion):
```suggestion
    fn make_dt(year: i16, month: i8, day: i8, hour: i8, min: i8, sec: i8) -> Zoned {
        jiff::civil::date(year, month, day).at(hour, min, sec, 0).to_zoned(TimeZone::UTC).unwrap()
```

Code after:
        if mins != 0 {
            result.push(':');
            if mins < 10 {
                result.push('0');
            }
            result.push_str(buf.format(mins));
        }
    }
}

/// Combine date and time strings using a datetime pattern
pub fn combine_datetime(date: &str, time: &str, pattern: &str) -> String {
    pattern.replace("{1}", date).replace("{0}", time)
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::cldr_data::get_locale_data;
    use jiff::{civil, tz::TimeZone, Zoned};

    fn make_dt(year: i16, month: i8, day: i8, hour: i8, min: i8, sec: i8) -> Zoned {
        civil::date(year, month, day)
            .at(hour, min, sec, 0)
            .to_zoned(TimeZone::UTC)
            .unwrap()
    }

    #[test]
    fn test_format_year() {
        let dt = make_dt(2024, 3, 15, 10, 30, 45);
        let locale = get_locale_data("en-US");

        assert!(format_with_pattern(&dt, "y", locale, None).contains("2024"));
        assert!(format_with_pattern(&dt, "yy", locale, None).contains("24"));
        assert!(format_with_pattern(&dt, "yyyy", locale, None).contains("2024"));
    }

    #[test]
    fn test_format_month() {
        let dt = make_dt(2024, 3, 15, 10, 30, 45);
        let locale = get_locale_data("en-US");

        assert_eq!(format_with_pattern(&dt, "M", locale, None), "3");
        assert_eq!(format_with_pattern(&dt, "MM", locale, None), "03");
        assert_eq!(format_with_pattern(&dt, "MMM", locale, None), "Mar");
        assert_eq!(format_with_pattern(&dt, "MMMM", locale, None), "March");
    }

    #[test]
    fn test_format_day() {