How to use the @angular/common.DatePipe 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 locdb / locdb-frend / src / app / pipes / type-pipes / standard.pipe.ts View on Github external
transform(
    typedResource: TypedResourceView,
    forced_type: enums.resourceType = null,
    seperator: string = ', ',
    standalone: boolean = false,
  ): string {
    if (!typedResource) { return '(no resource)'; }
    /* Suffix for contributors, use colon (:) in standalone variants, else a comma (,) */
    const contrib_suffix = standalone ? ': ' : ', ';
    const identifierPepe = new IdentifierPipe();
    const authorsPepe = new AuthorsPipe();
    const editorsPepe = new EditorsPipe();
    const publisherPepe = new PublisherPipe();
    const datePepe = new DatePipe('en'); // locale
    let standardString = '';
    let trv = typedResource;
    if (forced_type != null) {
      // Change the view on the resource to the forced type
      trv = trv.astype(forced_type);
    }
    const title = typedResource.title
    const subtitle = typedResource.subtitle
    const publicationDate = typedResource.publicationDate
    // console.log('Date for title', title, publicationDate);
    const isoPublicationDate = datePepe.transform(publicationDate, 'yyyy');
    // console.log('YYYY date', title, isoPublicationDate);
    const contributors = typedResource.contributors;
    const authors = authorsPepe.transform(contributors, '; ', contrib_suffix);
    const editors = editorsPepe.transform(contributors, '; ', contrib_suffix);
    const publisher = publisherPepe.transform(contributors);
github metatron-app / metatron-discovery / discovery-frontend / src / app / monitoring / audit / job-log / component / job-detail / job-detail.component.ts View on Github external
public onClickOpenQueryModal(queryData: QueryHistory): void {
    const log: Log = new Log;
    const datePipe = new DatePipe('en-EN');
    log.title = 'QUERY';
    log.subTitle = [];
    // 생성시간 | 소요시간 | 성공여부
    log.subTitle.push(datePipe.transform(queryData.queryStartTime, 'yyyy-MM-dd HH:mm'));
    log.subTitle.push(queryData.queryTimeTakenFormatted);
    log.subTitle.push(queryData.queryResultStatus.toString());
    log.data = queryData.query;
    log.isShowCopy = true;
    // log 모달 오픈
    this.logEditorComponent.init(log);
  }
github nitsnets / unicorn_components / src / pipes / format.pipe.ts View on Github external
transform(value: string, format: string = null, locale: string = null): string {

        if (!value || !format) { return value; }
        switch (format) {
            case 'percentage': return (new PercentPipe(locale || this._locale)).transform(value);
            case 'decimal': return (new DecimalPipe(locale || this._locale)).transform(value);
            case 'currency': return (new CurrencyPipe(locale || this._locale)).transform(value);
            case 'date': return (new DatePipe(locale || this._locale)).transform(value);
            default: console.warn(`Format not available: ${format}`);
        }
        return value;
    }
}
github caos / zitadel / console / src / app / pipes / localized-date-pipe / localized-date.pipe.ts View on Github external
public transform(value: any, pattern: string = 'mediumDate'): any {
        if (this.translateService.currentLang && this.translateService.currentLang === ('de' || 'it' || 'fr' || 'eng')) {
            const datePipe: DatePipe = new DatePipe(this.translateService.currentLang);
            return datePipe.transform(value, pattern);
        } else {
            const datePipe: DatePipe = new DatePipe('de');
            return datePipe.transform(value, pattern);
        }
    }
}
github aws / lumberyard / dev / Gems / CloudGemFramework / v1 / Website / CloudGemPortal / app / shared / class / datetime.class.ts View on Github external
public static toString(date: Date, format: string): string {
        return new DatePipe("en-US").transform(date, format);
    }
github Alfresco / alfresco-ng2-components / ng2-components / ng2-activiti-processlist / src / components / process-instance-details.component.ts View on Github external
getFormatDate(value, format: string) {
        let datePipe = new DatePipe('en-US');
        try {
            return datePipe.transform(value, format);
        } catch (err) {
            this.logService.error(`ProcessListInstanceHeader: error parsing date ${value} to format ${format}`);
        }
    }
github spderosso / deja-vu / packages / catalog / schedule / src / app / schedule / shared / schedule.provider.ts View on Github external
public weekViewColumnHeader({ date, locale }: DateFormatterParams): string {
    return new DatePipe(locale).transform(date, 'E', locale);
  }
github dcm4che / dcm4chee-arc-light / dcm4chee-arc-ui2 / src / app / helpers / j4care.service.ts View on Github external
static convertDateRangeToString(rangeArray:Date[]){
        let datePipe = new DatePipe('en_US');

        if(rangeArray && rangeArray.length > 0){
            let stringArray:string[] = [];
            rangeArray.forEach(date =>{
                if(date){
                    stringArray.push(datePipe.transform(date,'yyyyMMdd'))
                }
            });
            return (stringArray.length > 1)?stringArray.join('-'):stringArray.join('');
        }else{
            if(_.isDate(rangeArray)){
                return datePipe.transform(rangeArray,'yyyyMMdd')
            }
            return '';
        }
    }
github Alfresco / alfresco-ng2-components / ng2-components / ng2-activiti-processlist / src / components / activiti-processlist.component.ts View on Github external
getFormatDate(value, format: string) {
        let datePipe = new DatePipe('en-US');
        try {
            return datePipe.transform(value, format);
        } catch (err) {
            return '';
        }
    }