Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimes are local and not UTC #1602

Open
1 task done
bhas opened this issue Jan 28, 2025 · 0 comments
Open
1 task done

DateTimes are local and not UTC #1602

bhas opened this issue Jan 28, 2025 · 0 comments

Comments

@bhas
Copy link

bhas commented Jan 28, 2025

Category

  • Bug

Describe the bug

DateTime values are returned in local DateKind instead of Utc, when reading SharePoint List items data, even when DatesInUtc = true.

Tip

I did some investigation and it looks like the issue happens with this line when trying to parse the DateTime object from the JSON. DateTime.TryParse converts the date into local time per default. It looks like you can use this code to have the parsed DateTime be in UTC instead:

DateTime.TryParse(dateString, null, System.Globalization.DateTimeStyles.AdjustToUniversal, out _);

Steps to reproduce

  1. Load any date column from a view with DatesInUtc = true such as:
var output = await list.LoadListDataAsStreamAsync(new RenderListDataOptions
{
    ViewXml = viewXmlQuery,
    RenderOptions = RenderListDataOptionsFlags.ListData,
    DatesInUtc = true,
});

var item = list.Items.AsRequested().First();
var date = item.Values["ConfirmedDate"]; // here date.Kind == Local
  1. Inspect that the returned DateTime object has Kind = Local

Expected behavior

When loading data with the argument is DatesInUtc = true I would expect to receive a UTC dates back and not Local dates.

Environment details (development & target environment)

  • SDK version: 1.9.0
  • OS: Windows 10
  • SDK used in: ASP.Net Web app
  • Framework: .NET Core v8.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant