Created
February 27, 2024 22:25
-
-
Save thuliumsystems/4b1ed1990a0d5052d28b5435cd51e2fe to your computer and use it in GitHub Desktop.
iCal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextApiRequest, NextApiResponse } from 'next'; | |
import ical, { ICalEventStatus } from 'ical-generator'; | |
const iCal = async (req: NextApiRequest, res: NextApiResponse) => { | |
const calendar = ical({ | |
name: 'my first iCal', | |
prodId: '//cia//inc//EN', | |
url: 'site.com' | |
}); | |
const startTime = new Date(); | |
const endTime = new Date(); | |
const endTime2 = new Date(); | |
const endTime3 = new Date(); | |
const status = ICalEventStatus.CONFIRMED | |
endTime.setHours(startTime.getHours() + 1); | |
endTime2.setHours(startTime.getHours() + 2); | |
endTime3.setHours(startTime.getHours() + 3); | |
calendar.createEvent({ | |
start: startTime, | |
end: endTime, | |
summary: 'Example Event', | |
description: 'It works ;)', | |
location: { title: 'my room', address: 'Kissimmee' }, | |
sequence: 0 | |
}) | |
calendar.createEvent({ | |
start: startTime, | |
end: endTime2, | |
summary: 'Example Event 2', | |
description: 'It works ;2)', | |
location: { title: 'my room 2', address: 'Kissimmee 2' }, | |
status: status, | |
id: 43 | |
}) | |
calendar.serve(res) | |
console.log(calendar.toString()) | |
res.json(calendar.toString()) | |
} | |
export default iCal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment