How to use the @angular/common.formatDate function in @angular/common

To help you get started, we’ve selected a few @angular/common 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 UXAspects / UXAspects / e2e / pages / app / date-range-picker / date-range-picker.testpage.component.ts View on Github external
onRangeChange(): void {
        const start = this.start ? formatDate(this.start, 'd MMMM y  h:mm a', 'en-US') + ' ' + this._startTimezone.name : '';
        const end = this.end ? formatDate(this.end, 'd MMMM y  h:mm a', 'en-US') + ' ' + this._endTimezone.name : '';

        if (!this.start || !this.end) {
            return;
        }

        // reset the invalid state
        this.invalid = false;

        // check if the dates are valid
        if (this.getNormalizedDate(this.start, this._startTimezone).getTime() > this.getNormalizedDate(this.end, this._endTimezone).getTime()) {
            this.invalid = true;
        }

        // concatenate the two dates
        this.date = start && end ? `${start}${end}` : start || end;
github BinaryStudioAcademy / bsa-2018-watcher / frontend / src / app / dashboards / report / report.component.ts View on Github external
eventRender.subscribe(() => {
        renderedImg++;
        if (renderedImg === this.chartPDF.length) {
          doc.deletePage(this.chartPDF.length + 1);
          // tslint:disable-next-line:max-line-length
          doc.save(`Report ${DataType[this.selectedType]} Period ${formatDate(this.dateFrom, 'dd/MM/yy HH:mm', 'en-US')} - ${formatDate(this.dateTo, 'dd/MM/yy HH:mm', 'en-US')}`);
        }
      });
    }
github jingkuan / Meel / src / app / providers / invitation-provider.service.ts View on Github external
readableHour(startStr : string, endStr : string) : string {
    let start = new Date(), end = new Date();
    
    var slot = startStr.split('-');
    start.setMonth(Number(slot[1]) - 1, Number(slot[2]));
    start.setHours(Number(slot[3]), Number(slot[4]));
    
    slot = endStr.split('-');
    end.setMonth(Number(slot[1]) - 1, Number(slot[2]));
    end.setHours(Number(slot[3]), Number(slot[4]));

    var tail = formatDate(start, "hh:mm aa", "en-US");
    tail += " to " + formatDate(end, "hh:mm aa", "en-US");

    if(start.getDay() != end.getDay())
    {
      tail += "(tmw)";
    }
    
    return tail;
  }
github jingkuan / Meel / src / app / providers / invitation-provider.service.ts View on Github external
readableHour(startStr : string, endStr : string) : string {
    let start = new Date(), end = new Date();
    
    var slot = startStr.split('-');
    start.setMonth(Number(slot[1]) - 1, Number(slot[2]));
    start.setHours(Number(slot[3]), Number(slot[4]));
    
    slot = endStr.split('-');
    end.setMonth(Number(slot[1]) - 1, Number(slot[2]));
    end.setHours(Number(slot[3]), Number(slot[4]));

    var tail = formatDate(start, "hh:mm aa", "en-US");
    tail += " to " + formatDate(end, "hh:mm aa", "en-US");

    if(start.getDay() != end.getDay())
    {
      tail += "(tmw)";
    }
    
    return tail;
  }
github dockstore / dockstore-ui2 / src / app / notifications / notifications.component.ts View on Github external
removeExpiredDisabledNotifications(notificationsStored: Array) {
    const today = formatDate(new Date(), 'yyyy-MM-dd', 'en');
    this.dismissedNotifications = this.dismissedNotifications.filter(notification => {
      return formatDate(notification.expiration, 'yyyy-MM-dd', 'en') > today;
    });
    localStorage.setItem(this.storageKey, JSON.stringify(this.dismissedNotifications));
  }
github IgniteUI / igniteui-angular-samples / src / app / grid / grid-custom-summaries-selection / summaries-data / summaries-data.component.ts View on Github external
if (this.dates.length > 0) {
          let minDate = 0;
          let maxDate = 0;
          this.dates.forEach((date) => {
            const dMinDate = new Date(minDate);
            const dMaxDate = new Date(maxDate);
            const dDate = new Date(date);
            if (dDate > dMaxDate) {
                maxDate = date;
            }
            if (dDate < dMinDate || minDate === 0) {
                minDate = date;
            }
          });
          this.summariesData["Min Date"] = formatDate(minDate, "mediumDate", "en");
          this.summariesData["Max Date"] = formatDate(maxDate, "mediumDate", "en");
      }
      if (this.bools.length > 0) {
           let trues = 0;
           let falses = 0;
           let count = 0;
           this.bools.forEach((bool) => {
                if (bool) {
                    trues += 1;
                } else {
                    falses += 1;
                }
           });
           count = trues + falses;
           this.summariesData["Discontinued"] = trues + " of " + count;
      }
    }
github mattlewis92 / angular-calendar / projects / angular-calendar / src / modules / common / calendar-a11y.provider.ts View on Github external
public eventDescription({ event, locale }: A11yParams): string {
    if (event.allDay === true) {
      return this.allDayEventDescription({ event, locale });
    }

    const aria = `
      ${formatDate(event.start, 'EEEE MMMM dd', locale)},
      ${event.title}, from ${formatDate(event.start, 'hh:mm a', locale)}
    `;
    if (event.end) {
      return aria + ` to ${formatDate(event.end, 'hh:mm a', locale)}`;
    }
    return aria;
  }
github dynatrace-oss / barista / components / formatters / src / date / date-range.ts View on Github external
dateString1 = 'y MMM d HH:mm';
    }

    if (
      date1.getUTCMonth() === date2.getUTCMonth() &&
      date1.getUTCDay() === date2.getUTCDay()
    ) {
      dateString2 = 'HH:mm';
    }
  } else {
    dateString1 = 'y MMM d HH:mm';
    dateString2 = dateString1;
  }

  dateString1 = formatDate(start, dateString1, locale);
  dateString2 = formatDate(end, dateString2, locale);

  return `${dateString1}${dateString2}`;
}
github jingkuan / Meel / src / app / subpages / send-invt / send-invt.page.ts View on Github external
this.storage.get("time_slot").then((res) => {
      if(!res) {
        let date = new Date();
        date.setMinutes(date.getMinutes() + 30);
        this.start = formatDate(date, "yyyy-MM-dd-HH-mm", 'en-US');
        date.setHours(date.getHours() + 1);
        this.end = formatDate(date, "yyyy-MM-dd-HH-mm", 'en-US');
      } else {
        this.start   = res.start;
        this.end   = res.end;
      }
    })
    .finally(() => {
github mattlewis92 / angular-calendar / projects / angular-calendar / src / modules / common / calendar-a11y.provider.ts View on Github external
public openDayEventsAlert({ date, locale }: A11yParams): string {
    return `${formatDate(date, 'EEEE MMMM dd', locale)} expanded`;
  }