SHARE
TWEET

Untitled

a guest Nov 9th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function daysAfterBirth([arg1]){
  2.     let input = arg1;
  3.     let inputArray = input.split('-');
  4.     let monthOutput = 0;
  5.     let dayOutput = 0;
  6.     let month = 0;
  7.     let day = 0;
  8.     let newdate = 0;
  9.     if (input[0].length<3){
  10.     day = inputArray[0];
  11.     month = inputArray[1];
  12.     let year = inputArray[2];
  13.     let birthdate = `${year}-${month}-${day}`
  14.     newdate = new Date(birthdate);
  15.     newdate.setDate((newdate.getDate())+1000);
  16.     dayOutput = newdate.getDate();
  17.     monthOutput = newdate.getMonth()+1;
  18.     let yearOutput = newdate.getFullYear();
  19.     newdate = (`${dayOutput}-${monthOutput}-${yearOutput}`);
  20.     }else if (input[0].length==4){
  21.     let year = inputArray[0];
  22.     month = inputArray[1];
  23.     day = inputArray[2];
  24.     let birthdate = `${year}-${month}-${day}`
  25.     newdate = new Date(birthdate);
  26.     newdate.setDate((newdate.getDate())+1000);
  27.     dayOutput = newdate.getDate();
  28.     monthOutput = newdate.getMonth()+1;
  29.     let yearOutput = newdate.getFullYear();
  30.     }
  31.     if (monthOutput<10){
  32.         month ="0"+month;
  33.     }if (dayOutput<10){
  34.         day ="0"+day;
  35.     }
  36.     console.log(newdate)
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top