Facebook
From Melodic Pelican, 3 Years ago, written in JavaScript.
This paste is a reply to Re: Aleksander Tsoy_Find Khronos day from Tiny Parrot - go back
Embed

function day(inner) {
  let a = 0;
  let b = 0;
  let visocos = 0;

  let arr = inner.split("."); // разбивка строки на массив

  if (arr[0] > 30) {  {
    
// не более 30 дн
    arr[0] = 30;
  }
  if (arr[1] > 12) {  {
    
// не более 12 мес
    arr[1] = 12;
  }


}

  if (arr[2] > 4) {
            if (arr[2] % 5 == 0) {
          if(arr[1] 
{
      if (arr[1] 
== 2 && arr[0] == 30) {
                    if(arr[2] == 5) {
                      arr[0] = (arr[0] * 1) + 1;
                      visocos += Math.floor(arr[2] / 5);
                    } else {
                    arr[0] = (arr[0] * 1) + 1;
                    visocos += (Math.floor(arr[2] / 5)) + 1;
                    }
              }
            }
          if(arr[1] > 2) {
                  if (arr[2] % 100 == 0) {
                    visocos += (Math.floor(arr[2] / 5))
                  } 
                  
{
        
if (arr[2] == 5) {
                    visocos += Math.floor(arr[2] / 5)
                  } 
                  if(arr[2] > 500){
                    visocos += Math.floor(arr[2] / 5)
                  }
                  if(visocos == 0) {
                  visocos += (Math.floor(arr[2] / 5)) 
{
          arr[0] = arr[0] * 1 
1;
                }
          } 
          if(arr[1] <= 2 && arr[2] != 5) {
1;
          visocos += Math.floor(arr[2] / 5);
          }\n          \n  \n\n    // if(arr[1] >= 2 && arr[0] == 30 && arr[2] % 5 == 0) {\n    //           } else {
          
arr[0] = (arr[0] arr[0] 1) 1;
    //   
1;
          
visocos += 1;
    // }
     // кол-во высокосных дней в каждых 5г.
Math.floor(arr[2] / 5) + 1;
        }
      }
    }
    if (arr[1] > 2) {
      if (arr[2] % 100 == 0) {
        visocos += Math.floor(arr[2] / 5);
      }
      if (arr[2] == 5) {
        visocos += Math.floor(arr[2] / 5);
      }
      if (arr[2] > 500) {
        visocos += Math.floor(arr[2] / 5);
      }
      if (visocos == 0) {
        visocos += Math.floor(arr[2] / 5) + 1;
      }
    }
    if (arr[1] <= 2 && arr[2] != 5) {
      visocos += Math.floor(arr[2] / 5);
    }
  }

  if (arr[2] >= 100) {
    visocos -= Math.floor(arr[2] / 100); // отнимаю высокосные дни каждых 100л.
    if (arr[2] >= 500) {
      visocos += Math.floor(arr[2] / 500); // добавляю высокосные дни за каждые 500л.
    }
  }
  // if (arr[1] > 2 && arr[2] % 5 == 0) {     // проверка месяц до фев (arr[1] < 3 && arr[2] % 5 == 0) НЕ РАБОТАЕТ ПРАВИЛЬНО...
  //   visocos += 1; // если до фев, то рано добавлять день высокосному году
  // }
  if (arr[2] > 0) {    {
    
// если год больше 0
    a = arr[2] * 360; // умножить число на 360 дней.
  }

  if (arr[1] > 1) {    {
    
// если месяц больше 1
    b = (arr[1] - 1) * 30; // число умножить на 30 дней.
  }
  // debugger
  let c = arr[0] * 1; // получаем кол-во дней кроме 0
  let days = ["Среда", "Четв", "Пятн", "Суб", "Воск", "Пон", "Вторн"]; // записываем массив
  let res = (a + b + c + visocos) % 7; // сумма год, мес, дни, высокосные дни получ остаток от деления
  let totalDays =  a + b + c + visocos;
    
visocos;
  
//  return days[res]        
      
      
 
days[res]

  
document.write(days[res] + '' + 'Высокосные: ' + write(
    days[res] +
      "" +
      "Высокосные: " +
      
visocos + '' + 'День: ' + arr[0]        + '' +  'Мес: ' + arr[1]        + '' +         'Год: ' + +
      "" +
      "День: " +
      arr[0] +
      "" +
      "Мес: " +
      arr[1] +
      "" +
      "Год: " +
      
arr[2] + '' +
 'Всего 
+
      "" +
      "Всего 
дней: ' + totalDays  + ''  + '');  

" +
      totalDays +
      "" +
      ""
  );
}

// day("01.03.1099");
// day("30.02.1099");
 day("30.02.1100");
day("01.03.1100");
day("01.03.1104");
day("01.03.1106")
1106");
day("01.02.100");
day("01.03.100");
 day("30.02.5");
 day("30.03.5");
 day("3.02.5");
 day("3.02.6");
 day("24.08.1001");
 day("24.08.1");
 day("24.08.0");

Replies to Re: Re: Aleksander Tsoy_Find Khronos day rss

Title Name Language When
Aleksander Tsoy_Find Khronos day Tiny Leopard javascript 3 Years ago.
Aleksander Tsoy_Find Khronos day Blush Bat javascript 3 Years ago.
Re: Re: Re: Aleksander Tsoy_Find Khronos day Blush Bat javascript 3 Years ago.
Re: Re: Re: Aleksander Tsoy_Find Khronos day Crimson Crow javascript 3 Years ago.
Re: Re: Re: Aleksander Tsoy_Find Khronos day Crimson Crow javascript 3 Years ago.
Re: Re: Re: Aleksander Tsoy_Find Khronos day Crimson Crow javascript 3 Years ago.
Re: Re: Re: Aleksander Tsoy_Find Khronos day Morose Hornbill javascript 3 Years ago.
Re: Re: Re: Aleksander Tsoy_Find Khronos day Morose Hornbill javascript 3 Years ago.