Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ class MainDetails extends React.Component<Props, State> {

renderLastExecutionTime() {
return this.props.item
? this.renderValue(
DateUtils.getLocalDate(this.props.item.updated_at).toFormat(
"yyyy-LL-dd HH:mm:ss",
),
)
? this.renderValue(DateUtils.formatSafeDate(this.props.item.updated_at))
: "-";
}

Expand Down
15 changes: 4 additions & 11 deletions src/components/modules/TransferModule/TaskItem/TaskItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ class TaskItem extends React.Component<Props> {
}

renderHeader(status: string) {
const date = this.props.item.updated_at
? this.props.item.updated_at
: this.props.item.created_at;
const date =
this.props.item.updated_at || this.props.item.created_at || null;

const instance = this.props.instancesDetails.find(
i => i.id === this.props.item.instance,
Expand Down Expand Up @@ -276,9 +275,7 @@ class TaskItem extends React.Component<Props> {
{this.getLastMessage()}
</HeaderData>
<HeaderData width={this.props.columnWidths[3]}>
{date
? DateUtils.getLocalDate(date).toFormat("yyyy-LL-dd HH:mm:ss")
: "-"}
{DateUtils.formatSafeDate(date)}
</HeaderData>
<ArrowStyled
primary
Expand Down Expand Up @@ -346,11 +343,7 @@ class TaskItem extends React.Component<Props> {
}
>
<ProgressUpdateDate width={this.props.columnWidths[0]}>
<span>
{DateUtils.getLocalDate(update.created_at).toFormat(
"yyyy-LL-dd HH:mm:ss",
)}
</span>
<span>{DateUtils.formatSafeDate(update.created_at)}</span>
</ProgressUpdateDate>
<ProgressUpdateValue>
{update.message}
Expand Down
14 changes: 14 additions & 0 deletions src/utils/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ class DateUtils {
}
}

static formatSafeDate(
value: string | Date | null | undefined,
fallback = "—",
): string {
if (value == null) {
return fallback;
}
const dt = this.getLocalDate(value);
if (!dt.isValid) {
return fallback;
}
return dt.toFormat("yyyy-LL-dd HH:mm:ss");
}

static toUnix(date: Date): number {
return parseInt((date.getTime() / 1000).toFixed(0), 10);
}
Expand Down
Loading