Данный отчёт сгенерирован 10.02.2023 18:21:31 UTC.
HTML версия (этот сайт) сгенерирован 10.02.2023 18:21:38 UTC.
Коммит: [bfeb65b9] add automatic zip creation
10.02.2023 18:21:31
Задача: День народження 10.02.2023 18:21:31
Описание: Визначте функцію brth(s1,s2), яка повертає кількість днів, що залишилися до дня народження. Функція отримує два рядки: у першій записано дату народження у форматі: "дд.мм" , а в другій – поточну дату в форматі: "дд.мм.гггг". Наприклад, brth("02.07","11.06.2016") = 21. 10.02.2023 18:21:31
Решений: 52 10.02.2023 18:21:31
День народження 10.02.2023 18:21:31
 function brth(b, dt) {
    let [b_day, b_mounth] = b.split('.').map(x=>+x);
    let [day, mounth, year] = dt.split('.').map(x=>+x);
    let byrthday = new Date(year, b_mounth-1, b_day);
    let data = new Date(year, mounth-1, day);
    if (data > byrthday) byrthday = new Date(year+1,b_mounth-1, b_day);   
    return Math.round( (byrthday - data)/(1000*60*60*24));
}
 function brth(s1, s2)
{
    date1 = s1.split('.')
    date2 = s2.split('.')
    days1 = 0
    days2 = 0
    
         if(date1[1]=='01') days1 = 0
    else if(date1[1]=='02') days1 = 31
    else if(date1[1]=='03') days1 = 59
    else if(date1[1]=='04') days1 = 90
    else if(date1[1]=='05') days1 = 120
    else if(date1[1]=='06') days1 = 151
    else if(date1[1]=='07') days1 = 181
    else if(date1[1]=='08') days1 = 212
    else if(date1[1]=='09') days1 = 243
    else if(date1[1]=='10') days1 = 273
    else if(date1[1]=='11') days1 = 304
    else if(date1[1]=='12') days1 = 334
    days1+=Number(date1[0])
    
         if(date1[1]=='01') days1 = 0
    else if(date2[1]=='02') days2 = 31
    else if(date2[1]=='03') days2 = 59
    else if(date2[1]=='04') days2 = 90
    else if(date2[1]=='05') days2 = 120
    else if(date2[1]=='06') days2 = 151
    else if(date2[1]=='07') days2 = 181
    else if(date2[1]=='08') days2 = 212
    else if(date2[1]=='09') days2 = 243
    else if(date2[1]=='10') days2 = 273
    else if(date2[1]=='11') days2 = 304
    else if(date2[1]=='12') days2 = 334
    days2+=Number(date2[0])
    
    if(days1>=days2)
    {
        if(Number(date2[2])%4==0) 
        {
            days1+=1
        }
        return days1-days2
    }
    else 
    {
        return 365-days2+days1
    }
}
 function brth(s1, s2)
{
    let days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    let t1 = s1.split('.');
    let t2 = s2.split('.');
    let d1 = +t1[0],
        m1 = +t1[1],
        y1;
    let d2 = +t2[0],
        m2 = +t2[1],
        y2 = +t2[2];
    if(m1< m2 || (m1==m2 && d1< d2)){
        y1 = y2+1;
    } else {
        y1 = y2;
    }
    let res_days = 0;
    for(let y = y2; ; y++){
        if(y%4==0){
            days_in_month[1] = 29;
        } else {
            days_in_month[1] = 28;
        }
        for(let m = m2-1; m<=11; m++){
            for(let d = d2; d<=days_in_month[m]; d++, res_days++){
                if(m==m1-1 && d==d1){
                    return res_days;
                }
            }
            d2 = 1;
        }
        m2 = 1;
    }
    
}
 function brth(s1, s2) {
    let count = 0;

    let monthes = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


    let arr1 = s1.split(".")
    let arr2 = s2.split(".")

    if (arr2[2] % 4 == 0) {
        monthes[1] = 29
    }

    while (true) {
        if (arr1[0] == arr2[0] && arr1[1] == arr2[1]) {
            return count
        }

        count++;
        arr2[0]++
        if (arr2[0] > monthes[arr2[1] - 1]) {
            arr2[0] -= monthes[[arr2[1] - 1]]
            arr2[1]++
        }
        if(arr2[1]>12)
        {
            arr2[1]-=12;
            arr2[2]++;

            if (arr2[2] % 4 == 0) {
                monthes[1] = 29
            }
            else{
                monthes[1]=28
            }
        }
    }
}
 function brth(s1, s2) {
    let arr1 = s1.split('.');
    let arr2 = s2.split('.');
    let brDay = +arr1[0]; 
    let brMon = +arr1[1]; 
    let nowDay = +arr2[0];
    let nowMon = +arr2[1];
    let nowYear = +arr2[2]; 
    let allMonth = 12;
    let sumDayMonth = 0; 
    let daysMons = 0; // Число дней в месяце 
    let res = 0;
     
    if(nowMon == brMon && brDay > nowDay) {
        res = brDay - nowDay;
        if (res < 0) {
            res = -res;
        }
        return res;
    } else {
        let cond = 0;
        if ((nowMon > 9 && brMon < 10)) {
            cond = allMonth - nowMon + brMon;
        } else if (nowMon > brMon) {
            cond = allMonth - nowMon + brMon;
        } else if (nowMon == brMon){
            cond = allMonth - (nowDay - brDay) + 1;
        } else {
            cond = brMon - nowMon; // Сколько месяцев считать
        }
        let numDay = 0;
        if (cond < 0) {
            cond = -cond; 
        }
        for (let a = 0; a < cond; a++, nowMon++) {
            if (nowMon == 13) {
                nowMon = 1;
            }
            numDay = checkDaysMonth(nowMon, nowYear); 
            sumDayMonth += numDay; 
        }
        res = sumDayMonth - nowDay + brDay; 
        return res;
    }

}

function checkLeapYear(year) {
    for (let i = 0; i <= year; i += 4) {
        if (i == year) {
            return 29;
        }
    }
    return 28;
}

