diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte index ed718960b..d6a8f0ef9 100644 --- a/src/lib/components/support.svelte +++ b/src/lib/components/support.svelte @@ -9,12 +9,15 @@ import { BillingPlan } from '$lib/constants'; import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte'; import { trackEvent } from '$lib/actions/analytics'; + import { localeTimezoneName, utcHourToLocaleHour } from '$lib/helpers/date'; export let show = false; $: isPaid = $organization?.billingPlan === BillingPlan.PRO || $organization?.billingPlan === BillingPlan.SCALE; + + $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneName()}`; {#if isCloud} @@ -23,7 +26,7 @@

Premium support

{#if isPaid}

- Get personalized support from the Appwrite team from 09:00 - 17:00 UTC + Get personalized support from the Appwrite team from {supportTimings}

{/if} diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index d0802c9cc..49b5ff7ee 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -2,6 +2,15 @@ import { browser } from '$app/environment'; import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; +export type WeekDay = + | 'Sunday' + | 'Monday' + | 'Tuesday' + | 'Wednesday' + | 'Thursday' + | 'Friday' + | 'Saturday'; + if (browser) { dayjs.extend(relativeTime); } @@ -73,6 +82,52 @@ export const toLocaleTimeISO = (datetime: string | number) => { return date.toLocaleTimeString('sv'); }; +export const utcHourToLocaleHour = (utcTimeString: string) => { + const now = new Date(); + const [hours, minutes] = utcTimeString.split(':').map(Number); + const customTime = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes); + + const options: Intl.DateTimeFormatOptions = { + hour: 'numeric', + minute: 'numeric', + hourCycle: 'h23' + }; + + return new Intl.DateTimeFormat('en', options).format(new Date(customTime)); +}; + +export const utcWeekDayToLocaleWeekDay = (utcDay: WeekDay, utcTimeString: string) => { + const now = new Date(); + + const daysOfTheWeek = { + Sunday: 0, + Monday: 1, + Tuesday: 2, + Wednesday: 3, + Thursday: 4, + Friday: 5, + Saturday: 6 + }; + + const utcDayNumber = daysOfTheWeek[utcDay]; + const [hours, minutes] = utcTimeString.split(':').map(Number); + + const daysUntilNextUtcDay = (7 + utcDayNumber - now.getUTCDay()) % 7; + now.setUTCDate(now.getUTCDate() + daysUntilNextUtcDay); + now.setUTCHours(hours, minutes, 0, 0); + + return new Intl.DateTimeFormat('en', { weekday: 'short' }).format(now); +}; + +export const localeTimezoneName = () => { + const options: Intl.DateTimeFormatOptions = { + timeZoneName: 'longGeneric' + }; + + const dateWithTimezone = new Intl.DateTimeFormat('en', options).format(new Date()); + return dateWithTimezone.split(', ')[1]; +}; + export const isSameDay = (date1: Date, date2: Date) => { return ( date1.getFullYear() === date2.getFullYear() && diff --git a/src/lib/wizards/functions/steps/createRepository.svelte b/src/lib/wizards/functions/steps/createRepository.svelte index 2b8247a32..d6126890c 100644 --- a/src/lib/wizards/functions/steps/createRepository.svelte +++ b/src/lib/wizards/functions/steps/createRepository.svelte @@ -103,25 +103,23 @@ {:then installations} {#if hasInstallations} -
-
- { - return { - label: entry.organization, - value: entry.$id - }; - })} - on:change={() => { - $installation = installations.find( - (entry) => entry.$id === selectedInstallationId - ); - }} - bind:value={selectedInstallationId} /> -
-
+ + { + return { + label: entry.organization, + value: entry.$id + }; + })} + on:change={() => { + $installation = installations.find( + (entry) => entry.$id === selectedInstallationId + ); + }} + bind:value={selectedInstallationId} /> + {:else}
@@ -296,7 +303,7 @@ -
+