Mini Calendar C

Hello everyone, I am doing the C mini calendar project.
The code does not give me errors, only that I have been searching for more than 2 hours for an error that does not give me the correct answer.
In step 30 of the project I verify that the code is working correctly but:
input: “12 31 2019 367 ” → should output “1 1 2021”.
But i am getting on and on the output: “1 1 2020”.

If you could help me I would be very grateful to you.
Thank you.
Postscript: I’m from Colombia that’s why some prints are in Spanish.

#include <stdio.h>
#include <stdbool.h>
bool is_leap_year(int year) {
  if (year % 4 != 0) {
    return false;
  } else if (year % 100 != 0) {
    return true;
  } else if (year % 400 != 0) {
    return false;
  } else {
    return true;
  }
}
int days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void add_days_to_date(int* mm, int* dd, int* yy, int days_left_to_add) {
  int days_left_in_month = days_in_month[*mm] - *dd; 
  while (days_left_in_month > 0) {
    if (days_in_month[2] && is_leap_year(*yy) == true) {
      days_left_in_month++;
    }
  }
  if (days_left_to_add > days_left_in_month) {
    days_left_to_add -= days_left_in_month + 1;
    *dd = 1;
    if (*mm == 12) {
      *mm = 1;
      *yy = *yy +1;
      } else {
        *mm = *mm + 1;
      }
    } else {
    *dd += days_left_to_add;
    days_left_to_add = 0;
  }
}
int main() {
  int year;
  printf("Elija un año entre 1800 y 10000: ");
  scanf("%i", &year);
  is_leap_year(year);
  if (is_leap_year(year) == true) {
    printf("Es año bisiesto\n");
  } else {
    printf("No es bisiesto\n");
  }
  
  int mm, dd, yy, days_left_to_add;
  printf("Please enter a date between the years 1800 and 10000 in the format mm dd yy and provide the number of days to add to this date: ");
  scanf("%i%i%i%i", &mm, &dd, &yy, &days_left_to_add);
  add_days_to_date(&mm, &dd, &yy, days_left_to_add);
  printf("%i %i %i\n", mm, dd, yy);
}
void add_days_to_date(int *mm,int *dd, int *yy, int days_left_to_add) { int days_left_in_month; while (days_left_to_add > 0) { days_left_in_month = days_in_month[*mm] - *dd; // Step 23 if (*mm == 2 && is_leap_year(*yy)) { // February leap year case => From 28 to 29 days. days_left_in_month++; } if (days_left_to_add >= days_left_in_month) { // if more days left can be add in a month days_left_to_add -= days_left_in_month; // jump to the first day of the next month *dd = 1; // we are on the first day of the next month, but what is the next month ? days_left_to_add--; if (*mm != 12) { // if last month is Not December *mm = *mm + 1; // pass to the next month } else { *mm = 1; // if it is December *yy = *yy + 1; // pass to the next month => January } } else { // (days_left_to_add < days_left_in_month) *dd = *dd + days_left_to_add; // simply add the days days_left_to_add = 0; // no more days to add ! } } }

Here the solution of the function you needed