Skip to content

Commit 0739079

Browse files
authored
NXT-4230: Make date-time format consistent with version panel on hub (#115)
NXT-4230 (WebUI for "Change Component Link Version")
1 parent ac5cb0f commit 0739079

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

org.knime.ui.js/src/components/workflowEditor/ChangeHubItemVersionModal.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
KdsModal,
88
KdsRadioButtonGroup,
99
} from "@knime/kds-components";
10-
import { formatDateString } from "@knime/utils";
10+
import { formatDateTimeString } from "@knime/utils";
1111
1212
import {
1313
ItemVersion,
@@ -67,6 +67,19 @@ type DropdownOption = {
6767
6868
const MAX_DESCRIPTION_LENGTH = 120;
6969
70+
const formatCreatedOn = (createdOnValue: string | Date) => {
71+
const date =
72+
createdOnValue instanceof Date ? createdOnValue : new Date(createdOnValue);
73+
if (Number.isNaN(date.getTime())) {
74+
const rawValue =
75+
createdOnValue instanceof Date ? null : createdOnValue.trim();
76+
return rawValue ? `Created on ${rawValue}` : "Created on unknown date";
77+
}
78+
const dateInput =
79+
createdOnValue instanceof Date ? date.getTime() : createdOnValue;
80+
return `Created on ${formatDateTimeString(dateInput)}`;
81+
};
82+
7083
const dropdownOptions = computed<DropdownOption[]>(() =>
7184
itemVersions.value
7285
.filter(
@@ -77,13 +90,7 @@ const dropdownOptions = computed<DropdownOption[]>(() =>
7790
const title = version.title ?? "Untitled";
7891
const author = version.author ? `Author: ${version.author}` : null;
7992
const createdOnValue = version.createdOn;
80-
const createdOn = createdOnValue
81-
? `Created: ${formatDateString(
82-
createdOnValue instanceof Date
83-
? createdOnValue.toISOString()
84-
: createdOnValue,
85-
)}`
86-
: null;
93+
const createdOn = createdOnValue ? formatCreatedOn(createdOnValue) : null;
8794
const rawDescription = version.description?.trim() ?? "";
8895
let description: string | null = null;
8996
if (rawDescription.length > 0) {

0 commit comments

Comments
 (0)