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

Fix timezone display for logs on UI #23075

Merged
merged 1 commit into from
Apr 21, 2022
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 airflow/www/static/js/datetime_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function updateAllDateTimes() {
const dt = moment($el.attr('datetime'));
// eslint-disable-next-line no-underscore-dangle
if (dt._isValid) {
$el.text(dt.format(defaultFormat));
$el.text(dt.format($el.data('with-tz') ? defaultFormatWithTZ : defaultFormat));
}
if ($el.attr('title') !== undefined) {
// If displayed date is not UTC, have the UTC date in a title attribute
Expand Down
5 changes: 2 additions & 3 deletions airflow/www/static/js/ti_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

/* global document, window, $, moment, Airflow */
/* global document, window, $ */
import { escapeHtml } from './main';
import { getMetaValue } from './utils';
import { formatDateTime } from './datetime_utils';
Expand Down Expand Up @@ -118,10 +118,9 @@ function autoTailingLog(tryNumber, metadata = null, autoTailing = false) {

// The message may contain HTML, so either have to escape it or write it as text.
const escapedMessage = escapeHtml(item[1]);
const tzOffset = moment().tz(Airflow.serverTimezone).format('Z');
const linkifiedMessage = escapedMessage
.replace(urlRegex, (url) => `<a href="${url}" target="_blank">${url}</a>`)
.replaceAll(dateRegex, (date) => `<time datetime="${date}${tzOffset}">${formatDateTime(`${date}${tzOffset}`)}</time>`);
.replaceAll(dateRegex, (date) => `<time datetime="${date}+00:00" data-with-tz="true">${formatDateTime(`${date}+00:00`)}</time>`);
logBlock.innerHTML += `${linkifiedMessage}\n`;
});

Expand Down