Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
[Web Portal] fix job detail's duration display (#2436)
Browse files Browse the repository at this point in the history
* fix

* 231

* 706
  • Loading branch information
sunqinzheng authored Mar 29, 2019
1 parent 8944849 commit 02b9169
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 71 deletions.
19 changes: 14 additions & 5 deletions src/webportal/src/app/job/job-view/fabric/job-detail/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,27 @@ export function getHumanizedJobStateString(jobInfo) {
}

export function getDurationString(jobInfo) {
const dt0 = jobInfo.jobStatus.createdTime && DateTime.fromMillis(jobInfo.jobStatus.createdTime);
const dt1 = jobInfo.jobStatus.completedTime && DateTime.fromMillis(jobInfo.jobStatus.completedTime);
if (dt0 && dt1) {
return Interval.fromDateTimes(dt0, dt1).toDuration(['hours', 'minutes', 'seconds']).toFormat('h:mm:ss');
const start = jobInfo.jobStatus.createdTime && DateTime.fromMillis(jobInfo.jobStatus.createdTime);
const end = jobInfo.jobStatus.completedTime && DateTime.fromMillis(jobInfo.jobStatus.completedTime);
if (start) {
const dur = Interval.fromDateTimes(start, end || DateTime.utc()).toDuration(['days', 'hours', 'minutes', 'seconds']);
if (dur.days > 0) {
return dur.toFormat(`d'd' h'h' m'm' s's'`);
} else if (dur.hours > 0) {
return dur.toFormat(`h'h' m'm' s's'`);
} else if (dur.minutes > 0) {
return dur.toFormat(`m'm' s's'`);
} else {
return dur.toFormat(`s's'`);
}
} else {
return 'N/A';
}
}


export function printDateTime(dt) {
if (dt > DateTime.local().minus({week: 1}) && dt < DateTime.local().minus({minute: 1})) {
if (dt > DateTime.utc().minus({week: 1}) && dt < DateTime.utc().minus({minute: 1})) {
return `${dt.toRelative()}, ${dt.toLocaleString(DateTime.TIME_24_SIMPLE)}`;
} else {
return dt.toLocaleString(DateTime.DATETIME_MED);
Expand Down
66 changes: 0 additions & 66 deletions src/webportal/src/app/job/job-view/fabric/util.js

This file was deleted.

0 comments on commit 02b9169

Please sign in to comment.