How to use the @ng-bootstrap/ng-bootstrap/datepicker/ngb-date.NgbDate function in @ng-bootstrap/ng-bootstrap

To help you get started, we’ve selected a few @ng-bootstrap/ng-bootstrap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / registration / forms / voyages / voyages.component.ts View on Github external
if (this.etaModel && this.etdModel) {
      const etaDate = new NgbDate(this.etaModel.date.year, this.etaModel.date.month, this.etaModel.date.day);
      const etdDate = new NgbDate(this.etdModel.date.year, this.etdModel.date.month, this.etdModel.date.day);

      this.etaIsAfterEtdError = etdDate.before(etaDate);

      if (etdDate.equals(etaDate)) {
        this.etaIsAfterEtdError = this.etaModel.time.hour > this.etdModel.time.hour
          || (this.etaModel.time.hour === this.etdModel.time.hour
            && this.etaModel.time.minute >= this.etdModel.time.minute);
      }
    } else {
      this.etaIsAfterEtdError = false;
    }

    const prevEtdDate = this.prevEtdModel != null && this.prevEtdModel.date != null ? new NgbDate(this.prevEtdModel.date.year, this.prevEtdModel.date.month, this.prevEtdModel.date.day) : null;
    const nextEtaDate = this.nextEtaModel != null && this.nextEtaModel.date != null ? new NgbDate(this.nextEtaModel.date.year, this.nextEtaModel.date.month, this.nextEtaModel.date.day) : null;

    // Checking for sequence errors between prev and current port of call
    if (prevEtdDate && this.etaModel) {
      this.prevEtdIsAfterCurrentEtaError = prevEtdDate.after(this.etaModel.date);
      if (prevEtdDate.equals(this.etaModel.date)) {
        this.prevEtdIsAfterCurrentEtaError = this.prevEtdModel.time.hour > this.etaModel.time.hour
          || (this.prevEtdModel.time.hour === this.etaModel.time.hour
            && this.prevEtdModel.time.minute >= this.etaModel.time.minute);
      }
    } else {
      this.prevEtdIsAfterCurrentEtaError = false;
    }

    // Checking for sequence errors between next and current port of call
    if (nextEtaDate && this.etdModel) {
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / registration / forms / voyages / voyages.component.ts View on Github external
const etaDate = new NgbDate(this.etaModel.date.year, this.etaModel.date.month, this.etaModel.date.day);
      const etdDate = new NgbDate(this.etdModel.date.year, this.etdModel.date.month, this.etdModel.date.day);

      this.etaIsAfterEtdError = etdDate.before(etaDate);

      if (etdDate.equals(etaDate)) {
        this.etaIsAfterEtdError = this.etaModel.time.hour > this.etdModel.time.hour
          || (this.etaModel.time.hour === this.etdModel.time.hour
            && this.etaModel.time.minute >= this.etdModel.time.minute);
      }
    } else {
      this.etaIsAfterEtdError = false;
    }

    const prevEtdDate = this.prevEtdModel != null && this.prevEtdModel.date != null ? new NgbDate(this.prevEtdModel.date.year, this.prevEtdModel.date.month, this.prevEtdModel.date.day) : null;
    const nextEtaDate = this.nextEtaModel != null && this.nextEtaModel.date != null ? new NgbDate(this.nextEtaModel.date.year, this.nextEtaModel.date.month, this.nextEtaModel.date.day) : null;

    // Checking for sequence errors between prev and current port of call
    if (prevEtdDate && this.etaModel) {
      this.prevEtdIsAfterCurrentEtaError = prevEtdDate.after(this.etaModel.date);
      if (prevEtdDate.equals(this.etaModel.date)) {
        this.prevEtdIsAfterCurrentEtaError = this.prevEtdModel.time.hour > this.etaModel.time.hour
          || (this.prevEtdModel.time.hour === this.etaModel.time.hour
            && this.prevEtdModel.time.minute >= this.etaModel.time.minute);
      }
    } else {
      this.prevEtdIsAfterCurrentEtaError = false;
    }

    // Checking for sequence errors between next and current port of call
    if (nextEtaDate && this.etdModel) {
      this.nextEtaIsBeforeCurrentEtdError = nextEtaDate.before(this.etdModel.date);
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / new-port-call-draft / ship-location-time / eta-etd / eta-etd.component.ts View on Github external
private validateData() {
    if (this.etaEtdModel.eta && this.etaEtdModel.etd) {
      const etaDate = new NgbDate(this.etaEtdModel.eta.date.year, this.etaEtdModel.eta.date.month, this.etaEtdModel.eta.date.day);
      const etdDate = new NgbDate(this.etaEtdModel.etd.date.year, this.etaEtdModel.etd.date.month, this.etaEtdModel.etd.date.day);

      this.dateSequenceError = etdDate.before(etaDate);

      if (etdDate.equals(etaDate)) {
        this.timeSequenceError = this.etaEtdModel.eta.time.hour > this.etaEtdModel.etd.time.hour
          || (this.etaEtdModel.eta.time.hour === this.etaEtdModel.etd.time.hour
          && this.etaEtdModel.eta.time.minute >= this.etaEtdModel.etd.time.minute);
      } else {
        this.timeSequenceError = false;
      }
    } else {
      this.dateSequenceError = false;
      this.timeSequenceError = false;
    }
    this.persistData();
  }
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / registration / forms / security / last-10-port-calls / last-10-port-calls.component.ts View on Github external
private dateStringToDateTime(dateString) {
    const date = new Date(dateString);
    const dateTime: DateTime = {
      date: new NgbDate(date.getFullYear(), date.getMonth() + 1, date.getDate()),
      time: new NgbTime(date.getHours(), date.getMinutes(), 0)
    };
    return dateTime;
  }
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / shared / services / validate-date-time.service.ts View on Github external
getNgbDateFormat(date): NgbDate {
    const newDate = new NgbDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
    return newDate;
  }
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / registration / forms / security / last-10-port-calls / last-10-port-calls.component.ts View on Github external
private isAfter(dt1: DateTime, dt2: DateTime) {
    if (dt1.date && dt2.date) {
      const dt1Date = new NgbDate(dt1.date.year, dt1.date.month, dt1.date.day);
      const dt2Date = new NgbDate(dt2.date.year, dt2.date.month, dt2.date.day);
      if (dt1Date.after(dt2Date)) {
        return true;
      }
      if (dt1Date.equals(dt2Date)) {
        if (dt1.time.hour > dt2.time.hour || (dt1.time.hour === dt2.time.hour && dt1.time.minute >= dt2.time.minute)) {
          return true;
        }
      }
    }
    return false;
  }
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / new-port-call-draft / ship-location-time / eta-etd / eta-etd.component.ts View on Github external
private validateData() {
    if (this.etaEtdModel.eta && this.etaEtdModel.etd) {
      const etaDate = new NgbDate(this.etaEtdModel.eta.date.year, this.etaEtdModel.eta.date.month, this.etaEtdModel.eta.date.day);
      const etdDate = new NgbDate(this.etaEtdModel.etd.date.year, this.etaEtdModel.etd.date.month, this.etaEtdModel.etd.date.day);

      this.dateSequenceError = etdDate.before(etaDate);

      if (etdDate.equals(etaDate)) {
        this.timeSequenceError = this.etaEtdModel.eta.time.hour > this.etaEtdModel.etd.time.hour
          || (this.etaEtdModel.eta.time.hour === this.etaEtdModel.etd.time.hour
          && this.etaEtdModel.eta.time.minute >= this.etaEtdModel.etd.time.minute);
      } else {
        this.timeSequenceError = false;
      }
    } else {
      this.dateSequenceError = false;
      this.timeSequenceError = false;
    }
    this.persistData();
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / registration / forms / prev-and-next-poc / prev-and-next-poc.component.ts View on Github external
data => {
        if (data) {
          const dateTime = new Date(data);
          this.nextEtaModel = {
            date: new NgbDate(dateTime.getFullYear(), dateTime.getMonth() + 1, dateTime.getDate()),
            time: new NgbTime(dateTime.getHours(), dateTime.getMinutes(), 0)
          };
        } else {
          this.nextEtaModel = {
            date: null,
            time: new NgbTime(0, 0, 0)
          };
        }
        this.validateDateTime();
      }
    );
github Fundator / IMO-Maritime-Single-Window / IMOMaritimeSingleWindow / Client / src / app / main-content / content-container / port-call / overview / set-actual-time / set-actual-time.component.ts View on Github external
validateDateTime() {
    let arrival: DateTime = null;
    let departure: DateTime = 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 {