Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/utils/date-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
: "";
}
}
7 changes: 3 additions & 4 deletions app/utils/decorators/decorator-base.ts
Original file line number Diff line number Diff line change
@@ -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<TEntity> {
public original: TEntity;
Expand All @@ -16,7 +15,7 @@ export class DecoratorBase<TEntity> {

protected dateField(value: Date, returnEmptyStringForNullOrUndefined = false): string {
return value
? Moment(value).format("LLLL")
? DateUtils.fullDateAndTime(value)
: returnEmptyStringForNullOrUndefined ? "" : "n/a";
}

Expand Down Expand Up @@ -104,6 +103,6 @@ export class DecoratorBase<TEntity> {
}

private _formatTimespan(value?: Duration) {
return value.toString() === this._maxTimespan ? "Unlimited" : value.humanize();
return value.toString() === this._maxTimespan ? "Unlimited" : DateUtils.prettyDuration(value);
}
}
4 changes: 2 additions & 2 deletions test/app/utils/date-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
});