Timezone aware UI
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<header class="grid justify-center z-10">
|
<header class="grid justify-center z-10">
|
||||||
<div class="greetings justify-center pt-2 pb-3">
|
<div class="greetings justify-center pt-2 pb-3">
|
||||||
<h1 class="green">
|
<h1 class="green">
|
||||||
<RouterLink to="/">DigiSnaxx.com</RouterLink>
|
<a href="/">DigiSnaxx.com</a>
|
||||||
</h1>
|
</h1>
|
||||||
<!-- <span class="subtitle z-40">
|
<!-- <span class="subtitle z-40">
|
||||||
another <a href="https://www.dreamfreely.org" targe="_blank">DreamFreely</a> project
|
another <a href="https://www.dreamfreely.org" targe="_blank">DreamFreely</a> project
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { useEventsStore } from '../../stores/EventsStore';
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
|
|
||||||
|
const EventsStore = useEventsStore();
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -13,7 +16,8 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
function format_date(dateString) {
|
function format_date(dateString) {
|
||||||
let date = moment.utc(dateString);
|
let page_tz = EventsStore.timezone
|
||||||
|
let date = moment.utc(dateString).tz(page_tz);
|
||||||
return date.format('dd @ h:mm a');
|
return date.format('dd @ h:mm a');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ const router = createRouter({
|
|||||||
name: 'stl',
|
name: 'stl',
|
||||||
component: DigiSnaxxView
|
component: DigiSnaxxView
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// path: '/live',
|
// path: '/live',
|
||||||
// name: 'live',
|
// name: 'live',
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export const useEventsStore = defineStore('Events', {
|
|||||||
new_msg: "",
|
new_msg: "",
|
||||||
today: "",
|
today: "",
|
||||||
shortcode: "",
|
shortcode: "",
|
||||||
|
timezone: "",
|
||||||
filter: false,
|
filter: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -37,6 +38,28 @@ export const useEventsStore = defineStore('Events', {
|
|||||||
// console.log("CAL: ", this.shortcode);
|
// console.log("CAL: ", this.shortcode);
|
||||||
// return this.shortcode;
|
// return this.shortcode;
|
||||||
// },
|
// },
|
||||||
|
async settimezone(cal) {
|
||||||
|
console.log("CAL: ", cal)
|
||||||
|
const est = ['bos', 'phl',]
|
||||||
|
const cst = ['chi', 'msp']
|
||||||
|
const mtn = ['dnv',]
|
||||||
|
const pst = ['pda',]
|
||||||
|
const col = ['mde', 'bog']
|
||||||
|
|
||||||
|
if (est.includes(cal)) {
|
||||||
|
this.timezone = "America/New_York"
|
||||||
|
} else if (cst.includes(cal)) {
|
||||||
|
this.timezone = "America/Chicago"
|
||||||
|
console.log("Success")
|
||||||
|
} else if (mtn.includes(cal)) {
|
||||||
|
this.timezone = "America/Denver"
|
||||||
|
} else if (pst.includes(cal)) {
|
||||||
|
this.timezone = "America/Vancouver"
|
||||||
|
} else if (col.includes(cal)) {
|
||||||
|
this.timezone = "America/Bogota"
|
||||||
|
}
|
||||||
|
return this.timezone;
|
||||||
|
},
|
||||||
|
|
||||||
async fetchPromo(cal) {
|
async fetchPromo(cal) {
|
||||||
const results = await fetch(`${apiUrl}/events/promo/?calendar__shortcode=${this.shortcode}`, {headers: this.headers});
|
const results = await fetch(`${apiUrl}/events/promo/?calendar__shortcode=${this.shortcode}`, {headers: this.headers});
|
||||||
@@ -51,6 +74,7 @@ export const useEventsStore = defineStore('Events', {
|
|||||||
|
|
||||||
async fetchEvents(cal) {
|
async fetchEvents(cal) {
|
||||||
this.shortcode = cal;
|
this.shortcode = cal;
|
||||||
|
this.settimezone(cal);
|
||||||
const results = await fetch(`${apiUrl}/events/events/?calendar__shortcode=${this.shortcode}`, {headers: this.headers});
|
const results = await fetch(`${apiUrl}/events/events/?calendar__shortcode=${this.shortcode}`, {headers: this.headers});
|
||||||
const data = await results.json();
|
const data = await results.json();
|
||||||
const events_list = data.slice(0,126);
|
const events_list = data.slice(0,126);
|
||||||
|
|||||||
Reference in New Issue
Block a user