Skip to content

Commit

Permalink
Get VTIMEZONE data from a time zone database lib
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Oct 25, 2021
1 parent 9b6238a commit 6301531
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/dav/js/settings-admin-caldav.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/dav/js/settings-admin-caldav.js.map

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions apps/dav/src/service/CalendarService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { getClient } from '../dav/client'
import ICAL from 'ical.js'
import logger from './logger'
import { parseXML } from 'webdav/dist/node/tools/dav'
import { getZoneString } from 'icalzone'
import { v4 as uuidv4 } from 'uuid'

export function getEmptySlots() {
Expand Down Expand Up @@ -107,11 +108,21 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
})))]

const vcalendarComp = new ICAL.Component('vcalendar')
vcalendarComp.addPropertyWithValue('prodid', 'Nextcloud DAV app')

// Store time zone info
const timezoneComp = new ICAL.Component('vtimezone')
timezoneComp.addPropertyWithValue('tzid', timezoneId)
vcalendarComp.addSubcomponent(timezoneComp)
// If possible we use the info from a time zone database
const predefinedTimezoneIcal = getZoneString(timezoneId)
if (predefinedTimezoneIcal) {
const timezoneComp = new ICAL.Component(ICAL.parse(predefinedTimezoneIcal))
console.info('tz comp', timezoneComp, predefinedTimezoneIcal)
vcalendarComp.addSubcomponent(timezoneComp)
} else {
// Fall back to a simple markup
const timezoneComp = new ICAL.Component('vtimezone')
timezoneComp.addPropertyWithValue('tzid', timezoneId)
vcalendarComp.addSubcomponent(timezoneComp)
}

// Store availability info
const vavailabilityComp = new ICAL.Component('vavailability')
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"escape-html": "^1.0.3",
"handlebars": "^4.7.7",
"ical.js": "^1.4.0",
"icalzone": "^0.0.1",
"jquery": "~3.3",
"jquery-migrate": "~3.3",
"jquery-ui": "^1.13.0",
Expand Down

0 comments on commit 6301531

Please sign in to comment.