function checkDaysMonth(month, year) {
    if (month == 4 || month == 6 || month == 9 || month == 11) {
        return 30;
    } else if (month == 2) {
        if (year % 4 == 0 && year % 100 == 0 && year % 400 == 0 && year != 2000 || year == 2016) {
            return 29;
        } else {
            return 28;
        }
    } else {
        return 31; 
    }
}
 const daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function daysIn(month, year) {
    if (month === 2 && isLeap(year)) return 29;
    return daysInMonths[month - 1];
}

function isLeap(year) {
    if (year % 400 === 0) return true;
    if (year % 100 === 0) return false;
    return year % 4 === 0;
}

class Date {
    constructor(day, month, year) {
        this.day = parseInt(day);
        this.month = parseInt(month);
        this.year = parseInt(year);
    }

    static from(string) {
        let parts = string.split('.');
        return new Date(parts[0], parts[1], parts[2]);
    }
}

function brth(target, current) {
    let currentDate = Date.from(current);
    let targetDate = Date.from(target + '.' + currentDate.year);
    let rearranged = rearrangeDate(currentDate, targetDate);
    let assumed = daysInBetween(rearranged[0], rearranged[1]);
    if (currentDate !== rearranged[0])
        return 365 - assumed;
    return assumed;
}

function rearrangeDate(firstDate, secondDate) {
    let initialOrder = [firstDate, secondDate];
    if (firstDate.month < secondDate.month) return initialOrder;
    if (firstDate.month === secondDate.month && firstDate.day <= secondDate.day) return initialOrder;
    return [secondDate, firstDate];
}

