Fix times in task lists on Help > System Status
The time adjustments are not necessary because we rely on WP setting timezone to UTC. Manipulation in adjustTimezone difference was causing us to display GMT time. [MAILPOET-6142]
This commit is contained in:
committed by
Aschepikov
parent
dac4eb82a4
commit
ef5ee6d59a
@@ -6,8 +6,6 @@ import {
|
||||
import { MailPoet } from 'mailpoet';
|
||||
import { useState } from 'react';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import parseDate from 'date-fns/parse';
|
||||
import { isPast } from 'date-fns';
|
||||
|
||||
type TasksListDataRowProps = {
|
||||
id: number;
|
||||
@@ -37,13 +35,11 @@ function TaskButton({ task, type }: Props): JSX.Element {
|
||||
const isCancelButton = type === 'cancel';
|
||||
const isRescheduleButton = type === 'reschedule';
|
||||
|
||||
let scheduledDate = task.scheduledAt
|
||||
? parseDate(task.scheduledAt, 'yyyy-MM-dd HH:mm:ss', new Date())
|
||||
: undefined;
|
||||
if (scheduledDate) {
|
||||
scheduledDate = MailPoet.Date.adjustForTimezoneDifference(scheduledDate);
|
||||
}
|
||||
const isScheduledInPast = isPast(scheduledDate);
|
||||
const scheduledDate = task.scheduledAt;
|
||||
const isScheduledInPast = MailPoet.Date.isInPastGmt(
|
||||
scheduledDate,
|
||||
new Date().toISOString(),
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { MailPoet } from 'mailpoet';
|
||||
import parseDate from 'date-fns/parse';
|
||||
import { CancelTaskButton, RescheduleTaskButton } from './tasks-list-actions';
|
||||
|
||||
export type Props = {
|
||||
@@ -28,31 +27,6 @@ function TasksListDataRow({ type, task }: Props): JSX.Element {
|
||||
const canCancelTask = type === 'scheduled' || type === 'running';
|
||||
const canRescheduleTask = type === 'cancelled';
|
||||
|
||||
let scheduled: Date;
|
||||
if (showScheduledAt) {
|
||||
scheduled = parseDate(task.scheduledAt, 'yyyy-MM-dd HH:mm:ss', new Date());
|
||||
if (scheduled) {
|
||||
scheduled = MailPoet.Date.adjustForTimezoneDifference(scheduled);
|
||||
}
|
||||
}
|
||||
|
||||
let cancelled: Date;
|
||||
if (showCancelledAt) {
|
||||
cancelled = parseDate(task.cancelledAt, 'yyyy-MM-dd HH:mm:ss', new Date());
|
||||
if (cancelled) {
|
||||
cancelled = MailPoet.Date.adjustForTimezoneDifference(cancelled);
|
||||
}
|
||||
}
|
||||
|
||||
let updated: Date = parseDate(
|
||||
task.updatedAt,
|
||||
'yyyy-MM-dd HH:mm:ss',
|
||||
new Date(),
|
||||
);
|
||||
if (updated) {
|
||||
updated = MailPoet.Date.adjustForTimezoneDifference(updated);
|
||||
}
|
||||
|
||||
return (
|
||||
<tr>
|
||||
<td className="column column-primary">{task.id}</td>
|
||||
@@ -86,21 +60,21 @@ function TasksListDataRow({ type, task }: Props): JSX.Element {
|
||||
{showScheduledAt ? (
|
||||
<td className="column-date">
|
||||
<abbr>{`${MailPoet.Date.shortFromGmt(
|
||||
scheduled,
|
||||
)} ${MailPoet.Date.timeFromGmt(scheduled)}`}</abbr>
|
||||
task.scheduledAt,
|
||||
)} ${MailPoet.Date.timeFromGmt(task.scheduledAt)}`}</abbr>
|
||||
</td>
|
||||
) : null}
|
||||
{showCancelledAt ? (
|
||||
<td className="column-date">
|
||||
<abbr>{`${MailPoet.Date.shortFromGmt(
|
||||
cancelled,
|
||||
)} ${MailPoet.Date.timeFromGmt(cancelled)}`}</abbr>
|
||||
task.cancelledAt,
|
||||
)} ${MailPoet.Date.timeFromGmt(task.cancelledAt)}`}</abbr>
|
||||
</td>
|
||||
) : null}
|
||||
<td className="column-date">
|
||||
<abbr>{`${MailPoet.Date.shortFromGmt(
|
||||
updated,
|
||||
)} ${MailPoet.Date.timeFromGmt(updated)}`}</abbr>
|
||||
task.updatedAt,
|
||||
)} ${MailPoet.Date.timeFromGmt(task.updatedAt)}`}</abbr>
|
||||
</td>
|
||||
{canCancelTask ? (
|
||||
<td>
|
||||
|
Reference in New Issue
Block a user