Skip to content

Commit 53281a6

Browse files
committed
Updated dependencies
1 parent 2187ec5 commit 53281a6

File tree

8 files changed

+114
-121
lines changed

8 files changed

+114
-121
lines changed

demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
To run the completed project in this folder, you need the following:
66

7-
- [Node.js](https://nodejs.org) installed on your development machine. If you do not have Node.js, visit the previous link for download options. (**Note:** This tutorial was written with Node version 12.6.1. The steps in this guide may work with other versions, but that has not been tested.)
7+
- [Node.js](https://nodejs.org) installed on your development machine. If you do not have Node.js, visit the previous link for download options. (**Note:** This tutorial was written with Node version 14.15.0. The steps in this guide may work with other versions, but that has not been tested.)
88
- Either a personal Microsoft account with a mailbox on Outlook.com, or a Microsoft work or school account.
99

1010
If you don't have a Microsoft account, there are a couple of options to get a free account:

demo/graph-tutorial/app.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ app.set('view engine', 'hbs');
8989

9090
// <FormatDateSnippet>
9191
var hbs = require('hbs');
92-
var moment = require('moment');
92+
var parseISO = require('date-fns/parseISO');
93+
var formatDate = require('date-fns/format');
9394
// Helper to format date/time sent by Graph
94-
hbs.registerHelper('eventDateTime', function(dateTime){
95-
return moment(dateTime).format('M/D/YY h:mm A');
95+
hbs.registerHelper('eventDateTime', function(dateTime) {
96+
const date = parseISO(dateTime);
97+
return formatDate(date, 'M/d/yy h:mm a');
9698
});
9799
// </FormatDateSnippet>
98100

demo/graph-tutorial/package-lock.json

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

demo/graph-tutorial/package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
"start": "node ./bin/www"
77
},
88
"dependencies": {
9-
"@azure/msal-node": "^1.0.0-beta.0",
10-
"@microsoft/microsoft-graph-client": "^2.1.1",
9+
"@azure/msal-node": "^1.0.2",
10+
"@microsoft/microsoft-graph-client": "^2.2.1",
1111
"connect-flash": "^0.1.1",
1212
"cookie-parser": "~1.4.4",
13-
"debug": "^4.2.0",
13+
"date-fns": "^2.21.1",
14+
"date-fns-tz": "^1.1.4",
15+
"debug": "^4.3.1",
1416
"dotenv": "^8.2.0",
1517
"express": "^4.17.1",
16-
"express-promise-router": "^4.0.1",
18+
"express-promise-router": "^4.1.0",
1719
"express-session": "^1.17.1",
18-
"express-validator": "^6.6.1",
19-
"hbs": "^4.1.1",
20+
"express-validator": "^6.10.0",
21+
"hbs": "^4.1.2",
2022
"http-errors": "^1.8.0",
2123
"isomorphic-fetch": "^3.0.0",
22-
"moment": "^2.29.1",
23-
"moment-timezone": "^0.5.31",
2424
"morgan": "^1.10.0",
25-
"uuid": "^8.3.1",
26-
"windows-iana": "^4.2.1"
25+
"windows-iana": "^5.0.1"
2726
}
2827
}

demo/graph-tutorial/routes/calendar.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
const router = require('express-promise-router')();
55
const graph = require('../graph.js');
6-
const moment = require('moment-timezone');
6+
const addDays = require('date-fns/addDays');
7+
const formatISO = require('date-fns/formatISO');
8+
const startOfWeek = require('date-fns/startOfWeek');
9+
const zonedTimeToUtc = require('date-fns-tz/zonedTimeToUtc');
710
const iana = require('windows-iana');
811
const { body, validationResult } = require('express-validator');
912
const validator = require('validator');
@@ -24,17 +27,16 @@ router.get('/',
2427
const user = req.app.locals.users[req.session.userId];
2528
// Convert user's Windows time zone ("Pacific Standard Time")
2629
// to IANA format ("America/Los_Angeles")
27-
// Moment needs IANA format
28-
const timeZoneId = iana.findOneIana(user.timeZone);
30+
const timeZoneId = iana.findIana(user.timeZone)[0];
2931
console.log(`Time zone: ${timeZoneId.valueOf()}`);
3032

3133
// Calculate the start and end of the current week
3234
// Get midnight on the start of the current week in the user's timezone,
3335
// but in UTC. For example, for Pacific Standard Time, the time value would be
3436
// 07:00:00Z
35-
var startOfWeek = moment.tz(timeZoneId.valueOf()).startOf('week').utc();
36-
var endOfWeek = moment(startOfWeek).add(7, 'day');
37-
console.log(`Start: ${startOfWeek.format()}`);
37+
var weekStart = zonedTimeToUtc(startOfWeek(new Date()), timeZoneId.valueOf());
38+
var weekEnd = addDays(weekStart, 7);
39+
console.log(`Start: ${formatISO(weekStart)}`);
3840

3941
// Get the access token
4042
var accessToken;
@@ -53,8 +55,8 @@ router.get('/',
5355
// Get the events
5456
const events = await graph.getCalendarView(
5557
accessToken,
56-
startOfWeek.format(),
57-
endOfWeek.format(),
58+
formatISO(weekStart),
59+
formatISO(weekEnd),
5860
user.timeZone);
5961

6062
params.events = events.value;

tutorial/01-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ You should also have either a personal Microsoft account with a mailbox on Outlo
2121
- You can [sign up for the Office 365 Developer Program](https://developer.microsoft.com/office/dev-program) to get a free Office 365 subscription.
2222

2323
> [!NOTE]
24-
> This tutorial was written with Node version 12.18.4. The steps in this guide may work with other versions, but that has not been tested.
24+
> This tutorial was written with Node version 14.15.0. The steps in this guide may work with other versions, but that has not been tested.
2525
2626
## Feedback
2727

0 commit comments

Comments
 (0)