From 8d2c47915a2d60142d066eb1d789c424d04ccdaa Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Thu, 7 Mar 2024 04:48:00 -0500 Subject: [PATCH 01/22] Add methods for local time and timezone shorthand. --- src/lib/helpers/date.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index c8aaf0fc8..dcbeb7844 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -1,8 +1,10 @@ import { browser } from '$app/environment'; import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; import relativeTime from 'dayjs/plugin/relativeTime'; if (browser) { + dayjs.extend(utc); dayjs.extend(relativeTime); } @@ -41,6 +43,21 @@ export const toLocaleDateTime = (datetime: string | number) => { return date.toLocaleDateString('en', options); }; +export const utcHourToLocaleHour = (utcTimeString: string) => { + // we can use a default utc date format. + const utcDefaultDate = dayjs.utc(`1970-01-01T${utcTimeString}:00`); + return utcDefaultDate.local().format('HH:mm'); +}; + +export const localeTimezoneShortHand = () => { + const options: Intl.DateTimeFormatOptions = { + timeZoneName: 'long' + }; + + const dateWithTimezone = new Intl.DateTimeFormat('en', options).format(new Date()); + return dateWithTimezone.match(/\b([A-Z])/g).join(''); +}; + export const isSameDay = (date1: Date, date2: Date) => { return ( date1.getFullYear() === date2.getFullYear() && From 8eeb8794a6bfd0c76b2c22d96f31215be39290b6 Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Thu, 7 Mar 2024 04:51:47 -0500 Subject: [PATCH 02/22] Add support timings to support component and wizard. --- src/lib/components/support.svelte | 5 ++++- src/routes/console/supportWizard.svelte | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte index fa36429ff..1e94163a9 100644 --- a/src/lib/components/support.svelte +++ b/src/lib/components/support.svelte @@ -13,12 +13,15 @@ import { BillingPlan } from '$lib/constants'; import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte'; import { trackEvent } from '$lib/actions/analytics'; + import { localeTimezoneShortHand, 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')} ${localeTimezoneShortHand()}`; {#if isCloud} @@ -40,7 +43,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/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index a4e28d4c1..f576fc689 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -10,6 +10,7 @@ import { wizard } from '$lib/stores/wizard'; import { VARS } from '$lib/system'; import { organization } from '$lib/stores/organization'; + import { localeTimezoneShortHand, utcHourToLocaleHour } from '$lib/helpers/date'; onDestroy(() => { $supportData = { @@ -76,6 +77,8 @@ } $wizard.finalAction = handleSubmit; + + $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneShortHand()}`; @@ -85,7 +88,7 @@ If you found a bug or have questions, please reach out to the Appwrite team. We try to respond to all messages within our office hours.

-

Available: Mon-Fri 09:00 - 17:00 UTC

+

Available: Mon-Fri, {supportTimings}

Currently: {#if isSupportOnline()} From 887b820eb088174a1c25321b40a7f7eb39d4d47b Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Fri, 8 Mar 2024 10:50:25 +0530 Subject: [PATCH 03/22] replace dayjs implementation with builtin `DateTimeFormat`. --- src/lib/helpers/date.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index dcbeb7844..544863fd9 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -1,10 +1,8 @@ import { browser } from '$app/environment'; import dayjs from 'dayjs'; -import utc from 'dayjs/plugin/utc'; import relativeTime from 'dayjs/plugin/relativeTime'; if (browser) { - dayjs.extend(utc); dayjs.extend(relativeTime); } @@ -44,9 +42,15 @@ export const toLocaleDateTime = (datetime: string | number) => { }; export const utcHourToLocaleHour = (utcTimeString: string) => { - // we can use a default utc date format. - const utcDefaultDate = dayjs.utc(`1970-01-01T${utcTimeString}:00`); - return utcDefaultDate.local().format('HH:mm'); + const defaultDate = new Date(`1970-01-01T${utcTimeString}:00Z`); + + const options: Intl.DateTimeFormatOptions = { + hour: 'numeric', + minute: 'numeric', + hourCycle: 'h23' + }; + + return new Intl.DateTimeFormat('en', options).format(defaultDate); }; export const localeTimezoneShortHand = () => { From 41421c41fac96a716a27eb5b6f2ae834f5972cf6 Mon Sep 17 00:00:00 2001 From: Darshan Date: Fri, 8 Mar 2024 20:16:14 +1100 Subject: [PATCH 04/22] Use current date instead of default. --- src/lib/helpers/date.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index 544863fd9..c85c7ad87 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -42,7 +42,9 @@ export const toLocaleDateTime = (datetime: string | number) => { }; export const utcHourToLocaleHour = (utcTimeString: string) => { - const defaultDate = new Date(`1970-01-01T${utcTimeString}:00Z`); + const now = new Date(); + const [hours, minutes] = utcTimeString.split(':').map(Number); + const currentDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes)); const options: Intl.DateTimeFormatOptions = { hour: 'numeric', @@ -50,7 +52,7 @@ export const utcHourToLocaleHour = (utcTimeString: string) => { hourCycle: 'h23' }; - return new Intl.DateTimeFormat('en', options).format(defaultDate); + return new Intl.DateTimeFormat('en', options).format(currentDate); }; export const localeTimezoneShortHand = () => { From d6ae9671b66894592482a8bbc611e527369d2281 Mon Sep 17 00:00:00 2001 From: Darshan Date: Fri, 8 Mar 2024 19:29:47 +1000 Subject: [PATCH 05/22] Add a method to convert UTC weekday to local weekday. --- src/lib/helpers/date.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index c85c7ad87..c87f9fb81 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -55,6 +55,25 @@ export const utcHourToLocaleHour = (utcTimeString: string) => { return new Intl.DateTimeFormat('en', options).format(currentDate); }; +export const utcWeekDayToLocaleWeekDay = (utcDay: string, utcTimeString: string) => { + const now = new Date(); + + // easy mapping instead of passing numbers. + const dayMap = { + 'Sunday': 0, 'Monday': 1, 'Tuesday': 2, + 'Wednesday': 3, 'Thursday': 4, 'Friday': 5, 'Saturday': 6 + }; + + const utcDayNumber = dayMap[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 localeTimezoneShortHand = () => { const options: Intl.DateTimeFormatOptions = { timeZoneName: 'long' From 119d382b7966df2fc4e2ce6d52be5ec01d388ad1 Mon Sep 17 00:00:00 2001 From: Darshan Date: Fri, 8 Mar 2024 15:03:14 +0530 Subject: [PATCH 06/22] Update the support wizard to display local weekday. --- src/routes/console/supportWizard.svelte | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index f576fc689..1beced944 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -10,7 +10,7 @@ import { wizard } from '$lib/stores/wizard'; import { VARS } from '$lib/system'; import { organization } from '$lib/stores/organization'; - import { localeTimezoneShortHand, utcHourToLocaleHour } from '$lib/helpers/date'; + import { localeTimezoneShortHand, utcHourToLocaleHour, utcWeekDayToLocaleWeekDay } from '$lib/helpers/date'; onDestroy(() => { $supportData = { @@ -78,7 +78,9 @@ $wizard.finalAction = handleSubmit; - $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneShortHand()}`; + const workTimings = { start: '09:00', end: '17:00', startDay: 'Monday', endDay: 'Friday' }; + $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)} ${localeTimezoneShortHand()}`; + $: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`; @@ -88,7 +90,7 @@ If you found a bug or have questions, please reach out to the Appwrite team. We try to respond to all messages within our office hours.

-

Available: Mon-Fri, {supportTimings}

+

Available: {supportWeekDays}, {supportTimings}

Currently: {#if isSupportOnline()} From dc2672a4924afca31581adf8af92352fd3625832 Mon Sep 17 00:00:00 2001 From: Darshan Date: Fri, 8 Mar 2024 19:48:12 +1000 Subject: [PATCH 07/22] Fix format for build, misc. --- src/lib/helpers/date.ts | 13 +++++++++---- src/routes/console/supportWizard.svelte | 10 ++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index c87f9fb81..9102d5a3c 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -44,7 +44,7 @@ export const toLocaleDateTime = (datetime: string | number) => { export const utcHourToLocaleHour = (utcTimeString: string) => { const now = new Date(); const [hours, minutes] = utcTimeString.split(':').map(Number); - const currentDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes)); + const customTime = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes); const options: Intl.DateTimeFormatOptions = { hour: 'numeric', @@ -52,7 +52,7 @@ export const utcHourToLocaleHour = (utcTimeString: string) => { hourCycle: 'h23' }; - return new Intl.DateTimeFormat('en', options).format(currentDate); + return new Intl.DateTimeFormat('en', options).format(new Date(customTime)); }; export const utcWeekDayToLocaleWeekDay = (utcDay: string, utcTimeString: string) => { @@ -60,8 +60,13 @@ export const utcWeekDayToLocaleWeekDay = (utcDay: string, utcTimeString: string) // easy mapping instead of passing numbers. const dayMap = { - 'Sunday': 0, 'Monday': 1, 'Tuesday': 2, - 'Wednesday': 3, 'Thursday': 4, 'Friday': 5, 'Saturday': 6 + Sunday: 0, + Monday: 1, + Tuesday: 2, + Wednesday: 3, + Thursday: 4, + Friday: 5, + Saturday: 6 }; const utcDayNumber = dayMap[utcDay]; diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index 1beced944..ebcac1157 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -10,7 +10,11 @@ import { wizard } from '$lib/stores/wizard'; import { VARS } from '$lib/system'; import { organization } from '$lib/stores/organization'; - import { localeTimezoneShortHand, utcHourToLocaleHour, utcWeekDayToLocaleWeekDay } from '$lib/helpers/date'; + import { + localeTimezoneShortHand, + utcHourToLocaleHour, + utcWeekDayToLocaleWeekDay + } from '$lib/helpers/date'; onDestroy(() => { $supportData = { @@ -90,7 +94,9 @@ If you found a bug or have questions, please reach out to the Appwrite team. We try to respond to all messages within our office hours.

-

Available: {supportWeekDays}, {supportTimings}

+

+ Available: {supportWeekDays}, {supportTimings} +

Currently: {#if isSupportOnline()} From 19425168b52ef674141dd532ba2485e0cbd82a24 Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Sun, 10 Mar 2024 19:43:20 +0530 Subject: [PATCH 08/22] Add a weekday type. --- src/lib/helpers/date.ts | 6 ++++-- src/routes/console/supportWizard.svelte | 9 +++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index b18047339..a01338e35 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -2,6 +2,8 @@ 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); } @@ -87,11 +89,11 @@ export const utcHourToLocaleHour = (utcTimeString: string) => { return new Intl.DateTimeFormat('en', options).format(new Date(customTime)); }; -export const utcWeekDayToLocaleWeekDay = (utcDay: string, utcTimeString: string) => { +export const utcWeekDayToLocaleWeekDay = (utcDay: WeekDay, utcTimeString: string) => { const now = new Date(); // easy mapping instead of passing numbers. - const dayMap = { + const dayMap: { [day in WeekDay]: number } = { Sunday: 0, Monday: 1, Tuesday: 2, diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index ebcac1157..02fa1cdef 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -10,11 +10,8 @@ import { wizard } from '$lib/stores/wizard'; import { VARS } from '$lib/system'; import { organization } from '$lib/stores/organization'; - import { - localeTimezoneShortHand, - utcHourToLocaleHour, - utcWeekDayToLocaleWeekDay - } from '$lib/helpers/date'; + import type { WeekDay } from '$lib/helpers/date'; + import { localeTimezoneShortHand, utcHourToLocaleHour, utcWeekDayToLocaleWeekDay } from '$lib/helpers/date'; onDestroy(() => { $supportData = { @@ -82,7 +79,7 @@ $wizard.finalAction = handleSubmit; - const workTimings = { start: '09:00', end: '17:00', startDay: 'Monday', endDay: 'Friday' }; + const workTimings = { start: '09:00', end: '17:00', startDay: 'Monday' as WeekDay, endDay: 'Friday' as WeekDay }; $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)} ${localeTimezoneShortHand()}`; $: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`; From a2285fc8bce128e8d22d1243b0a1b33517db6c02 Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Sun, 10 Mar 2024 19:45:24 +0530 Subject: [PATCH 09/22] add tests for date. --- tests/unit/helpers/date.test.ts | 37 ++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/unit/helpers/date.test.ts b/tests/unit/helpers/date.test.ts index d28106973..01e1f5d49 100644 --- a/tests/unit/helpers/date.test.ts +++ b/tests/unit/helpers/date.test.ts @@ -1,4 +1,5 @@ import '@testing-library/jest-dom'; +import type { WeekDay } from '$lib/helpers/date'; import { toLocaleDate, toLocaleDateTime, @@ -6,7 +7,9 @@ import { isValidDate, diffDays, toLocaleDateISO, - toLocaleTimeISO + toLocaleTimeISO, + utcHourToLocaleHour, + utcWeekDayToLocaleWeekDay } from '$lib/helpers/date'; describe('local date', () => { @@ -121,3 +124,35 @@ describe('diff days', () => { }); }); }); + +describe('utc hour to local hour', () => { + const entries: Array<[string, string]> = [ + ['09:00', '04:00'], + ['10:45', '05:45'], + ['11:59', '06:59'], + ['17:00', '12:00'], + ['22:36', '17:36'] + ]; + + entries.forEach(([value, expected]) => { + it(value, () => { + expect(utcHourToLocaleHour(value)).toBe(expected); + }); + }); +}); + +describe('utc week day to local week day', () => { + const entries: Array<[WeekDay, string, string]> = [ + ['Sunday', '00:00', 'Sat'], + ['Sunday', '22:00', 'Sun'], + ['Wednesday', '13:00', 'Wed'], + ['Friday', '23:59', 'Fri'], + ['Saturday', '10:00', 'Sat'] + ]; + + entries.forEach(([weekDay, utcTimeString, expected]) => { + it(`${weekDay} ${utcTimeString}`, () => { + expect(utcWeekDayToLocaleWeekDay(weekDay, utcTimeString)).toBe(expected); + }); + }); +}); From 9ee4d0db0f9337acc2f2af7812c5642085190cbc Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Sun, 10 Mar 2024 20:12:34 +0530 Subject: [PATCH 10/22] better indexing. --- src/lib/helpers/date.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index a01338e35..b3f4ccd3c 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -92,18 +92,17 @@ export const utcHourToLocaleHour = (utcTimeString: string) => { export const utcWeekDayToLocaleWeekDay = (utcDay: WeekDay, utcTimeString: string) => { const now = new Date(); - // easy mapping instead of passing numbers. - const dayMap: { [day in WeekDay]: number } = { - Sunday: 0, - Monday: 1, - Tuesday: 2, - Wednesday: 3, - Thursday: 4, - Friday: 5, - Saturday: 6 - }; + const daysOfTheWeek: WeekDay[] = [ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday' + ]; - const utcDayNumber = dayMap[utcDay]; + const utcDayNumber = daysOfTheWeek.indexOf(utcDay); const [hours, minutes] = utcTimeString.split(':').map(Number); const daysUntilNextUtcDay = (7 + utcDayNumber - now.getUTCDay()) % 7; From 2e4cc2229b3c51906f49b52bfa46129c62bddb79 Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Sun, 10 Mar 2024 20:22:08 +0530 Subject: [PATCH 11/22] fix formatting. --- src/lib/helpers/date.ts | 9 ++++++++- src/routes/console/supportWizard.svelte | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index b3f4ccd3c..e35648528 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -2,7 +2,14 @@ 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'; +export type WeekDay = + | 'Sunday' + | 'Monday' + | 'Tuesday' + | 'Wednesday' + | 'Thursday' + | 'Friday' + | 'Saturday'; if (browser) { dayjs.extend(relativeTime); diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index 02fa1cdef..a0021e9da 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -11,7 +11,11 @@ import { VARS } from '$lib/system'; import { organization } from '$lib/stores/organization'; import type { WeekDay } from '$lib/helpers/date'; - import { localeTimezoneShortHand, utcHourToLocaleHour, utcWeekDayToLocaleWeekDay } from '$lib/helpers/date'; + import { + localeTimezoneShortHand, + utcHourToLocaleHour, + utcWeekDayToLocaleWeekDay + } from '$lib/helpers/date'; onDestroy(() => { $supportData = { @@ -79,7 +83,13 @@ $wizard.finalAction = handleSubmit; - const workTimings = { start: '09:00', end: '17:00', startDay: 'Monday' as WeekDay, endDay: 'Friday' as WeekDay }; + const workTimings = { + start: '09:00', + end: '17:00', + startDay: 'Monday' as WeekDay, + endDay: 'Friday' as WeekDay + }; + $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)} ${localeTimezoneShortHand()}`; $: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`; From 068fa42ebf8cbfa3a752f7b86af8a9de12dc87c3 Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Sun, 10 Mar 2024 21:08:32 +0530 Subject: [PATCH 12/22] Use full timezone name. --- src/lib/helpers/date.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index e35648528..e98bf9100 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -119,13 +119,13 @@ export const utcWeekDayToLocaleWeekDay = (utcDay: WeekDay, utcTimeString: string return new Intl.DateTimeFormat('en', { weekday: 'short' }).format(now); }; -export const localeTimezoneShortHand = () => { +export const localeTimezoneName = () => { const options: Intl.DateTimeFormatOptions = { - timeZoneName: 'long' + timeZoneName: 'longGeneric' }; const dateWithTimezone = new Intl.DateTimeFormat('en', options).format(new Date()); - return dateWithTimezone.match(/\b([A-Z])/g).join(''); + return dateWithTimezone.split(', ')[1]; }; export const isSameDay = (date1: Date, date2: Date) => { From 52bdd15e7c6ddcd4eccbccde0fe251b79463fffb Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Sun, 10 Mar 2024 21:09:42 +0530 Subject: [PATCH 13/22] add tooltip for timezone. --- src/lib/components/support.svelte | 6 ++++-- src/routes/console/supportWizard.svelte | 13 ++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte index 1e94163a9..18c91e79c 100644 --- a/src/lib/components/support.svelte +++ b/src/lib/components/support.svelte @@ -6,6 +6,7 @@ import SupportOnlineDark from '$lib/images/support/support-online-dark.png'; import { app } from '$lib/stores/app'; import { wizard } from '$lib/stores/wizard'; + import Label from '../elements/forms/label.svelte'; import SupportWizard from '../../routes/console/supportWizard.svelte'; import { isSupportOnline, showSupportModal } from '../../routes/console/wizard/support/store'; import { isCloud } from '$lib/system'; @@ -13,7 +14,7 @@ import { BillingPlan } from '$lib/constants'; import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte'; import { trackEvent } from '$lib/actions/analytics'; - import { localeTimezoneShortHand, utcHourToLocaleHour } from '$lib/helpers/date'; + import { localeTimezoneName, utcHourToLocaleHour } from '$lib/helpers/date'; export let show = false; @@ -21,7 +22,7 @@ $organization?.billingPlan === BillingPlan.PRO || $organization?.billingPlan === BillingPlan.SCALE; - $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneShortHand()}`; + $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')}`; {#if isCloud} @@ -44,6 +45,7 @@ {#if isPaid}

Get personalized support from the Appwrite team from {supportTimings} +

{/if}
diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index a0021e9da..e5c65210d 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -3,6 +3,7 @@ import { onDestroy } from 'svelte'; import { isSupportOnline, supportData } from './wizard/support/store'; import Step1 from './wizard/support/step1.svelte'; + import Label from '$lib/elements/forms/label.svelte'; import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import { user } from '$lib/stores/user'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; @@ -10,11 +11,11 @@ import { wizard } from '$lib/stores/wizard'; import { VARS } from '$lib/system'; import { organization } from '$lib/stores/organization'; - import type { WeekDay } from '$lib/helpers/date'; import { - localeTimezoneShortHand, + localeTimezoneName, utcHourToLocaleHour, - utcWeekDayToLocaleWeekDay + utcWeekDayToLocaleWeekDay, + type WeekDay } from '$lib/helpers/date'; onDestroy(() => { @@ -90,7 +91,7 @@ endDay: 'Friday' as WeekDay }; - $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)} ${localeTimezoneShortHand()}`; + $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)}`; $: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`; @@ -102,7 +103,9 @@ respond to all messages within our office hours.

- Available: {supportWeekDays}, {supportTimings} + Available: {supportWeekDays}, {supportTimings} +

Currently: From b741fbf80b0439581419f734a7e1bd589c8c5e07 Mon Sep 17 00:00:00 2001 From: DarShan Pandya Date: Sun, 10 Mar 2024 21:18:40 +0530 Subject: [PATCH 14/22] fix formatting. --- src/lib/components/support.svelte | 2 +- src/routes/console/supportWizard.svelte | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte index 18c91e79c..f706e4999 100644 --- a/src/lib/components/support.svelte +++ b/src/lib/components/support.svelte @@ -45,7 +45,7 @@ {#if isPaid}

Get personalized support from the Appwrite team from {supportTimings} -

{/if}
diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index e5c65210d..0e7fb7d25 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -103,9 +103,8 @@ respond to all messages within our office hours.

- Available: {supportWeekDays}, {supportTimings} - + Available: {supportWeekDays}, {supportTimings} +

Currently: From bee05359d9568e746c071fca650902331ad1668c Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Thu, 4 Apr 2024 12:40:22 +0530 Subject: [PATCH 15/22] fix: convert array to object for perf. --- src/lib/helpers/date.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index e98bf9100..49b5ff7ee 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -99,17 +99,17 @@ export const utcHourToLocaleHour = (utcTimeString: string) => { export const utcWeekDayToLocaleWeekDay = (utcDay: WeekDay, utcTimeString: string) => { const now = new Date(); - const daysOfTheWeek: WeekDay[] = [ - 'Sunday', - 'Monday', - 'Tuesday', - 'Wednesday', - 'Thursday', - 'Friday', - 'Saturday' - ]; + const daysOfTheWeek = { + Sunday: 0, + Monday: 1, + Tuesday: 2, + Wednesday: 3, + Thursday: 4, + Friday: 5, + Saturday: 6 + }; - const utcDayNumber = daysOfTheWeek.indexOf(utcDay); + const utcDayNumber = daysOfTheWeek[utcDay]; const [hours, minutes] = utcTimeString.split(':').map(Number); const daysUntilNextUtcDay = (7 + utcDayNumber - now.getUTCDay()) % 7; From a86c464c12b3d656f5fdb160bc23260c1dfdd4c0 Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Tue, 9 Apr 2024 12:20:32 +0530 Subject: [PATCH 16/22] update: add the timezone in support timings. --- src/lib/components/support.svelte | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte index f706e4999..b75f9cde5 100644 --- a/src/lib/components/support.svelte +++ b/src/lib/components/support.svelte @@ -6,7 +6,6 @@ import SupportOnlineDark from '$lib/images/support/support-online-dark.png'; import { app } from '$lib/stores/app'; import { wizard } from '$lib/stores/wizard'; - import Label from '../elements/forms/label.svelte'; import SupportWizard from '../../routes/console/supportWizard.svelte'; import { isSupportOnline, showSupportModal } from '../../routes/console/wizard/support/store'; import { isCloud } from '$lib/system'; @@ -22,7 +21,7 @@ $organization?.billingPlan === BillingPlan.PRO || $organization?.billingPlan === BillingPlan.SCALE; - $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')}`; + $: supportTimings = `${utcHourToLocaleHour('09:00')} - ${utcHourToLocaleHour('17:00')} ${localeTimezoneName()}`; {#if isCloud} @@ -45,7 +44,6 @@ {#if isPaid}

Get personalized support from the Appwrite team from {supportTimings} -

{/if}
From d5197f7ee72bab37e54453a4d278fbd82449ddf3 Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Wed, 10 Apr 2024 11:42:01 +0530 Subject: [PATCH 17/22] update: show the timezone with support timings. --- src/routes/console/supportWizard.svelte | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte index 0e7fb7d25..877b5a716 100644 --- a/src/routes/console/supportWizard.svelte +++ b/src/routes/console/supportWizard.svelte @@ -3,7 +3,6 @@ import { onDestroy } from 'svelte'; import { isSupportOnline, supportData } from './wizard/support/store'; import Step1 from './wizard/support/step1.svelte'; - import Label from '$lib/elements/forms/label.svelte'; import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import { user } from '$lib/stores/user'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; @@ -91,7 +90,7 @@ endDay: 'Friday' as WeekDay }; - $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)}`; + $: supportTimings = `${utcHourToLocaleHour(workTimings.start)} - ${utcHourToLocaleHour(workTimings.end)} ${localeTimezoneName()}`; $: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`; @@ -104,7 +103,6 @@

Available: {supportWeekDays}, {supportTimings} -

Currently: From 7049f663a2e12b8ef9ca64c303635a4acca6c210 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Mon, 29 Apr 2024 14:38:45 -0700 Subject: [PATCH 18/22] fix(migrations): fix modal not closing We should be using a bound show variable to control the modal. Prior to this PR, we were indirectly controlling the modal by setting the migration ID via the on close handler, but that event is never triggered when the modal is closed. This also refactors the modal to pass in the migration instead of a list of migrations and a migration ID because the entire list is not needed inside the modal. --- .../settings/migrations/+page.svelte | 13 +++++++++--- .../settings/migrations/details.svelte | 20 ++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/routes/console/project-[project]/settings/migrations/+page.svelte b/src/routes/console/project-[project]/settings/migrations/+page.svelte index 2a7877a02..8d5657b18 100644 --- a/src/routes/console/project-[project]/settings/migrations/+page.svelte +++ b/src/routes/console/project-[project]/settings/migrations/+page.svelte @@ -24,10 +24,12 @@ import Status from '$lib/components/status.svelte'; import { capitalize } from '$lib/helpers/string'; import { readOnly } from '$lib/stores/billing'; + import type { Models } from '@appwrite.io/console'; export let data; - let details: string | null = null; + let migration: Models.Migration = null; let showExport = false; + let showMigration = false; const getStatus = (status: string) => { if (status === 'failed') { @@ -129,6 +131,11 @@ // JSON.stringify(migrationData) // )}`; }; + + function showDetails(m: Models.Migration) { + showMigration = true; + migration = m; + } @@ -182,7 +189,7 @@
-
@@ -296,7 +303,7 @@ -
+