Skip to content

Commit 16f07fa

Browse files
committed
fix: errors in cardbox clock
1 parent 17937f6 commit 16f07fa

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/components/ui/CardBox.astro

+15-14
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@ const { title, padding, minHeight, link, clock } = Astro.props;
1515
<div class={`text-sm bg-white dark:bg-tertiary p-${padding} rounded-b-sm`} style={`min-height: ${minHeight}px`}>
1616
<slot />
1717
</div>
18-
</div>
18+
{clock && (
19+
<script is:inline>
20+
function updateZuluTime() {
21+
const now = new Date();
22+
const options = { timeZone: 'UTC', hour: '2-digit', minute: '2-digit' };
23+
const zuluTime = now.toLocaleTimeString('en-UK', options);
24+
document.getElementById('zuluTime').textContent = zuluTime+"z";
25+
}
1926

20-
<script is:inline>
21-
function updateZuluTime() {
22-
const now = new Date();
23-
const options = { timeZone: 'UTC', hour: '2-digit', minute: '2-digit' };
24-
const zuluTime = now.toLocaleTimeString('en-UK', options);
25-
document.getElementById('zuluTime').textContent = zuluTime+"z";
26-
}
27+
// Initial call to display the time immediately
28+
updateZuluTime();
2729

28-
// Initial call to display the time immediately
29-
updateZuluTime();
30-
31-
// Update the time every minute
32-
setInterval(updateZuluTime, 60000);
33-
</script>
30+
// Update the time every minute
31+
setInterval(updateZuluTime, 60000);
32+
</script>
33+
)}
34+
</div>

0 commit comments

Comments
 (0)