Skip to content

Commit 60e6700

Browse files
authored
Merge pull request #17 from antarr/performance/optimize-date-parsing-example-3697228967244090157
⚡ Optimize constant DateTime parsing in Withings.Example
2 parents ddf2ad2 + a4b3f10 commit 60e6700

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Withings.Example/Program.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
var authenticator = new Authenticator(credentials);
2222
var session = new Dictionary<string, string>();
2323

24+
var activityStartDate = new DateTime(2017, 1, 1);
25+
var activityEndDate = new DateTime(2017, 3, 30);
26+
var bodyStartDate = new DateTime(2017, 5, 8);
27+
var bodyEndDate = new DateTime(2017, 5, 10);
28+
2429
app.MapGet("/", () => Results.Redirect("/api/oauth/authorize", permanent: true));
2530

2631
app.MapGet("/api/oauth/authorize", () =>
@@ -125,8 +130,8 @@
125130
var client = new WithingsClient(credentials);
126131
var activity = await client.GetBodyMeasures(
127132
session["UserId"],
128-
DateTime.Parse("2017-05-08"),
129-
DateTime.Parse("2017-05-10"),
133+
bodyStartDate,
134+
bodyEndDate,
130135
session["AccessToken"]);
131136
return Results.Json(activity);
132137
});
@@ -136,7 +141,7 @@
136141
var client = new WithingsClient(credentials);
137142
var activity = await client.GetBodyMeasures(
138143
session["UserId"],
139-
DateTime.Parse("2017-05-08"),
144+
bodyStartDate,
140145
session["AccessToken"]);
141146
return Results.Json(activity);
142147
});

0 commit comments

Comments
 (0)