Skip to content

Commit e2c8bab

Browse files
[Outlook] Update and map appointment date snippets (#1018)
[Outlook] Update and map appointment date snippets
1 parent 8e37f66 commit e2c8bab

File tree

6 files changed

+150
-31
lines changed

6 files changed

+150
-31
lines changed

samples/outlook/90-other-item-apis/get-end-read.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ api_set:
77
Mailbox: '1.1'
88
script:
99
content: |-
10-
document.getElementById("get").addEventListener("click", get);
10+
document.getElementById("get-utc").addEventListener("click", getUtc);
11+
document.getElementById("get-local").addEventListener("click", getLocal);
1112
12-
function get() {
13-
console.log(`Appointment ends: ${Office.context.mailbox.item.end}`);
13+
function getUtc() {
14+
const time = Office.context.mailbox.item.end;
15+
console.log(`Appointment ends (UTC): ${time.toUTCString()}`);
16+
}
17+
18+
function getLocal() {
19+
const time = Office.context.mailbox.item.end;
20+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
21+
console.log(`Appointment ends (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1422
}
1523
language: typescript
1624
template:
@@ -22,8 +30,11 @@ template:
2230
<section class="ms-Fabric samples ms-font-m">
2331
<h3>Try it out</h3>
2432
<button id="get" class="ms-Button">
25-
<div class="ms-Button-label">Get end date and time</div>
26-
</button>
33+
<div class="ms-Button-label">Get end date and time (UTC)</div>
34+
</button>
35+
<button id="get-local" class="ms-Button">
36+
<div class="ms-Button-label">Get end date and time (local)</div>
37+
</button>
2738
</section>
2839
language: html
2940
style:

samples/outlook/90-other-item-apis/get-set-end-appointment-organizer.yaml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@ api_set:
77
Mailbox: '1.1'
88
script:
99
content: |-
10-
document.getElementById("get").addEventListener("click", get);
10+
document.getElementById("get-utc").addEventListener("click", getUtc);
11+
document.getElementById("get-local").addEventListener("click", getLocal);
1112
document.getElementById("set").addEventListener("click", set);
1213
13-
function get() {
14+
function getUtc() {
1415
Office.context.mailbox.item.end.getAsync((result) => {
1516
if (result.status !== Office.AsyncResultStatus.Succeeded) {
1617
console.error(`Action failed with message ${result.error.message}`);
1718
return;
1819
}
19-
console.log(`Appointment ends: ${result.value}`);
20+
21+
const time = result.value;
22+
console.log(`Appointment ends (UTC): ${time.toUTCString()}`);
23+
});
24+
}
25+
26+
function getLocal() {
27+
Office.context.mailbox.item.end.getAsync((result) => {
28+
if (result.status !== Office.AsyncResultStatus.Succeeded) {
29+
console.error(`Action failed with message ${result.error.message}`);
30+
return;
31+
}
32+
33+
const time = result.value;
34+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
35+
console.log(`Appointment ends (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
2036
});
2137
}
2238
@@ -50,9 +66,12 @@ template:
5066
<button id="set" class="ms-Button">
5167
<div class="ms-Button-label">Set end date and time</div>
5268
</button>
53-
<button id="get" class="ms-Button">
54-
<div class="ms-Button-label">Get end date and time</div>
55-
</button>
69+
<button id="get-utc" class="ms-Button">
70+
<div class="ms-Button-label">Get end date and time (UTC)</div>
71+
</button>
72+
<button id="get-local" class="ms-Button">
73+
<div class="ms-Button-label">Get end date and time (local)</div>
74+
</button>
5675
</section>
5776
language: html
5877
style:
@@ -73,4 +92,4 @@ libraries: |-
7392
https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts
7493
7594
https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css
76-
https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css
95+
https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css

samples/outlook/90-other-item-apis/get-set-start-appointment-organizer.yaml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@ api_set:
77
Mailbox: '1.1'
88
script:
99
content: |-
10-
document.getElementById("get").addEventListener("click", get);
10+
document.getElementById("get-utc").addEventListener("click", getUtc);
11+
document.getElementById("get-local").addEventListener("click", getLocal);
1112
document.getElementById("set").addEventListener("click", set);
1213
13-
function get() {
14+
function getUtc() {
1415
Office.context.mailbox.item.start.getAsync((result) => {
1516
if (result.status !== Office.AsyncResultStatus.Succeeded) {
1617
console.error(`Action failed with message ${result.error.message}`);
1718
return;
1819
}
19-
console.log(`Appointment starts: ${result.value}`);
20+
21+
const time = result.value;
22+
console.log(`Appointment starts (UTC): ${time.toUTCString()}`);
23+
});
24+
}
25+
26+
function getLocal() {
27+
Office.context.mailbox.item.start.getAsync((result) => {
28+
if (result.status !== Office.AsyncResultStatus.Succeeded) {
29+
console.error(`Action failed with message ${result.error.message}`);
30+
return;
31+
}
32+
33+
const time = result.value;
34+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
35+
console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
2036
});
2137
}
2238
@@ -43,9 +59,12 @@ template:
4359
<button id="set" class="ms-Button">
4460
<div class="ms-Button-label">Set start date and time</div>
4561
</button>
46-
<button id="get" class="ms-Button">
47-
<div class="ms-Button-label">Get start date and time</div>
48-
</button>
62+
<button id="get-utc" class="ms-Button">
63+
<div class="ms-Button-label">Get start date and time (UTC)</div>
64+
</button>
65+
<button id="get-local" class="ms-Button">
66+
<div class="ms-Button-label">Get start date and time (local)</div>
67+
</button>
4968
</section>
5069
language: html
5170
style:

samples/outlook/90-other-item-apis/get-start-read.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ api_set:
77
Mailbox: '1.1'
88
script:
99
content: |-
10-
document.getElementById("get").addEventListener("click", get);
10+
document.getElementById("get-utc").addEventListener("click", getUtc);
11+
document.getElementById("get-local").addEventListener("click", getLocal);
1112
12-
function get() {
13-
console.log(`Appointment starts: ${Office.context.mailbox.item.start}`);
13+
function getUtc() {
14+
const time = Office.context.mailbox.item.start;
15+
console.log(`Appointment starts (UTC): ${time.toUTCString()}`);
16+
}
17+
18+
function getLocal() {
19+
const time = Office.context.mailbox.item.start;
20+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
21+
console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1422
}
1523
language: typescript
1624
template:
@@ -21,9 +29,12 @@ template:
2129
</section>
2230
<section class="ms-Fabric samples ms-font-m">
2331
<h3>Try it out</h3>
24-
<button id="get" class="ms-Button">
25-
<div class="ms-Button-label">Get start date and time</div>
26-
</button>
32+
<button id="get-utc" class="ms-Button">
33+
<div class="ms-Button-label">Get start date and time (UTC)</div>
34+
</button>
35+
<button id="get-local" class="ms-Button">
36+
<div class="ms-Button-label">Get start date and time (local)</div>
37+
</button>
2738
</section>
2839
language: html
2940
style:
-52 Bytes
Binary file not shown.

snippet-extractor-output/snippets.yaml

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9330,7 +9330,10 @@ Office.AppointmentCompose#end:member:
93309330
console.error(`Action failed with message ${result.error.message}`);
93319331
return;
93329332
}
9333-
console.log(`Appointment ends: ${result.value}`);
9333+
9334+
const time = result.value;
9335+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
9336+
console.log(`Appointment ends (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
93349337
});
93359338
- >-
93369339
// Link to full sample:
@@ -10062,7 +10065,10 @@ Office.AppointmentCompose#start:member:
1006210065
console.error(`Action failed with message ${result.error.message}`);
1006310066
return;
1006410067
}
10065-
console.log(`Appointment starts: ${result.value}`);
10068+
10069+
const time = result.value;
10070+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
10071+
console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1006610072
});
1006710073
- >-
1006810074
// Link to full sample:
@@ -10448,7 +10454,13 @@ Office.AppointmentRead#end:member:
1044810454
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-end-read.yaml
1044910455

1045010456

10451-
console.log(`Appointment ends: ${Office.context.mailbox.item.end}`);
10457+
const time = Office.context.mailbox.item.end;
10458+
10459+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
10460+
10461+
console.log(`Appointment ends (local): ${localTime.month +
10462+
1}/${localTime.date}/${localTime.year},
10463+
${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1045210464
Office.AppointmentRead#enhancedLocation:member:
1045310465
- >-
1045410466
// Link to full sample:
@@ -10786,7 +10798,13 @@ Office.AppointmentRead#start:member:
1078610798
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml
1078710799

1078810800

10789-
console.log(`Appointment starts: ${Office.context.mailbox.item.start}`);
10801+
const time = Office.context.mailbox.item.start;
10802+
10803+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
10804+
10805+
console.log(`Appointment starts (local): ${localTime.month +
10806+
1}/${localTime.date}/${localTime.year},
10807+
${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1079010808
Office.AppointmentRead#subject:member:
1079110809
- >-
1079210810
// Link to full sample:
@@ -11845,6 +11863,19 @@ Office.Item:interface:
1184511863
console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`);
1184611864
break;
1184711865
}
11866+
Office.LocalClientTime:interface:
11867+
- >-
11868+
// Link to full sample:
11869+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml
11870+
11871+
11872+
const time = Office.context.mailbox.item.start;
11873+
11874+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
11875+
11876+
console.log(`Appointment starts (local): ${localTime.month +
11877+
1}/${localTime.date}/${localTime.year},
11878+
${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1184811879
Office.Location#getAsync:member(2):
1184911880
- >-
1185011881
// Link to full sample:
@@ -11902,6 +11933,19 @@ Office.Mailbox#convertToEwsId:member(1):
1190211933
Office.MailboxEnums.RestVersion.v2_0);
1190311934

1190411935
console.log("EWS ID (from REST ID): " + ewsId2);
11936+
Office.Mailbox#convertToLocalClientTime:member(1):
11937+
- >-
11938+
// Link to full sample:
11939+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml
11940+
11941+
11942+
const time = Office.context.mailbox.item.start;
11943+
11944+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
11945+
11946+
console.log(`Appointment starts (local): ${localTime.month +
11947+
1}/${localTime.date}/${localTime.year},
11948+
${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1190511949
Office.Mailbox#convertToRestId:member(1):
1190611950
- >-
1190711951
// Link to full sample:
@@ -14324,7 +14368,13 @@ Office.MessageRead#end:member:
1432414368
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-end-read.yaml
1432514369

1432614370

14327-
console.log(`Appointment ends: ${Office.context.mailbox.item.end}`);
14371+
const time = Office.context.mailbox.item.end;
14372+
14373+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
14374+
14375+
console.log(`Appointment ends (local): ${localTime.month +
14376+
1}/${localTime.date}/${localTime.year},
14377+
${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1432814378
Office.MessageRead#from:member:
1432914379
- >-
1433014380
// Link to full sample:
@@ -14659,7 +14709,13 @@ Office.MessageRead#start:member:
1465914709
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml
1466014710

1466114711

14662-
console.log(`Appointment starts: ${Office.context.mailbox.item.start}`);
14712+
const time = Office.context.mailbox.item.start;
14713+
14714+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
14715+
14716+
console.log(`Appointment starts (local): ${localTime.month +
14717+
1}/${localTime.date}/${localTime.year},
14718+
${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1466314719
Office.MessageRead#subject:member:
1466414720
- >-
1466514721
// Link to full sample:
@@ -15567,7 +15623,10 @@ Office.Time#getAsync:member(2):
1556715623
console.error(`Action failed with message ${result.error.message}`);
1556815624
return;
1556915625
}
15570-
console.log(`Appointment starts: ${result.value}`);
15626+
15627+
const time = result.value;
15628+
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
15629+
console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
1557115630
});
1557215631
Office.Time#setAsync:member(1):
1557315632
- >-

0 commit comments

Comments
 (0)