Skip to content

Commit 6c76e2d

Browse files
Get VTIMEZONE data from a time zone database lib
Signed-off-by: Christoph Wurst <[email protected]>
1 parent a98f2bc commit 6c76e2d

8 files changed

Lines changed: 47 additions & 22 deletions

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
/apps/comments/js/*.js.map binary
88
/apps/dashboard/js/*.js binary
99
/apps/dashboard/js/*.js.map binary
10+
/apps/dav/js/*.js binary
11+
/apps/dav/js/*.js.map binary
1012
/apps/files/js/dist/*.js binary
1113
/apps/files/js/dist/*.js.map binary
1214
/apps/files_sharing/js/dist/*.js binary

apps/dav/js/settings-admin-caldav.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/dav/js/settings-admin-caldav.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/dav/js/settings-personal-availability.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/dav/js/settings-personal-availability.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/dav/src/service/CalendarService.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { getClient } from '../dav/client'
2222
import ICAL from 'ical.js'
2323
import logger from './logger'
2424
import { parseXML } from 'webdav/dist/node/tools/dav'
25+
import { getZoneString } from 'icalzone'
2526
import { v4 as uuidv4 } from 'uuid'
2627

2728
export function getEmptySlots() {
@@ -107,11 +108,21 @@ export async function saveScheduleInboxAvailability(slots, timezoneId) {
107108
})))]
108109

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

111113
// Store time zone info
112-
const timezoneComp = new ICAL.Component('vtimezone')
113-
timezoneComp.addPropertyWithValue('tzid', timezoneId)
114-
vcalendarComp.addSubcomponent(timezoneComp)
114+
// If possible we use the info from a time zone database
115+
const predefinedTimezoneIcal = getZoneString(timezoneId)
116+
if (predefinedTimezoneIcal) {
117+
const timezoneComp = new ICAL.Component(ICAL.parse(predefinedTimezoneIcal))
118+
console.info('tz comp', timezoneComp, predefinedTimezoneIcal)
119+
vcalendarComp.addSubcomponent(timezoneComp)
120+
} else {
121+
// Fall back to a simple markup
122+
const timezoneComp = new ICAL.Component('vtimezone')
123+
timezoneComp.addPropertyWithValue('tzid', timezoneId)
124+
vcalendarComp.addSubcomponent(timezoneComp)
125+
}
115126

116127
// Store availability info
117128
const vavailabilityComp = new ICAL.Component('vavailability')

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"escape-html": "^1.0.3",
5757
"handlebars": "^4.7.7",
5858
"ical.js": "^1.4.0",
59+
"icalzone": "^0.0.1",
5960
"jquery": "~3.3",
6061
"jquery-migrate": "~3.3",
6162
"jquery-ui": "^1.13.0",

0 commit comments

Comments
 (0)