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

Timezone Information is not working #543

Closed
1 task done
henningeiben opened this issue Sep 13, 2021 · 3 comments
Closed
1 task done

Timezone Information is not working #543

henningeiben opened this issue Sep 13, 2021 · 3 comments
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@henningeiben
Copy link

Category

  • Bug

Describe the bug

I'm trying to add a new listitem using the PnP-SDK which contains a DateTime-field. Since me SharePoint site is based on "German" I get:

[2021-09-13T08:56:48.777Z]  ---> System.ArgumentException: Unknown timezone mapping
[2021-09-13T08:56:48.777Z]    at PnP.Core.Model.SharePoint.TimeZone.GetTimeZoneInfoFromSharePoint(String timeZoneDescription)
[2021-09-13T08:56:48.778Z]    at PnP.Core.Model.SharePoint.TimeZone.UtcDelta(DateTime dateTime)
[2021-09-13T08:56:48.779Z]    at PnP.Core.Model.SharePoint.TimeZone.UtcToLocalTime(DateTime dateTime)
[2021-09-13T08:56:48.780Z]    at PnP.Core.Model.SharePoint.ListItem.DateTimeToSharePointWebDateTimeString(PnPContext context, DateTime input)
[2021-09-13T08:56:48.780Z]    at PnP.Core.Model.SharePoint.ListItem.BuildValidateUpdateItemPayload(PnPContext context, KeyValuePair`2 changedProp, Object field)
[2021-09-13T08:56:48.781Z]    at PnP.Core.Model.SharePoint.ListItem.<.ctor>b__2_2(Dictionary`2 keyValuePairs)
[2021-09-13T08:56:48.782Z]    at PnP.Core.Model.BaseDataModel`1.AddBatchAsync(Batch batch, Dictionary`2 keyValuePairs)
[2021-09-13T08:56:48.783Z]    at PnP.Core.Model.SharePoint.ListItemCollection.AddBatchAsync(Batch batch, Dictionary`2 values, String folderPath, FileSystemObjectType fileSystemObjectType)
[2021-09-13T08:56:48.784Z]    at MyFunction.Function1.Run(String myBlob, String name, FunctionContext context) in C:\projects\playground\MyFunction\Function1.cs:line 119
[2021-09-13T08:56:48.785Z]    at Microsoft.Azure.Functions.Worker.Invocation.VoidTaskMethodInvoker`2.InvokeAsync(TReflected instance, Object[] arguments) in D:\a\1\s\src\DotNetWorker.Core\Invocation\VoidTaskMethodInvoker.cs:line 22
[2021-09-13T08:56:48.785Z]    --- End of inner exception stack trace ---

I looked at the code and found, that GetTimeZoneInfoFromSharePoint is only looking for english timezones. But instead of "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna" SharePoint is returning "(UTC+01:00) Amsterdam, Berlin, Bern, Rom, Stockholm, Wien" instead.

Expected behavior

The timezone detection should work independed of language settings.

Environment details (development & target environment)

  • SDK version: 1.3.0
  • OS: Windows 10
  • SDK used in: Azure Function (c#)
  • Framework: dotnet 5.0
  • Tooling: Visual Studio 2019
@jansenbe jansenbe self-assigned this Sep 13, 2021
@jansenbe jansenbe added area: model 📐 Related to the core SDK models bug Something isn't working labels Sep 13, 2021
@jansenbe
Copy link
Contributor

@henningeiben : I've just pushed a generic fix for non English time zone descriptions. There might be edge cases where time zones have the same time offset but different daylight savings, but for the majority of cases the chosen defaults should be good. I'll investigate if I can come up with a better solution.

Can you tomorrow try with our nightly build (version 1.3.50) and check if things work for you?

@henningeiben
Copy link
Author

Sure - will do!

@henningeiben
Copy link
Author

@jansenbe: works like a charm - at least for a german-based site-collection! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants