Skip to content

Commit 90c6f47

Browse files
walleeva2018romangg
authored andcommitted
feat: add release date to ui
Signed-off-by: zubairrafi <walleeva2018@gmail.com>
1 parent d6cc67d commit 90c6f47

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

components/iso-card.vue

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
class="relative object-cover h-[180px]"
1212
/>
1313
</figure>
14+
<div
15+
v-if="dateFromLink!=='' && showDetails"
16+
class="absolute right-2 bg-primary text-primary-content text-xs font-semibold px-2 py-1 rounded-full shadow-md"
17+
>
18+
{{ dateFromLink || '-' }}
19+
</div>
1420
<div
1521
v-if="!showDetails"
1622
class="card-body"
@@ -120,8 +126,8 @@ const props = defineProps({
120126
desktopId: { type: String, required: true },
121127
desktopData: { type: Object, required: true },
122128
isoData: { type: Object, required: true },
123-
showDetails: { type: Boolean, required: true } },
124-
)
129+
showDetails: { type: Boolean, required: true },
130+
})
125131
const emit = defineEmits(['details-toggled'])
126132
127133
function getDownloadLink() {
@@ -133,6 +139,7 @@ function getDownloadLink() {
133139
134140
const showDetailsRef = ref(props.showDetails)
135141
const fullImage = ref(true)
142+
const dateFromLink = ref('')
136143
137144
const enableDetails = () => {
138145
showDetailsRef.value = true
@@ -156,4 +163,26 @@ const getDetailEntry = (entry: string) => {
156163
}
157164
return props.isoData[entry]
158165
}
166+
167+
if (props.isoData?.image) {
168+
const datePattern = /(\d{6})/
169+
const match = props.isoData.image.match(datePattern)
170+
171+
if (match) {
172+
const dateStr = match[1]
173+
const year = parseInt(dateStr.slice(0, 2), 10)
174+
const month = parseInt(dateStr.slice(2, 4), 10) - 1
175+
const day = parseInt(dateStr.slice(4, 6), 10)
176+
177+
const dateObj = new Date(2000 + year, month, day)
178+
179+
const options: Intl.DateTimeFormatOptions = {
180+
year: 'numeric',
181+
month: 'long',
182+
day: 'numeric',
183+
}
184+
185+
dateFromLink.value = dateObj.toLocaleDateString(undefined, options)
186+
}
187+
}
159188
</script>

0 commit comments

Comments
 (0)