Untitled
unknown
javascript
3 years ago
3.8 kB
5
Indexable
//NOWY KOD TESTOWY DUZY v5 -- spradzanie wyjatkow! //const hubspot = require('@hubspot/api-client'); exports.main = async (event, callback) => { // Miesiac startowy //const deal_time_start = event.inputFields['deal_stage_ongoing___time']; let dateStart = new Date("2022,12,31"); // let dateStart = new Date(parseInt(deal_time_start)); let dateStartDay = dateStart.getDate(); let dateStartMonth = dateStart.getMonth(); let dateStartYear = dateStart.getFullYear(); let currentDate = new Date("2023,3,31"); let currentDateDay = currentDate.getDate(); let currentDateMonth = currentDate.getMonth(); let currentDateYear = currentDate.getFullYear(); // Wartosci sprawdzanego dnia na teraz // let currentDateDay = new Date().getDate(); #zamazane // let currentDateMonth = new Date().getMonth(); #zamazane let output = ''; console.log("DATA STARTOWA! : " + dateStart); console.log("DATA SPRAWDZANA! : " + currentDate); console.log("Rok start : = " + dateStartYear + ". Rok sprawdzany: = " + currentDateYear); console.log("Miesiac start : = "+ dateStartMonth + ". Miesiac sprawdzany: = "+currentDateMonth); console.log("Dzien start : = "+ dateStartDay + ". Dzien sprawdzany: = "+currentDateDay); if ((dateStartMonth === 11 || dateStartMonth === 9) && dateStartYear + 1 === currentDateYear && currentDateDay === dateStartDay) { console.log("Pazdziernik i grudzien przeszedl"); output = "True"; } else { if ( dateStartDay === 31 && (currentDateMonth === 1 ||currentDateMonth === 3 ||currentDateMonth === 5 || currentDateMonth === 8 || currentDateMonth === 10) && currentDateDay == 30) { console.log("\n"); console.log("Dni 31 dzialaja"); console.log("Czas startowy: " + dateStart); console.log("Czas teraz: Miesiac " + currentDateMonth); console.log("Czas teraz: Dzien " + currentDateDay); output = "True"; } else { console.log("\n"); console.log("Dni 31 nie dzialaja!"); //Jesli Listopad i wypada na luty w nastepnym roku if ( dateStartMonth === 10 && dateStartYear + 1 === currentDateYear && currentDateMonth == 1) { if (dateStartDay >= 28 && currentDateDay == 28) { console.log("\n"); console.log("LUTY ODPALONY version 1!"); output = "True"; } else if (dateStartDay >= 1 && dateStartDay < 28 && currentDateDay < 28 && currentDateDay == dateStartDay) { console.log("LUTY ODPALONY version 2!"); output = "True"; } else { console.log("Zla lutowa data"); output = "False"; } } else { console.log("\n"); console.log("LUTY NIE ODPALONY!"); //Normalne sprawdzanie! if ( dateStartMonth + 3 === currentDateMonth && dateStartDay === currentDateDay && dateStartYear === currentDateYear) { console.log("\n"); console.log("Dziala"); console.log("Czas startowy: " + dateStart); console.log("Czas teraz: Miesiac " + currentDateMonth); console.log("Czas teraz: Dzien " + currentDateDay); output = "True"; } else { console.log("\n"); console.log("Nie Dziala"); console.log("Czas startowy: " + dateStart); console.log("Czas Sprawdzany: " + currentDate); console.log("Rok start: " + dateStartYear + " Rok sprawdzany: " + currentDateYear); console.log("Miesiac start: " + dateStartMonth + " Czas teraz: Miesiac " + currentDateMonth); console.log("Dzien start: " + dateStartDay + " Czas teraz: Dzien " + currentDateDay); output = "False"; } } } } console.log("\n\n\n\n"); console.log("Output = "+output); callback({ outputFields: { output: output } }) }
Editor is loading...