summaryrefslogtreecommitdiff
path: root/src/views/HomeView.vue
diff options
context:
space:
mode:
authorDaniel Andreas Wang <codingforpeace@protonmail.com>2026-03-13 17:38:13 +0100
committerDaniel Andreas Wang <codingforpeace@protonmail.com>2026-03-13 17:38:13 +0100
commitf68ff92f12f8ad4bc4f157b78771d16067eaaf97 (patch)
tree89e6eaf30d851e43d0796d808c82b55baa885d2b /src/views/HomeView.vue
parent0608a926af3e11794f0f86e8fdff5b7a4ffd9254 (diff)
add clockHEADmain
Diffstat (limited to 'src/views/HomeView.vue')
-rw-r--r--src/views/HomeView.vue28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index a5290ec..c780410 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -1,15 +1,39 @@
<script setup lang="ts">
-import { onMounted } from 'vue'
+import { ref, onMounted, onUnmounted } from 'vue'
+import dayjs from 'dayjs'
+import utc from 'dayjs/plugin/utc'
+import timezone from 'dayjs/plugin/timezone'
import { useNewsStore } from '@/stores/news'
+dayjs.extend(utc)
+dayjs.extend(timezone)
+
+const tehranTime = ref('')
const store = useNewsStore()
+let interval: ReturnType<typeof setInterval>
+
+const updateClocks = () => {
+ tehranTime.value = dayjs().tz('Asia/Tehran').format('HH:mm:ss')
+}
onMounted(() => {
- store.fetchTopHeadlines({ country: 'us' })
+ updateClocks()
+ interval = setInterval(updateClocks, 1000)
+ store.fetchEverything({ q: 'iran' })
+})
+
+onUnmounted(() => {
+ clearInterval(interval)
})
</script>
<template>
+ <div class="container">
+ <div class="clock">
+ <div class="time">Tehran time: {{ tehranTime }}</div>
+ </div>
+ </div>
+
<main>
<p v-if="store.loading">Loading...</p>
<p v-else-if="store.error">{{ store.error }}</p>