Timezone aware UI
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<header class="grid justify-center z-10">
|
||||
<div class="greetings justify-center pt-2 pb-3">
|
||||
<h1 class="green">
|
||||
<RouterLink to="/">DigiSnaxx.com</RouterLink>
|
||||
<a href="/">DigiSnaxx.com</a>
|
||||
</h1>
|
||||
<!-- <span class="subtitle z-40">
|
||||
another <a href="https://www.dreamfreely.org" targe="_blank">DreamFreely</a> project
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<script setup>
|
||||
import { useEventsStore } from '../../stores/EventsStore';
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
const EventsStore = useEventsStore();
|
||||
|
||||
defineProps({
|
||||
item: {
|
||||
type: Object,
|
||||
@@ -13,7 +16,8 @@
|
||||
})
|
||||
|
||||
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');
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -57,7 +57,6 @@ const router = createRouter({
|
||||
name: 'stl',
|
||||
component: DigiSnaxxView
|
||||
},
|
||||
|
||||
// {
|
||||
// path: '/live',
|
||||
// name: 'live',
|
||||
|
||||
@@ -27,6 +27,7 @@ export const useEventsStore = defineStore('Events', {
|
||||
new_msg: "",
|
||||
today: "",
|
||||
shortcode: "",
|
||||
timezone: "",
|
||||
filter: false,
|
||||
};
|
||||
},
|
||||
@@ -37,6 +38,28 @@ export const useEventsStore = defineStore('Events', {
|
||||
// console.log("CAL: ", 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) {
|
||||
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) {
|
||||
this.shortcode = cal;
|
||||
this.settimezone(cal);
|
||||
const results = await fetch(`${apiUrl}/events/events/?calendar__shortcode=${this.shortcode}`, {headers: this.headers});
|
||||
const data = await results.json();
|
||||
const events_list = data.slice(0,126);
|
||||
|
||||
Reference in New Issue
Block a user