Skip to content

Commit e8cfb85

Browse files
committed
NXT-4230: Make datetime format consistent with version panel on hub
NXT-4230 (WebUI for "Change Component Link Version")
1 parent ecda9d6 commit e8cfb85

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ type DropdownOption = {
6767
6868
const MAX_DESCRIPTION_LENGTH = 120;
6969
70+
const formatCreatedOn = (createdOnValue: string | Date) => {
71+
const rawValue =
72+
createdOnValue instanceof Date
73+
? createdOnValue.toISOString()
74+
: createdOnValue;
75+
const dateLabel = formatDateString(rawValue);
76+
const date = new Date(rawValue);
77+
if (Number.isNaN(date.getTime())) {
78+
return `Created on ${dateLabel}`;
79+
}
80+
const timeLabel = date.toLocaleTimeString("en-US", {
81+
hour: "numeric",
82+
minute: "2-digit",
83+
hour12: true,
84+
});
85+
return `Created on ${dateLabel}, ${timeLabel}`;
86+
};
87+
7088
const dropdownOptions = computed<DropdownOption[]>(() =>
7189
itemVersions.value
7290
.filter(
@@ -77,13 +95,7 @@ const dropdownOptions = computed<DropdownOption[]>(() =>
7795
const title = version.title ?? "Untitled";
7896
const author = version.author ? `Author: ${version.author}` : null;
7997
const createdOnValue = version.createdOn;
80-
const createdOn = createdOnValue
81-
? `Created: ${formatDateString(
82-
createdOnValue instanceof Date
83-
? createdOnValue.toISOString()
84-
: createdOnValue,
85-
)}`
86-
: null;
98+
const createdOn = createdOnValue ? formatCreatedOn(createdOnValue) : null;
8799
const rawDescription = version.description?.trim() ?? "";
88100
let description: string | null = null;
89101
if (rawDescription.length > 0) {

0 commit comments

Comments
 (0)