diff --git a/app/utils/date-utils.ts b/app/utils/date-utils.ts index 1a93d8f471..b75e30f67e 100644 --- a/app/utils/date-utils.ts +++ b/app/utils/date-utils.ts @@ -54,7 +54,7 @@ export class DateUtils { */ public static fullDateAndTime(date: Date | moment.Moment) { return date - ? moment(date).format("MMM Do, YYYY, HH:mm:ss") + ? moment(date).format("MMM Do, YYYY, HH:mm:ss.SSS") : ""; } } diff --git a/app/utils/decorators/decorator-base.ts b/app/utils/decorators/decorator-base.ts index cf341c0628..6641d7cc92 100644 --- a/app/utils/decorators/decorator-base.ts +++ b/app/utils/decorators/decorator-base.ts @@ -1,7 +1,6 @@ -import * as Moment from "moment"; import { Duration } from "moment"; -import { exists } from "app/utils"; +import { DateUtils, exists } from "app/utils"; export class DecoratorBase { public original: TEntity; @@ -16,7 +15,7 @@ export class DecoratorBase { protected dateField(value: Date, returnEmptyStringForNullOrUndefined = false): string { return value - ? Moment(value).format("LLLL") + ? DateUtils.fullDateAndTime(value) : returnEmptyStringForNullOrUndefined ? "" : "n/a"; } @@ -104,6 +103,6 @@ export class DecoratorBase { } private _formatTimespan(value?: Duration) { - return value.toString() === this._maxTimespan ? "Unlimited" : value.humanize(); + return value.toString() === this._maxTimespan ? "Unlimited" : DateUtils.prettyDuration(value); } } diff --git a/test/app/utils/date-utils.spec.ts b/test/app/utils/date-utils.spec.ts index d0c8d5ef46..d843da12e5 100644 --- a/test/app/utils/date-utils.spec.ts +++ b/test/app/utils/date-utils.spec.ts @@ -41,8 +41,8 @@ describe("DateUtils", () => { it("returns formatted full date", () => { // note: date month array starts at 0 for jan const date = new Date(2017, 11, 24, 10, 55, 2); - expect(DateUtils.fullDateAndTime(date)).toEqual(moment(date).format("MMM Do, YYYY, HH:mm:ss")); - expect(DateUtils.fullDateAndTime(date)).toEqual("Dec 24th, 2017, 10:55:02"); + expect(DateUtils.fullDateAndTime(date)).toEqual(moment(date).format("MMM Do, YYYY, HH:mm:ss.SSS")); + expect(DateUtils.fullDateAndTime(date)).toEqual("Dec 24th, 2017, 10:55:02.000"); }); }); });