Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle DST better in Task Instance tool tips #8104

Merged
merged 1 commit into from
Apr 3, 2020
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
7 changes: 0 additions & 7 deletions airflow/www/static/js/datetime-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,11 @@ export const defaultFormat = 'YYYY-MM-DD, HH:mm:ss';
export const defaultFormatWithTZ = 'YYYY-MM-DD, HH:mm:ss z';
export const defaultTZFormat = 'z (Z)';

let currentTimezone = 'UTC'

export function setDisplayedTimezone(tz) {
currentTimezone = tz;
moment.tz.setDefault(tz);
updateAllDateTimes();
}

export function getCurrentTimezone() {
return currentTimezone;
}

export function formatTimezone(what) {
if (what instanceof moment) {
return what.isUTC() ? 'UTC' : what.format(defaultTZFormat);
Expand Down
14 changes: 8 additions & 6 deletions airflow/www/static/js/task-instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/* global window, dagTZ, moment, convertSecsToHumanReadable */

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

function makeDateTimeHTML(start, end) {
Expand All @@ -31,7 +31,7 @@ function makeDateTimeHTML(start, end) {

function generateTooltipDateTimes(startDate, endDate, dagTZ) {
const tzFormat = 'z (Z)';
const localTZ = getCurrentTimezone();
const localTZ = moment.defaultZone.name;
startDate = moment.utc(startDate);
endDate = moment.utc(endDate);
dagTZ = dagTZ.toUpperCase();
Expand All @@ -46,13 +46,15 @@ function generateTooltipDateTimes(startDate, endDate, dagTZ) {
tooltipHTML += makeDateTimeHTML(startDate, endDate);

// Generate User's Local Start and End Date
tooltipHTML += `<br><strong>Local: ${moment.tz(localTZ).format(tzFormat)}</strong><br>`;
tooltipHTML += makeDateTimeHTML(startDate.tz(localTZ), endDate.tz(localTZ));
startDate.tz(localTZ);
tooltipHTML += `<br><strong>Local: ${startDate.format(tzFormat)}</strong><br>`;
tooltipHTML += makeDateTimeHTML(startDate, endDate.tz(localTZ));

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

return tooltipHTML;
Expand Down