Skip to content

Commit

Permalink
fix invalid end date (#8311)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi FU committed Jun 7, 2020
1 parent f31be7d commit dd0d8b9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions airflow/www/static/js/task-instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@
/* global window, dagTZ, moment, convertSecsToHumanReadable */

// We don't re-import moment again, otherwise webpack will include it twice in the bundle!
import { defaultFormat, formatDateTime } from './datetime-utils';
import { escapeHtml } from './base';
import { defaultFormat, formatDateTime } from './datetime-utils';

function makeDateTimeHTML(start, end) {
// check task ended or not
if (end && end instanceof moment) {
return (
`Started: ${start.format(defaultFormat)} <br> Ended: ${end.format(defaultFormat)} <br>`
)
}
return (
`Started: ${start.format(defaultFormat)} <br> Ended: ${end.format(defaultFormat)} <br>`
`Started: ${start.format(defaultFormat)} <br> Ended: Not ended yet <br>`
)
}

Expand All @@ -47,13 +53,15 @@ function generateTooltipDateTimes(startDate, endDate, dagTZ) {
// Generate User's Local Start and End Date
startDate.tz(localTZ);
tooltipHTML += `<br><strong>Local: ${startDate.format(tzFormat)}</strong><br>`;
tooltipHTML += makeDateTimeHTML(startDate, endDate.tz(localTZ));
const localEndDate = endDate && endDate instanceof moment ? endDate.tz(localTZ) : endDate;
tooltipHTML += makeDateTimeHTML(startDate, localEndDate);

// Generate DAG's Start and End Date
if (dagTZ !== 'UTC' && dagTZ !== localTZ) {
startDate.tz(dagTZ);
tooltipHTML += `<br><strong>DAG's TZ: ${startDate.format(tzFormat)}</strong><br>`;
tooltipHTML += makeDateTimeHTML(startDate, endDate.tz(dagTZ));
const dagTZEndDate = endDate && endDate instanceof moment ? endDate.tz(dagTZ) : endDate;
tooltipHTML += makeDateTimeHTML(startDate, dagTZEndDate);
}

return tooltipHTML;
Expand Down

0 comments on commit dd0d8b9

Please sign in to comment.