Advertisement
avr39ripe

jsDatePlusOne

Jan 25th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Study</title>
  6. </head>
  7. <body>
  8.     <script>
  9.     `use strict`
  10.  
  11.         const monthInYear = 12;
  12.         let day = 28;
  13.         let month = 2;
  14.         let year = 1600;
  15.  
  16.         let daysInMonth = 30;
  17.  
  18.         day = +prompt('Enter day number',28);
  19.         month = +prompt('Enter month number',2);
  20.         year = +prompt('Enter year number',2020);
  21.        
  22.         let leapYear = false;
  23.  
  24.         leapYear = ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0)) );
  25.  
  26.         console.log(`${year} is leap year: ${leapYear}`);
  27.  
  28.         daysInMonth += ((month < 8) && (month % 2 != 0)) || ((month >= 8) && (month % 2 == 0)) + ((month == 2)*(-2 + leapYear));
  29.  
  30.         console.log(`In month #${month} there are ${daysInMonth} days.`);
  31.  
  32.         (++day > daysInMonth) && ((day = 1) && ((++month > monthInYear) && ( (month = 1) && (++year))))
  33. /*
  34.         ++day;
  35.  
  36.         if (day > daysInMonth)
  37.         {
  38.             day = 1;
  39.             ++month;
  40.         }
  41.  
  42.         if (month > monthInYear)
  43.         {
  44.             month = 1;
  45.             ++year;
  46.         }
  47. */
  48.         console.log(`${day}.${month}.${year}`);
  49.  
  50. /*
  51.         1   2   3   4   5   6   7       #   8   9   10  11  12
  52.         31  28  31  30  31  30  31      #   31  30  31  30  31
  53.  
  54.         ((month < 8) && (month % 2 != 0)) || ((month >= 8) && (month % 2 == 0)) (month == 2)*(-2 + leapYear)
  55. */
  56. /*
  57.         if ( year % 4 == 0 )
  58.         {
  59.             leapYear = true;
  60.         }
  61.  
  62.         leapYear = ( year % 4 == 0 );
  63. */
  64.  
  65.  
  66. /*
  67.         if ( year % 400 == 0)
  68.         {
  69.             leapYear = true;
  70.         }
  71.         else if (year % 100 != 0)
  72.         {
  73.             leapYear = true;
  74.         }
  75.         else if ( year % 4 == 0 )
  76.         {
  77.             leapYear = true;
  78.         }
  79. */
  80.  
  81.     </script>
  82. </body>
  83. </html>
  84.  
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement