Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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);
}
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;
}
}
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);
}
}
}
public static toString(date: Date, format: string): string {
return new DatePipe("en-US").transform(date, format);
}
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}`);
}
}
public weekViewColumnHeader({ date, locale }: DateFormatterParams): string {
return new DatePipe(locale).transform(date, 'E', locale);
}
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 '';
}
}
getFormatDate(value, format: string) {
let datePipe = new DatePipe('en-US');
try {
return datePipe.transform(value, format);
} catch (err) {
return '';
}
}