作者:node-packag
项目:dashboar
transform(value:number):any {
if (isNumber(value)) {
return new Date(value * 1000);
} else {
if (isString(value)) {
return new Date(value);
}
}
}
作者:AhmedRaghe
项目:nativescript-angula
export function convertToInt(value): number {
let normalizedValue;
if (isBlank(value)) {
normalizedValue = 0;
} else {
if (isNumber(value)) {
normalizedValue = value;
} else {
let parsedValue = parseInt(value.toString());
normalizedValue = isNaN(parsedValue) ? 0 : parsedValue;
}
}
return Math.round(normalizedValue);
}
作者:macpersi
项目:planty-worklogs-angula
transform(value: any, args: any): string {
if (isBlank(value)) return null;
if (!this.supports(value)) {
// throw new InvalidPipeArgumentException(MyDateWorkaroudPipe, value);
throw new BaseException("InvalidPipeArgument: " + MyDateWorkaroudPipe + ", " + value);
}
if (isNumber(value)) {
value = DateWrapper.fromMillis(value);
}
// return DateFormatter.format(value, undefined, 'y MM dd');
let yearStr = DateFormatter.format(value, undefined, 'y');
let monthStr = DateFormatter.format(value, undefined, 'MM');
let dayStr = DateFormatter.format(value, undefined, 'dd');
return yearStr + '-' + monthStr + '-' + dayStr;
}
作者:macpersi
项目:planty-worklogs-angula
supports(obj: any): boolean { return isDate(obj) || isNumber(obj); }