Skip to content

Commit

Permalink
Fix log timezone in task log view (#19342) (#19401)
Browse files Browse the repository at this point in the history
(cherry picked from commit c96789b)
  • Loading branch information
calfzhou authored and jedcunningham committed Dec 7, 2021
1 parent c6d419b commit 8da7418
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 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, $, */
/* global document, window, $, moment, Airflow */
import { escapeHtml } from './main';
import getMetaValue from './meta_value';
import { formatDateTime } from './datetime_utils';
Expand Down Expand Up @@ -115,9 +115,10 @@ 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}+00:00">${formatDateTime(`${date}+00:00`)}</time>`);
.replaceAll(dateRegex, (date) => `<time datetime="${date}${tzOffset}">${formatDateTime(`${date}${tzOffset}`)}</time>`);
logBlock.innerHTML += `${linkifiedMessage}\n`;
});

Expand Down

0 comments on commit 8da7418

Please sign in to comment.