Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
persistData() {
this.dateFormatError.emit(!this.validDateFormat);
if (this.dateTimeModel.date && this.validDateFormat) {
if (this.dateTimeModel.time == null) {
this.dateTimeModel.time = new NgbTime(0, 0, 0);
}
this.dateTimeResult.emit(this.dateTimeModel);
} else {
this.dateTimeResult.emit(null);
}
}
if (this.ataModel && this.ataModel.date) {
arrival = {
date: new NgbDate(this.ataModel.date.year, this.ataModel.date.month, this.ataModel.date.day),
time: new NgbTime(this.ataModel.time.hour, this.ataModel.time.minute, 0)
};
this.portCallModel.locationAta = new Date(arrival.date.year, arrival.date.month - 1, arrival.date.day,
arrival.time.hour, arrival.time.minute, 0);
} else {
this.portCallModel.locationAta = null;
}
if (this.atdModel && this.atdModel.date) {
departure = {
date: new NgbDate(this.atdModel.date.year, this.atdModel.date.month, this.atdModel.date.day),
time: new NgbTime(this.atdModel.time.hour, this.atdModel.time.minute, 0)
};
this.portCallModel.locationAtd = new Date(departure.date.year, departure.date.month - 1, departure.date.day,
departure.time.hour, departure.time.minute, 0);
} else {
this.portCallModel.locationAtd = null;
}
this.ataAfterTodayError = arrival != null ? this.currentDate.before(arrival.date) : false;
this.atdAfterTodayError = departure != null ? this.currentDate.before(departure.date) : false;
if (arrival != null && departure != null) {
this.dateSequenceError = arrival.date.after(departure.date);
if (arrival.date.equals(departure.date)) {
this.dateSequenceError = arrival.time.hour > departure.time.hour
|| (arrival.time.hour === departure.time.hour && arrival.time.minute >= departure.time.minute);
}
data => {
if (data) {
const dateTime = new Date(data);
this.prevEtdModel = {
date: new NgbDate(dateTime.getFullYear(), dateTime.getMonth() + 1, dateTime.getDate()),
time: new NgbTime(dateTime.getHours(), dateTime.getMinutes(), 0)
};
} else {
this.prevEtdModel = {
date: null,
time: new NgbTime(0, 0, 0)
};
}
this.validateDateTime();
}
);
private resetModel() {
this.locationFound = false;
this.arrivalModel = {
date: null,
time: new NgbTime(0, 0, 0)
};
this.departureModel = {
date: null,
time: new NgbTime(0, 0, 0)
};
this.formModel = new SecurityPreviousPortOfCallModel();
}
const etdDateTime: Date = new Date(this.prevEtdModel.date.year, this.prevEtdModel.date.month - 1, this.prevEtdModel.date.day, this.prevEtdModel.time.hour, this.prevEtdModel.time.minute);
this.prevAndNextPocService.setPrevPortOfCallEtd(etdDateTime);
} else {
const etdDateTime: DateTime = {
date: null,
time: new NgbTime(0, 0, 0)
};
this.prevAndNextPocService.setPrevPortOfCallEtd(null);
}
if (this.nextEtaModel.date) {
const etaDateTime: Date = new Date(this.nextEtaModel.date.year, this.nextEtaModel.date.month - 1, this.nextEtaModel.date.day, this.nextEtaModel.time.hour, this.nextEtaModel.time.minute);
this.prevAndNextPocService.setNextPortOfCallEta(etaDateTime);
} else {
const etaDateTime: DateTime = {
date: null,
time: new NgbTime(0, 0, 0)
};
this.prevAndNextPocService.setNextPortOfCallEta(null);
}
}
}
}
data => {
if (data) {
const dateTime = new Date(data);
this.prevEtdModel = {
date: new NgbDate(dateTime.getFullYear(), dateTime.getMonth() + 1, dateTime.getDate()),
time: new NgbTime(dateTime.getHours(), dateTime.getMinutes(), 0)
};
} else {
this.prevEtdModel = {
date: null,
time: new NgbTime(0, 0, 0)
};
}
this.validateDateTime();
}
);
getNgbDateTimeFormat(dateTime) {
const newDate = new NgbDate(dateTime.date.getFullYear(), dateTime.date.getMonth() + 1, dateTime.date.getDate());
const newTime = new NgbTime(dateTime.time);
const newDateTime = {date: newDate, time: newTime};
return newDateTime;
}
etaEtdData => {
if (etaEtdData) {
this.currentEtaModel = {
date: new NgbDate(etaEtdData.eta.year, etaEtdData.eta.month, etaEtdData.eta.day),
time: new NgbTime(etaEtdData.eta.hour, etaEtdData.eta.minute, 0)
};
this.currentEtdModel = {
date: new NgbDate(etaEtdData.etd.year, etaEtdData.etd.month, etaEtdData.etd.day),
time: new NgbTime(etaEtdData.etd.hour, etaEtdData.etd.minute, 0)
};
}
this.validateDateTime();
}
);