function daysInBetween(firstDate, secondDate) {
    if (firstDate.month === secondDate.month) {
        return secondDate.day - firstDate.day;
    }
    let days = daysIn(firstDate.month) - firstDate.day + secondDate.day;
    for (let month = firstDate.month + 1; month < secondDate.month; month++)
        days += daysIn(month, firstDate.year);
    return days;
}
 function brth(dr, date) {
    const drNums = dr.split('.');
    const drD = parseInt(drNums[0]);
    const drM = parseInt(drNums[1]);
    const dateNums = date.split('.');
    const dateD = parseInt(dateNums[0]);
    const dateM = parseInt(dateNums[1]);
    let dateY = parseInt(dateNums[2]);
    if (dateM == drM && dateD <= drD) return drD - dateD;
    let days = 0;
    let month = dateM;
    do {
        let monthDays = new Date(dateY, month, 0).getDate();
        if (month == dateM) days += monthDays - dateD; 
        else days += monthDays;
        if (month == 12) {
            month = 1;
            dateY++;
        } else {
            month++;
        }
    } while (month != drM);
    return days + drD;}
 function brth(s1,s2){
    let year = "";
    let months = [0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    let day = +(s2[0] + s2[1]);
    let currentMonth = +(s2[3] + s2[4]);
    let dayBrth = +(s1[0] + s1[1]);
    let brthMonth = +(s1[3] + s1[4]);
    let days = 0;

    if (currentMonth === brthMonth && dayBrth > day) return dayBrth - day;

    for (let i = 0; i < 4; i++) year += s2[6+i];
    parseInt(year);
    if (year % 4 === 0){
        if (year % 100 === 0 && year % 400 !== 0) months[2] = 28;
        else months[2] = 29;
    } else months[2] = 28;

    for (let i = currentMonth + 1; i !== brthMonth; i++){
        if (i === 13){
            i = 1;
            year++;
            if (year % 4 === 0){
                if (year % 100 === 0 && year % 400 !== 0) months[2] = 28;
                else months[2] = 29;
            } else months[2] = 28;
        }
        days += months[i];
    }
    days += (months[currentMonth] - day) + dayBrth;
    return days;
}
 function brth(s1,s2){
    let year = "";
    let months = [0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    let day = +(s2[0] + s2[1]);
    let currentMonth = +(s2[3] + s2[4]);
    let dayBrth = +(s1[0] + s1[1]);
    let brthMonth = +(s1[3] + s1[4]);
    let days = 0;

    if (currentMonth === brthMonth && dayBrth > day) return dayBrth - day;

    for (let i = 0; i < 4; i++) year += s2[6+i];
    parseInt(year);
    if (year % 4 === 0){
        if (year % 100 === 0 && year % 400 !== 0) months[2] = 28;
        else months[2] = 29;
    } else months[2] = 28;

    for (let i = currentMonth + 1; i !== brthMonth; i++){
        if (i === 13){
            i = 1;
            year++;
            if (year % 4 === 0){
                if (year % 100 === 0 && year % 400 !== 0) months[2] = 28;
                else months[2] = 29;
            } else months[2] = 28;
        }
        days += months[i];
    }
    days += (months[currentMonth] - day) + dayBrth;
    return days;
}
 function brth(brthday_date, current_date){
    brthday_date = brthday_date.split(".")
    current_date = current_date.split(".")
    let day_brhd = Number(brthday_date[0])
    let month_brhd = Number(brthday_date[1])
    let current_day = Number(current_date[0])
    let current_month = Number(current_date[1])
    let current_year = Number(current_date[2])
    const days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    const days_in_year = 365;
    let days_to_brthd=0
    if (current_month==month_brhd){
        if(day_brhd>current_day){
            return day_brhd-current_day
        }
        else {
            if(current_year%4==0){
                if(current_month>2){
                    return days_in_year-(current_day-day_brhd)
                }
                else{
                    return days_in_year-(current_day-day_brhd)+1
                }
            }
            else if((current_year+1)%4==0){
                if(current_month>=2){
                    return days_in_year-(current_day-day_brhd)+1
                }
                else{
                    return days_in_year-(current_day-day_brhd)
                }
            }
            else{
                return days_in_year-(current_day-day_brhd)
            }
        }
    }
    else if(current_month< month_brhd){
        for(let i = current_month; i< month_brhd-1;i++){
            days_to_brthd+=days_of_month[i];
        }
        days_to_brthd+= days_of_month[current_month-1]-current_day+day_brhd
        if(month_brhd-current_month==1&& current_month!=2){
            return days_of_month[current_month-1]-current_day+day_brhd
        }
        else if (month_brhd-current_month==1&& current_month==2){
            return days_of_month[current_month-1]-current_day+day_brhd  
        }
        else if(current_year%4==0){
            if(current_month<=2){
                return days_to_brthd+1
            }
            else{
                return days_to_brthd
            }
        }
        else{
            return days_to_brthd
        }
       
    }
    else{
        if(current_year%4==0 && current_month==2){
                for(let i = current_month;i<=11;i++){
                    days_to_brthd+=days_of_month[i];
                }
                days_to_brthd+=day_brhd +(days_of_month[current_month-1]-current_day+1)
                return days_to_brthd
        }
        else if(current_year+1%4==0){
            if(current_month==12 && month_brhd==1){
                 days_to_brthd+=(days_of_month[11]-current_day) + day_brhd
                 return days_to_brthd}
            else if(current_month==12 && month_brhd==2){
                days_to_brthd+= (days_of_month[11]-current_day) + day_brhd + days_of_month[0]
                return days_to_brthd
            }
            else if(current_month==12 && month_brhd>2){
                days_to_brthd+=(days_of_month[11]-current_day) + day_brhd;
                for(let i = 0; i< month_brhd-1; i++){
                    days_to_brthd+= days_of_month[i];
                }
                return days_to_brthd
            }
            else if(month_brhd==1){
                for(let i = current_month;i<=11;i++){
                    days_to_brthd+=days_of_month[i]
                }
                days_to_brthd+=day_brhd
                return days_to_brthd
            }
            else if(month_brhd==2){
                for(let i = current_month;i<=11;i++){
                    days_to_brthd+=days_of_month[i]
                }
                days_to_brthd+=day_brhd + days_of_month[0]
                return days_to_brthd
            }
            else if(month_brhd>2){
                for(let i = current_month;i<=11;i++){
                    days_to_brthd+=days_of_month[i]
                }
                for(let j = 0; j< month_brhd-1; j++){
                days_to_brthd+=days_of_month[i]
            }
            days_to_brthd+=day_brhd + (days_of_month[current_month-1]-current_day+1)+1
            return days_to_brthd
        } 
            }
            else{
                if(current_month==12 && month_brhd==1){
                    days_to_brthd+=(days_of_month[11]-current_day) + day_brhd
                    return days_to_brthd}
                else if(current_month==12 && month_brhd==2){
                    days_to_brthd+= (days_of_month[11]-current_day) + day_brhd + days_of_month[0]
                    return days_to_brthd
                }
                else if(current_month==12 && month_brhd>2){
                    days_to_brthd+=(days_of_month[11]-current_day) + day_brhd;
                    for(let i = 0; i< month_brhd-1; i++){
                        days_to_brthd+= days_of_month[i];
                    }
                    return days_to_brthd
                }
                else if(month_brhd==1){
                    for(let i = current_month;i<=11;i++){
                        days_to_brthd+=days_of_month[i]
                    }
                    days_to_brthd+=day_brhd
                    return days_to_brthd
                }
                else if(month_brhd==2){
                    for(let i = current_month;i<=11;i++){
                        days_to_brthd+=days_of_month[i]
                    }
                    days_to_brthd+=day_brhd + days_of_month[0] + + (days_of_month[current_month-1]-current_day)
                    return days_to_brthd
                }
                else if(month_brhd>2){
                    for(let i = current_month;i<=11;i++){
                        days_to_brthd+=days_of_month[i]
                    }
                   for(let j = 0; j< month_brhd-1; j++){
                    days_to_brthd+=days_of_month[j]
                }
                days_to_brthd+=day_brhd + (days_of_month[current_month-1]-current_day)
                return days_to_brthd
            }
            }
        }
    }
 function brth(s1, s2) {
    s1 = s1.split('.')
    s2 = s2.split('.')
    let day = s1[0]-s2[0];
    s2[1] = +s2[1]
    s1[1] = +s1[1]
    if(s1[1]==s2[1]){
    if(s1[0]>s2[0])
    return day;
    else
    return 365+day;
    }
    if(s2[1] > s1[1])
        s1[1] = 12 + s1[1];
    while(s2[1]< s1[1]){
    if(s1[1]>12){
        if(s2[1]<=12){
            if(s2[1]%2 == 0 && s2[1]< 8 || s2[1]%2 !== 0 && s2[1]>8)
            day+= 30;
        else 
            day += 31; 
      } else{
    if(s2[1] == 14 ){
        if(s2)
        day += 28;
    }else if(s2[1]%2 == 0 && s2[1]< 18 || s2[1]%2 !== 0 && s2[1]>18)
        day+= 30;
    else 
        day += 31;
   } 
    }else{
        if(s2[1] == 2 ){
            if(s2[2]%4 == 0)
            day += 29;
            else
            day+= 28
        }else if(s2[1]%2 == 0 && s2[1]< 8 || s2[1]%2 !== 0 && s2[1]>8)
            day+= 30;
        else 
            day += 31; 
    }
    s2[1]++;
    }
    return day;
}
 const daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function daysIn(month, year) {
    if (month === 2 && isLeap(year)) return 29;
    return daysInMonths[month - 1];
}

function isLeap(year) {
    if (year % 400 === 0) return true;
    if (year % 100 === 0) return false;
    return year % 4 === 0;
}

class Date {
    constructor(day, month, year) {
        this.day = parseInt(day);
        this.month = parseInt(month);
        this.year = parseInt(year);
    }

    static from(string) {
        let parts = string.split('.');
        return new Date(parts[0], parts[1], parts[2]);
    }
}

function brth(target, current) {
    let currentDate = Date.from(current);
    let targetDate = Date.from(target + '.' + currentDate.year);
    let rearranged = rearrangeDate(currentDate, targetDate);
    let assumed = daysInBetween(rearranged[0], rearranged[1]);
    if (currentDate !== rearranged[0])
        return 365 - assumed;
    return assumed;
}

function rearrangeDate(firstDate, secondDate) {
    let initialOrder = [firstDate, secondDate];
    if (firstDate.month < secondDate.month) return initialOrder;
    if (firstDate.month === secondDate.month && firstDate.day <= secondDate.day) return initialOrder;
    return [secondDate, firstDate];
}

function daysInBetween(firstDate, secondDate) {
    if (firstDate.month === secondDate.month) {
        return secondDate.day - firstDate.day;
    }
    let days = daysIn(firstDate.month) - firstDate.day + secondDate.day;
    for (let month = firstDate.month + 1; month < secondDate.month; month++)
        days += daysIn(month, firstDate.year);
    return days;
}
 function brth(s1, s2)
{
    const ONE_DAY = 24 * 60 * 60 * 1000;
    let currentDate = new Date(`${s2.substring(3,5)}.${s2.substring(0,2)}.${s2.substring(6)}`);
    let nextBrth = new Date(`${s1.substring(3)}.${s1.substring(0,2)}.${s2.substring(6)}`);
        
    if(currentDate > nextBrth) {
        nextBrth.setFullYear(nextBrth.getFullYear()+1);
    }
  
    return Math.round(Math.abs((currentDate-nextBrth)/ONE_DAY));
}

console.log(brth("14.03","28.02.2017"));   // 14
console.log(brth("02.02","12.07.1999"));   // 205
 function countDays(arr){
    let calendar={
      1:31, 
      2:28, 
      3:31, 
      4:30, 
      5:31, 
      6:30, 
      7:31,
      8:31, 
      9:30, 
      10:31,
      11:30, 
      12:31
    } 
    let daycount=0 
    for (let i=1; i< arr[1];i++){
      daycount+=calendar[i]
    } 
    daycount+=arr[0] 
    return daycount
}
function brth(s1, s2){
    let bdarr=s1.split('.').map(num=>parseInt(num))  
    let datearr=s2.split('.').map(num=>parseInt(num)) 
    let bd=countDays(bdarr) 
    let date=countDays(datearr) 
    let result=bd< date?365+bd-date:bd-date 
    if(datearr[1]<=2&&bdarr[1]>2&&datearr[2]%4==0){
        result++
    } 
    return result
}
 function brth(s1, s2)
{
    days = 0;
    days2 =0;
    numbers = s1.split('.');
    numbers2 = s2.split('.');
    if(numbers[1]=='01') days = 0;
    else if(numbers[1]=='02') days = 31;
    else if(numbers[1]=='03') days = 59;
    else if(numbers[1]=='04') days = 90;
    else if(numbers[1]=='05') days = 120;
    else if(numbers[1]=='06') days = 151;
    else if(numbers[1]=='07') days = 181;
    else if(numbers[1]=='08') days = 212;
    else if(numbers[1]=='09') days = 243;
    else if(numbers[1]=='10') days = 273;
    else if(numbers[1]=='11') days = 304;
    else if(numbers[1]=='12') days = 334;
    days+=Number(numbers[0]);
    
    if(numbers[1]=='01') days = 0;
    else if(numbers2[1]=='02') days2 = 31;
    else if(numbers2[1]=='03') days2 = 59;
    else if(numbers2[1]=='04') days2 = 90;
    else if(numbers2[1]=='05') days2 = 120;
    else if(numbers2[1]=='06') days2 = 151;
    else if(numbers2[1]=='07') days2 = 181;
    else if(numbers2[1]=='08') days2 = 212;
    else if(numbers2[1]=='09') days2 = 243;
    else if(numbers2[1]=='10') days2 = 273;
    else if(numbers2[1]=='11') days2 = 304;
    else if(numbers2[1]=='12') days2 = 334;
    days2+=Number(numbers2[0]);
    if(days>=days2)
    {
        if(Number(numbers2[2])%4==0) days+=1;
        return days-days2;
    }
    else return 365-days2+days
    
}
 function brth(a, b) {
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2)) -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365;
}
 function brth(s1, s2) {
    let dif = (new Date(s2.substr(6,4) + "-" + s1.substr(3,2) + "-" + s1.substr(0,2))-new Date(s2.substr(6,4) + "-" + s2.substr(3,2) + "-" + s2.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365;
}
 function brth(s1, s2){
    let arr_date = s1.split('.');
    let arr_current = s2.split('.');
    let birthday_day = +arr_date[0];
    let birthday_month = +arr_date[1];
    let current_day = +arr_current[0];
    let current_month = +arr_current[1];
    let current_year = +arr_current[2];
    let all_birthday_days = birthday_day;
    let all_current_days = current_day;
    let months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    let months_vys = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

    if((current_year % 4 == 0 && current_year % 100 != 0) || current_year % 400 == 0){
        for(let i = 0; i < birthday_month - 1;i++){
            if((current_month > birthday_month || (current_month == birthday_month && current_day >= birthday_day))){
                all_birthday_days += months[i];
            }else{
                all_birthday_days += months_vys[i];
            }
        }
        for(let i = 0; i < current_month - 1;i++){
            all_current_days += months_vys[i];
        }

        if(current_month > birthday_month || (current_month == birthday_month && current_day >= birthday_day)){
            return 366 - all_current_days + all_birthday_days;
        }else{
            return all_birthday_days - all_current_days;
        }
        
    }else{

        for(let i = 0; i < birthday_month - 1;i++){
            if((current_month > birthday_month || (current_month == birthday_month && current_day >= birthday_day)) && ((current_year + 1) % 4 == 0 && (current_year + 1) % 100 != 0) || (current_year + 1) % 400 == 0){
                all_birthday_days += months_vys[i];
            }else{
                all_birthday_days += months[i];
            }
        }
        for(let i = 0; i < current_month - 1;i++){
            all_current_days += months[i];
        }

        if(current_month > birthday_month || (current_month == birthday_month && current_day >= birthday_day)){
            return 365 - all_current_days + all_birthday_days;
        }else {
            return all_birthday_days - all_current_days;
        }
    }

}
 function brth(s1, s2){
    let splittedDateOfBirthday = s1.split('.')
    let splittedCurrentDate = s2.split('.')
    let yearOfBirthday = splittedCurrentDate[1]>splittedDateOfBirthday[1] || (splittedCurrentDate[1] == splittedDateOfBirthday[1] && splittedCurrentDate[0] >= splittedDateOfBirthday[0])?String(+splittedCurrentDate[2]+1):splittedCurrentDate[2]
    console.log(yearOfBirthday)
    let currentDate = new Date(splittedCurrentDate[2],splittedCurrentDate[1]-1,splittedCurrentDate[0])
    let dateOfBirthday = new Date(yearOfBirthday,splittedDateOfBirthday[1]-1,splittedDateOfBirthday[0])
    return Math.round((dateOfBirthday-currentDate)/1000/60/60/24)
}
 function brth(s1, s2){
    let arr1 = s1.split(".");
    let arr2 = s2.split(".");
    if(arr1[1] < arr2[1] || arr1[1] === arr2[1] && arr1[0] < arr2[0]){
        arr1.push((parseInt(arr2[2]) +1).toString());
    }
    else{
        arr1.push(arr2[2]);
    }
    let str1 = (arr1[2]+"-"+arr1[1]+"-"+arr1[0]).toString();
    let str2 = (arr2[2]+"-"+arr2[1]+"-"+arr2[0]).toString();

    const date1 = new Date(str1);
    const date2 = new Date(str2);
    const diffTime = Math.abs(date2 - date1);
    const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 
    return diffDays;
}
 function brth(a,b){
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(s1,s2){
    let dif = (new Date(s2.substr(6,4) + "-" + s1.substr(3,2) + "-" + s1.substr(0,2))
    -new Date(s2.substr(6,4) + "-" + s2.substr(3,2) + "-" + s2.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(s1, s2){
    let start = new Date (Number (s2.slice(6)), Number (s2.slice(3,5)) - 1, Number (s2.slice(0,2)));
    let end = new Date (Number (s2.slice(6)), Number (s1.slice(3,5)) - 1, Number (s1.slice(0,2)));
    if (end < start) end.setFullYear(Number (s2.slice(6)) + 1);
    let dif = Math.round((end - start)/(1000*60*60*24));
    return dif;
}
 function brth(s1, s2) {
    let formated_date1 = '',formated_date2 = '';
    formated_date2 = formated_date2.concat(s2.split('.')[1], "/", s2.split('.')[0], "/", s2.split('.')[2]);
    formated_date1 = formated_date1.concat(s1.split('.')[1], "/", s1.split('.')[0], "/", s2.split('.')[2]);
    let date1 = new Date(formated_date1);
    let date2 = new Date(formated_date2);
    if (date1 < date2) date1.setFullYear(date1.getFullYear() + 1);
    let diffDays = Math.round(Math.abs(date1 - date2) / (1000 * 60 * 60 * 24));
    return diffDays;
}
 function brth(a,b){
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
function brth(s1, s2) {
    let t2 = s2.split(".");
    let t1 = s1.split(".");
    let diff = new Date(t2[2], t2[1]-1, t2[0]) - new Date(t2[2], t1[1]-1, t1[0]);
    diff = diff/1000/86400;
    if(diff < 0) {
        return Math.ceil(-diff);
    }
    diff = Math.ceil(diff);
    return 365-diff;
}
 function brth(a,b){
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365;
}
 function brth(a,b){
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(s1, s2){
    let splittedDateOfBirthday = s1.split('.')
    let splittedCurrentDate = s2.split('.')
    let yearOfBirthday = splittedCurrentDate[1]>splittedDateOfBirthday[1] || (splittedCurrentDate[1] == splittedDateOfBirthday[1] && splittedCurrentDate[0] >= splittedDateOfBirthday[0])?String(+splittedCurrentDate[2]+1):splittedCurrentDate[2]
    console.log(yearOfBirthday)
    let currentDate = new Date(splittedCurrentDate[2],splittedCurrentDate[1]-1,splittedCurrentDate[0])
    let dateOfBirthday = new Date(yearOfBirthday,splittedDateOfBirthday[1]-1,splittedDateOfBirthday[0])
    return Math.round((dateOfBirthday-currentDate)/1000/60/60/24)
}
 function brth(a,b){
    var dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(s1, s2){
    let bd = s1.split('.'),
        nd = s2.split('.'),
        day = 0, now = 0;
    day = count(bd[0], bd[1], nd[2]);
    now = count(nd[0], nd[1], nd[2]);
    if (day - now < 0) return 365+(day - now);
    return day - now;
}
function count(a, b, c){
    let res = 0,
        month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    if (c % 4 == 0) month[1] = 29;
    for (let i = 0; i < Number(b) - 1; i++){
        res += month[i];
    } res += Number(a);   
    return res;
}
 function brth (birthDay, currentDate) {
const months = {
1: 31,
2: 28,
3: 31,
4: 30,
5: 31,
6: 30,
7: 31,
8: 31,
9: 30,
10: 31,
11: 30,
12: 31
}
const current = currentDate.split('.');
const birth = birthDay.split('.');
let sumDaysCurrent = 0;
let daysCurr = current[0]
let monthCurrent = current[1];
let sumDaysBirth = 0;
let daysBirth = birth[0]
let monthBirth = birth[1];
let specialYear = current[2];
if (specialYear % 4 == 0) {
months['2'] = 29;
}
for (let i = 1; i < monthCurrent; i++) {
sumDaysCurrent += months[`${i}`];
}
sumDaysCurrent = sumDaysCurrent + Number(daysCurr);
for (let i = 1; i < monthBirth; i++) {
sumDaysBirth += months[`${i}`];
}
sumDaysBirth = sumDaysBirth + Number(daysBirth);
let difference = sumDaysBirth - sumDaysCurrent;
if (difference > 0) {
return difference;
}
return Number(365 - sumDaysCurrent + sumDaysBirth);
}
 function brth(s1, s2) {
    if (parseInt(s1.slice(3, 5)) < parseInt(s2.slice(3, 5))) {
        s1 += "." + (parseInt(s2.slice(6, s2.length)) + 1).toString();
    } else if (parseInt(s1.slice(3, 5)) == parseInt(s2.slice(3, 5))) {
        if (parseInt(s1.slice(0, 2)) < parseInt(s2.slice(0, 2)))
            s1 += "." + (parseInt(s2.slice(6, s2.length)) + 1).toString();
        else if (parseInt(s1.slice(0, 2)) == parseInt(s2.slice(0, 2))) return 0;
        else s1 += "." + s2.slice(6, s2.length);
    } else s1 += "." + s2.slice(6, s2.length);

    s1 = s1.slice(3, 5) + "." + s1.slice(0, 2) + "." + s1.slice(6, s1.length);
    s2 = s2.slice(3, 5) + "." + s2.slice(0, 2) + "." + s2.slice(6, s2.length);

    let date1 = new Date(s1);
    let date2 = new Date(s2);
    console.log(date1, date2);
    return Math.round((date1.getTime() - date2.getTime()) / (1000 * 3600 * 24));
}
console.log(brth("17.03", "15.10.2000"));
 function brth(s1, s2){
    let s1Array = s1.split('.')
    let s2Array = s2.split('.')
    let brthDay = new Date(s2Array[2], s1Array[1]-1, s1Array[0])
    let todayDay = new Date(s2Array[2], s2Array[1]-1, s2Array[0])

    if(brthDay - todayDay > 0) {
      return Math.round((brthDay - todayDay)/86400000)
    }else{
        brthDay.setFullYear(brthDay.getFullYear()+1);
        return Math.round((brthDay - todayDay)/86400000);
    }
}
 const daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function daysIn(month, year) {
    if (month === 2 && isLeap(year)) return 29;
    return daysInMonths[month - 1];
}

function isLeap(year) {
    if (year % 400 === 0) return true;
    if (year % 100 === 0) return false;
    return year % 4 === 0;
}

class Date {
    constructor(day, month, year) {
        this.day = parseInt(day);
        this.month = parseInt(month);
        this.year = parseInt(year);
    }

    static from(string) {
        let parts = string.split('.');
        return new Date(parts[0], parts[1], parts[2]);
    }
}

function brth(target, current) {
    let currentDate = Date.from(current);
    let targetDate = Date.from(target + '.' + currentDate.year);
    let rearranged = rearrangeDate(currentDate, targetDate);
    let assumed = daysInBetween(rearranged[0], rearranged[1]);
    if (currentDate !== rearranged[0])
        return 365 - assumed;
    return assumed;
}

function rearrangeDate(firstDate, secondDate) {
    let initialOrder = [firstDate, secondDate];
    if (firstDate.month < secondDate.month) return initialOrder;
    if (firstDate.month === secondDate.month && firstDate.day <= secondDate.day) return initialOrder;
    return [secondDate, firstDate];
}

function daysInBetween(firstDate, secondDate) {
    if (firstDate.month === secondDate.month) {
        return secondDate.day - firstDate.day;
    }
    let days = daysIn(firstDate.month) - firstDate.day + secondDate.day;
    for (let month = firstDate.month + 1; month < secondDate.month; month++)
        days += daysIn(month, firstDate.year);
    return days;
}
 function brth(s1, s2){
    let birthDay = s1.split('.');
    let brDay =  Number(birthDay[0]);
    let brMonth =  Number(birthDay[1]);

    let Date = s2.split('.');
    let CurrDay = Number(Date[0]);
    let CurrMonth =  Number(Date[1]);
    let year = Number(Date[2]);

    let res = 0;
    let monthLength;
    let index;
    
    if(brMonth < CurrMonth){
     index = 12 - CurrMonth + brMonth;
    }else {
     index = brMonth - CurrMonth;
    }
    
    if(brMonth == Number(Date[1])){
      if(brDay < CurrDay){
        index = 12;
      }else if(brDay > CurrDay){
       res = brDay - CurrDay; 
       return res;
      }
    }
    
    for(let i = 0; i < index; i++){
        
        if(CurrMonth > 12){
          year++;
          CurrMonth = 1;
        }

        if(CurrMonth != 2){
          
         switch(true){
            case (CurrMonth%2 == 1)&&(CurrMonth <= 7): 
            monthLength = 31;
            break;

            case (CurrMonth%2 == 0)&&(CurrMonth <= 7):
            monthLength = 30;
            break;

            case (CurrMonth%2 == 1)&&(CurrMonth > 7):  
            monthLength = 30;
            break;

            case (CurrMonth%2 == 0)&&(CurrMonth > 7): 
            monthLength = 31;
            break;
         }
         
        }else if(year % 4 == 0){
            monthLength = 29;
        }else {
            monthLength = 28;
        }

        res += monthLength - CurrDay;
        CurrDay = 0;
        CurrMonth++;
        
    }
    
    res += brDay;
    return res;
    
}
 function brth(s1, s2){
    let s1a = s1.split('.')
    let s2a = s2.split('.')
    let sum = 0
    let m = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
    if(+s2a[2] % 4 == 0 && +s2a[1] <= 2){
        m['2'] = 29
    }
    if(+s1a[0] < +s2a[0]){
        sum += m[`${+s2a[1]}`]
        s2a[1] = +s2a[1] + 1
    }
    for(let i = +s2a[1];i!= +s1a[1];i++){
        sum += m[`${i}`]
        if(i ==   12){
            i = 0
            if((+s2a[2] + 1)%4 == 0){
                m['2'] = 29
            }
        }
    }
    if(+s1a[0] > +s2a[0]){
        sum += +s1a[0] - +s2a[0]
    }else{
        sum -= +s2a[0] - +s1a[0]
    }
    return sum
}
 function brth(s1, s2){
    let presentYear = +s2.slice(-4);
    let presentMonth = +s2.slice(-7,-5);
    let presentDay = +s2.slice(0,2);

    let constMonth = +s1.slice(3);
    let constDay = +s1.slice(0,2);
    let sum = 0;

    let months = [31,28,31,30,31,30,31,31,30,31,30,31];
    if (presentDay > constDay && presentMonth == constMonth && presentYear+1 % 4 != 0) return 365-(presentDay-constDay);
    if (presentDay > constDay && presentMonth == constMonth && presentYear+1 % 4 == 0) return 366-(presentDay-constDay);
    else if (presentMonth == constMonth) return constDay - presentDay;

    else if (presentMonth < constMonth){
        if (presentYear % 4 == 0) months[1] = 29;
        sum += (months[presentMonth-1]-presentDay);
        presentMonth+=1;
        while(presentMonth < constMonth){
            sum += months[presentMonth-1];
            presentMonth++;
        }
        sum += constDay;
        return sum;
    }

    else {
        if (presentYear % 4 == 0) months[1] = 29;
        sum += (months[presentMonth-1]-presentDay);
        presentMonth+=1;
        while (presentMonth < 13) {
            sum += months[presentMonth-1];
            presentMonth++;
        }
        presentMonth = 1;
        presentYear++;
        if (presentYear % 4 == 0) months[1] = 29;
        else months[1] = 28;
        while (presentMonth < constMonth){
            sum += months[presentMonth-1];
            presentMonth++;
        }
        sum += constDay;
        return sum;
    }

}
 function brth(a, b){
    let birthdate = a.split('.')
    let curdate = b.split('.')
    function countDays(date){
        const months = {
            1: 31,
            2: (date[2] % 4 == 0) ? 29 : 28,
            3: 31,
            4: 30,
            5: 31,
            6: 30,
            7: 31,
            8: 31,
            9: 30,
            10: 31,
            11: 30,
            12: 31
        }
        let days = +date[0];
        for (let i = 1; i < date[1]; ++i){
            days += months[i];
        }
        return days;
    }
    if (birthdate[1] > curdate[1]) {birthdate.push(curdate[2]); return countDays(birthdate) - countDays(curdate)}
    else if (birthdate[1] < curdate[1]) {birthdate.push(curdate[2] + 1); return countDays(birthdate) + countDays([31, 12, curdate[2]]) - countDays(curdate)}
    else if (birthdate[0] > curdate[0]) {birthdate.push(curdate[2]); return countDays(birthdate) - countDays(curdate)}
    else if (birthdate[0] < curdate[0]) {birthdate.push(curdate[2] + 1); return countDays(birthdate) + countDays([31, 12, curdate[2]]) - countDays(curdate)}
    else return 0
}
 function brth(dr, date) {
    const drNums = dr.split('.');
    const drD = parseInt(drNums[0]);
    const drM = parseInt(drNums[1]);
    
    const dateNums = date.split('.');
    const dateD = parseInt(dateNums[0]);
    const dateM = parseInt(dateNums[1]);
    let dateY = parseInt(dateNums[2]);
    
    if (dateM == drM && dateD <= drD) return drD - dateD;
    
    let days = 0;
    let month = dateM;
    do {
        let monthDays = new Date(dateY, month, 0).getDate();
        if (month == dateM) days += monthDays - dateD; 
        else days += monthDays;
      
        if (month == 12) {
            month = 1;
            dateY++;
        } else {
            month++;
        }
    } while (month != drM);

    return days + drD;
}
 function brth(s1, s2){
    let bd = s1.split('.')
    let curr = s2.split('.')
    let brthDay = new Date(curr[2], bd[1]-1, bd[0])
    let todayDay = new Date(curr[2], curr[1]-1, curr[0])

    if(brthDay - todayDay > 0) {
      return Math.round((brthDay - todayDay)/86400000)
    }else{
        brthDay.setFullYear(brthDay.getFullYear()+1);
        return Math.round((brthDay - todayDay)/86400000);
    }
}
 function brth(s1, s2)
{
s1 = s1.split(".")
s2 = s2.split(".")
s1 = [Number(s1[0]),Number(s1[1])] 
s2 = [Number(s2[0]),Number(s2[1]),Number(s2[2])]
let day = dayOfMonth(s2[1], s2[2]) - s2[0]

if(s1[1]>s2[1])
for(let i = s2[1]+1;i<=s1[1];i++)
{
if(i==s1[1])
day+=s1[0]
else
day += dayOfMonth(i, s2[2]) 
}

 if(s1[1]< s2[1])
for(let i = s2[1]+1;i!=s1[1]+1;i++)
{
if(i==13 && i!=s1[1])
{
i=1
s2[2]+=1
}
if(i==s1[1])
day+=s1[0]
else
day+=dayOfMonth(i, s2[2])
}

if(s1[1]==s2[1])
{
if(s1[0]>s2[0])
return s1[0]-s2[0]
else
s2[1]+=1
for(let i = s2[1];i!=s1[1];i++)
{
if(i==13 && i!=s1[1])
i=1

day+=dayOfMonth(i, s2[2])
}
day+=s1[0] 

return day
}

 
function dayOfMonth(x, y)
{
if(x == 2 && y%4 == 0)
return 29
if(x == 2)
return 28
if(x > 7)
{
if(x%2 == 0)
return 31
return 30
}
if(x < 8)
{
if(x%2 != 0)
return 31
return 30
}
}
 function brth(s1, s2){
let s1Arr=s1.split('.');
let s2Arr=s2.split('.');
let a = new Date(s2Arr[2],s1Arr[1]-1,s1Arr[0]);
let b = new Date(s2Arr[2],s2Arr[1]-1,s2Arr[0]);
if(a - b > 0){
    return Math.round((a - b)/(1000*60*60*24));
}else{
    a.setFullYear(a.getFullYear()+1);
    return Math.round((a - b)/(1000*60*60*24));
}
}
 const daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function daysIn(month, year) {
    if (month === 2 && isLeap(year)) return 29;
    return daysInMonths[month - 1];
}

function isLeap(year) {
    if (year % 400 === 0) return true;
    if (year % 100 === 0) return false;
    return year % 4 === 0;
}

class Date {
    constructor(day, month, year) {
        this.day = parseInt(day);
        this.month = parseInt(month);
        this.year = parseInt(year);
    }

    static from(string) {
        let parts = string.split('.');
        return new Date(parts[0], parts[1], parts[2]);
    }
}

function brth(target, current) {
    let currentDate = Date.from(current);
    let targetDate = Date.from(target + '.' + currentDate.year);
    let rearranged = rearrangeDate(currentDate, targetDate);
    let assumed = daysInBetween(rearranged[0], rearranged[1]);
    if (currentDate !== rearranged[0])
        return 365 - assumed;
    return assumed;
}

function rearrangeDate(firstDate, secondDate) {
    let initialOrder = [firstDate, secondDate];
    if (firstDate.month < secondDate.month) return initialOrder;
    if (firstDate.month === secondDate.month && firstDate.day <= secondDate.day) return initialOrder;
    return [secondDate, firstDate];
}

function daysInBetween(firstDate, secondDate) {
    if (firstDate.month === secondDate.month) {
        return secondDate.day - firstDate.day;
    }
    let days = daysIn(firstDate.month) - firstDate.day + secondDate.day;
    for (let month = firstDate.month + 1; month < secondDate.month; month++)
        days += daysIn(month, firstDate.year);
    return days;
}
 function brth(a,b){
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(a, b)
{
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2)) -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(a,b){
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(a,b){
    let dif = (new Date(b.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2))
    -new Date(b.substr(6,4) + "-" + b.substr(3,2) + "-" + b.substr(0,2)))/ 1000 / 3600 / 24;
    return dif > 0 ? dif : dif + 365
}
 function brth(s1, s2) {
    let formated_date1 = '',formated_date2 = '';
    formated_date2 = formated_date2.concat(s2.split('.')[1], "/", s2.split('.')[0], "/", s2.split('.')[2]);
    formated_date1 = formated_date1.concat(s1.split('.')[1], "/", s1.split('.')[0], "/", s2.split('.')[2]);
    let date1 = new Date(formated_date1);
    let date2 = new Date(formated_date2);
    if (date1 < date2) date1.setFullYear(date1.getFullYear() + 1);
    let diffDays = Math.round(Math.abs(date1 - date2) / (1000 * 60 * 60 * 24));
    return diffDays;
}
 function brth(s1, s2){
    s1 = s1.split(".")
    s2 = s2.split(".")
    let result = 0

    for(i = 0; i < s1.length; i++) s1[i] = parseInt(s1[i])
    for(i = 0; i < s1.length; i++) s2[i] = parseInt(s2[i])

    if ((s2[2] % 4 == 0 && s2[2] != 100) || s2[2] % 400 == 0){
        if (s1[1] >= s2[1]){
            for(i = s2[1]; i < s1[1]; i++){
                if (i <= 7 && i !=2 ) result += 30 + 1 * (i % 2)
                if (i == 2) result += 29
                if (i > 7) result += 31 - 1 * (i % 2) 
            }
            if(s1[0] >= s2[0]){
                for(i = s2[0]; i < s1[0]; i++) result++
            }
            else{
                for(i = s1[0]; i < s2[0]; i++) result--
            }
        }
        else{
            result = 366
            for(i = s1[1]; i < s2[1]; i++){
                if(i <= 7 && i != 2) result -= 30 + 1 * (i % 2)
                if(i == 2) result -= 29
                if(i > 7) result -= 31 - 1 * (i % 2) 
            }
            if(s1[0] <= s2[0]){
                for(i = s1[0]; i < s2[0]; i++) result--
            }
            else{
                for(i = s2[0] + 1; i < s1[0]; i++) result++
            }
        }
        if(result < 0) result += 366
    }
    else{
        if(s1[1] >= s2[1]){
            for(i = s2[1]; i < s1[1]; i++){
                if(i <= 7 && i != 2) result += 30 + 1 * (i % 2)
                if(i == 2) result += 28
                if(i > 7) result += 31 - 1 * (i % 2) 
            }
            if(s1[0] >= s2[0]){
                for(i = s2[0]; i < s1[0]; i++) result++
            }
            else{
                for(i = s1[0]; i < s2[0]; i++) result--
            }
        }
        else{
            result = 365
            for(i = s1[1]; i < s2[1]; i++){
                if(i <= 7 && i != 2) result -= 30 + 1 * (i % 2)
                if(i == 2) result -= 28
                if(i > 7) result -= 31 - 1 * (i % 2) 
            }
            if(s1[0] >= s2[0]){
                for(i = s2[0]; i < s1[0]; i++) result++
            }
            else{
                for(i = s1[0]; i < s2[0]; i++) result--
            }
        }
        if(result < 0) result += 365
    }
    return result
}
 const MONTHS = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
function leap(n, y) {
    if(n > 59 && (y % 4 == 0 && y % 100 != 0 || y % 400 == 0))
        return n + 1;
    return n;
}

function brth(s1, s2) {
    s1 = s1.split('.');
    s2 = s2.split('.');
    let y = Number(s2[2]);
    s1 = Number(s1[0]) + MONTHS[Number(s1[1]) - 1];
    s2 = Number(s2[0]) + MONTHS[Number(s2[1]) - 1];
    if(s1 < s2)
        s1 = leap(365, y) + leap(s1, y+1);
    else
        s1 = leap(s1, y);
    s2 = leap(s2, y);
    return s1 - s2;
}
 const daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function daysIn(month, year) {
    if (month === 2 && isLeap(year)) return 29;
    return daysInMonths[month - 1];
}

function isLeap(year) {
    if (year % 400 === 0) return true;
    if (year % 100 === 0) return false;
    return year % 4 === 0;
}

class Date {
    constructor(day, month, year) {
        this.day = parseInt(day);
        this.month = parseInt(month);
        this.year = parseInt(year);
    }

    static from(string) {
        let parts = string.split('.');
        return new Date(parts[0], parts[1], parts[2]);
    }
}

function brth(target, current) {
    let currentDate = Date.from(current);
    let targetDate = Date.from(target + '.' + currentDate.year);
    let rearranged = rearrangeDate(currentDate, targetDate);
    let assumed = daysInBetween(rearranged[0], rearranged[1]);
    if (currentDate !== rearranged[0])
        return 365 - assumed;
    return assumed;
}

function rearrangeDate(firstDate, secondDate) {
    let initialOrder = [firstDate, secondDate];
    if (firstDate.month < secondDate.month) return initialOrder;
    if (firstDate.month === secondDate.month && firstDate.day <= secondDate.day) return initialOrder;
    return [secondDate, firstDate];
}

function daysInBetween(firstDate, secondDate) {
    if (firstDate.month === secondDate.month) {
        return secondDate.day - firstDate.day;
    }
    let days = daysIn(firstDate.month) - firstDate.day + secondDate.day;
    for (let month = firstDate.month + 1; month < secondDate.month; month++)
        days += daysIn(month, firstDate.year);
    return days;
}