Skip to content

Commit 318669f

Browse files
authored
Outlook Calendar - Get Schedule - pass in timezone (#18911)
* add timezone header * pnpm-lock.yaml * versions * package.json version * updates * pnpm-lock.yaml * updates
1 parent 1ccd2b4 commit 318669f

File tree

11 files changed

+76
-13
lines changed

11 files changed

+76
-13
lines changed

components/microsoft_outlook_calendar/actions/create-calendar-event/create-calendar-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook_calendar-create-calendar-event",
6-
version: "0.0.8",
6+
version: "0.0.9",
77
annotations: {
88
destructiveHint: false,
99
openWorldHint: true,

components/microsoft_outlook_calendar/actions/delete-calendar-event/delete-calendar-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook_calendar-delete-calendar-event",
6-
version: "0.0.3",
6+
version: "0.0.4",
77
annotations: {
88
destructiveHint: true,
99
openWorldHint: true,

components/microsoft_outlook_calendar/actions/get-schedule/get-schedule.mjs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { ConfigurationError } from "@pipedream/platform";
22
import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
33
import utils from "../../common/utils.mjs";
4+
import { DateTime } from "luxon";
5+
import { findIana } from "windows-iana";
46

57
export default {
68
key: "microsoft_outlook_calendar-get-schedule",
79
name: "Get Free/Busy Schedule",
810
description: "Get the free/busy availability information for a collection of users, distributions lists, or resources (rooms or equipment) for a specified time period. [See the documentation](https://learn.microsoft.com/en-us/graph/api/calendar-getschedule)",
9-
version: "0.0.5",
11+
version: "0.0.6",
1012
annotations: {
1113
destructiveHint: false,
1214
openWorldHint: true,
@@ -53,6 +55,36 @@ export default {
5355
...opts,
5456
});
5557
},
58+
convertWorkingHoursToItemTimezone(response) {
59+
const workingHours = response?.workingHours;
60+
61+
if (!workingHours) return undefined;
62+
63+
// Extract the Windows-style names
64+
const sourceWinTz = workingHours.timeZone.name;
65+
const targetWinTz = this.timeZone;
66+
67+
// Convert to IANA time zones
68+
const sourceIana = findIana(sourceWinTz)?.[0]?.valueOf() || "UTC";
69+
const targetIana = findIana(targetWinTz)?.[0]?.valueOf() || "UTC";
70+
71+
const startTime = DateTime.fromISO(`2025-01-01T${workingHours.startTime}`, {
72+
zone: sourceIana,
73+
}).setZone(targetIana);
74+
75+
const endTime = DateTime.fromISO(`2025-01-01T${workingHours.endTime}`, {
76+
zone: sourceIana,
77+
}).setZone(targetIana);
78+
79+
return {
80+
...workingHours,
81+
startTime: startTime.toFormat("HH:mm:ss.SSSSSSS"),
82+
endTime: endTime.toFormat("HH:mm:ss.SSSSSSS"),
83+
timeZone: {
84+
name: targetWinTz,
85+
},
86+
};
87+
},
5688
},
5789
async run({ $ }) {
5890
if (this.schedules === null || this.schedules === undefined || this.schedules?.length === 0) {
@@ -75,8 +107,18 @@ export default {
75107
},
76108
availabilityViewInterval: this.availabilityViewInterval,
77109
},
110+
headers: {
111+
Prefer: `outlook.timezone="${this.timeZone}"`,
112+
},
78113
});
79114

115+
if (value?.length > 0 && value[0].workingHours) {
116+
const convertedHours = this.convertWorkingHoursToItemTimezone(value[0]);
117+
if (convertedHours) {
118+
value[0].workingHours = convertedHours;
119+
}
120+
}
121+
80122
$.export("$summary", `Successfully retrieved schedules for \`${schedules.join("`, `")}\``);
81123

82124
return value;

components/microsoft_outlook_calendar/actions/list-events/list-events.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook_calendar-list-events",
55
name: "List Events",
66
description: "Get a list of event objects in the user's mailbox. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-events)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/microsoft_outlook_calendar/actions/update-calendar-event/update-calendar-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook_calendar-update-calendar-event",
6-
version: "0.0.3",
6+
version: "0.0.4",
77
annotations: {
88
destructiveHint: true,
99
openWorldHint: true,

components/microsoft_outlook_calendar/microsoft_outlook_calendar.app.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ export default {
8484
_getUrl(path) {
8585
return `https://graph.microsoft.com/v1.0${path}`;
8686
},
87-
_getHeaders() {
87+
_getHeaders(headers = {}) {
8888
return {
8989
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
9090
"accept": "application/json",
9191
"Content-Type": "application/json",
92+
...headers,
9293
};
9394
},
9495
async _makeRequest({

components/microsoft_outlook_calendar/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/microsoft_outlook_calendar",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "Pipedream Microsoft Outlook Calendar Components",
55
"main": "microsoft_outlook_calendar.app.mjs",
66
"keywords": [
@@ -17,6 +17,8 @@
1717
"dependencies": {
1818
"@pipedream/microsoft_outlook": "^1.7.3",
1919
"@pipedream/pipedream": "^0.4.2",
20-
"@pipedream/platform": "^3.0.3"
20+
"@pipedream/platform": "^3.1.0",
21+
"luxon": "^3.7.2",
22+
"windows-iana": "^5.1.0"
2123
}
2224
}

components/microsoft_outlook_calendar/sources/new-calendar-event/new-calendar-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "microsoft_outlook_calendar-new-calendar-event",
66
name: "New Calendar Event (Instant)",
77
description: "Emit new event when a new Calendar event is created",
8-
version: "0.0.8",
8+
version: "0.0.9",
99
type: "source",
1010
hooks: {
1111
...common.hooks,

components/microsoft_outlook_calendar/sources/new-upcoming-event/new-upcoming-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "microsoft_outlook_calendar-new-upcoming-event",
77
name: "New Upcoming Calendar Event",
88
description: "Emit new event when a Calendar event is upcoming, this source is using `reminderMinutesBeforeStart` property of the event to determine the time it should emit.",
9-
version: "0.0.4",
9+
version: "0.0.5",
1010
type: "source",
1111
props: {
1212
...common.props,

components/microsoft_outlook_calendar/sources/updated-calendar-event/updated-calendar-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "microsoft_outlook_calendar-updated-calendar-event",
66
name: "New Calendar Event Update (Instant)",
77
description: "Emit new event when a Calendar event is updated",
8-
version: "0.0.8",
8+
version: "0.0.9",
99
type: "source",
1010
hooks: {
1111
...common.hooks,

0 commit comments

Comments
 (0)