Reputation: 3204
I have a C# UWP app that uses OneDrive REST APIs.
The app queries for the application folder and retrieves all the files from this special folder (app folder).
string appFolderParameters = string.Concat(OneDriveApi, OneDriveAppsFolderPath, "/children", "?access_token=", App.Settings.Values["access_token"]);
var appFolderMeetings = await client.GetStringAsync(appFolderParameters);
foreach (var file in files)
{
string fileName = file["name"]?.ToString();
string lastModifiedString = file["lastModifiedDateTime"]?.ToString();
}
While the query works fine, the value, especially the lastModifiedString is always 1 hour behind.
My PC TimeZone is set to "Automatic" and the Microsoft Account TimeZone is set to CET (same as my PC's). Any idea why the API returns a wrong lastModifiedString?
Here are a couple of screenshots to show this issue.
Last Updated Time in the browser:
Last Updated Time in the API result/Visual Studio:
Upvotes: 0
Views: 410
Reputation: 10201
It looks like the lastModifiedDateTime simply is in UTC. In the winter, there is a one hour difference between CET and UTC.
To convert between local time and UTC, use the DateTime
type, or even better, the DateTimeOffset
type.
Upvotes: 1