Skip to content

Commit

Permalink
fix: event date and hours
Browse files Browse the repository at this point in the history
  • Loading branch information
hassnian committed Feb 14, 2024
1 parent 04b21ec commit da6fc4d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions components/drops/CreateCalendarEventModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<script setup lang="ts">
import { NeoButton, NeoIcon, NeoModal } from '@kodadot1/brick'
import ModalBody from '@/components/shared/modals/ModalBody.vue'
import { addHours, format } from 'date-fns'
type CalendarProvider = 'google'
Expand All @@ -50,16 +51,31 @@ const providers: { id: CalendarProvider; label: string; icon: string }[] = [
const eventDetails = {
name: 'Kodadot Generative Drop',
url: 'https://kodadot.xyz/drops',
hoursDuration: 3,
}
const getNextDropDate = (): Date => {
const currentDate = new Date()
const daysUntilThursday = (11 - currentDate.getDay()) % 7
const millisecondsUntilThursday = daysUntilThursday * 24 * 60 * 60 * 1000
currentDate.setUTCHours(14, 0, 0, 0) // Set time to 3 PM CET
const dropDate = new Date(currentDate.getTime() + millisecondsUntilThursday)
dropDate.setHours(currentDate.getHours())
return dropDate
}
const getRfc5545FormatDate = (date: Date) =>
`${format(date, "yyyyMMdd'T'HH")}0000`
const addGoogleEvent = () => {
const dropDate = getNextDropDate()
const queryParams = new URLSearchParams({
action: 'TEMPLATE',
text: eventDetails.name,
dates: '',
dates: `${getRfc5545FormatDate(dropDate)}/${getRfc5545FormatDate(addHours(dropDate, eventDetails.hoursDuration))}`,
location: eventDetails.url,
ctz: 'CET',
recur: 'RRULE:FREQ=WEEKLY;UNTIL=20251007T000000Z;BYDAY=TU,TH',
recur: 'RRULE:FREQ=WEEKLY;BYDAY=TH',
})
const calendarURL = new URL('https://www.google.com/calendar/event')
Expand Down

0 comments on commit da6fc4d

Please sign in to comment.