fix: map dublin timezone correctly #1665
Merged
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1664
When a SharePoint site has the
TimeZone
set to(UTC) Dublin, Edinburg, Lisbon, London
,PnP.Core
incorrectly maps this toUTC
. Thereby, it does not take into account daylight savings when creating posts to the API.This PR fixes that by changing
id: 2, (UTC) Dublin, Edinburg, Lisbon, London
to map toGMT Standard Time
Explanation
In
ListItem.cs
:https://github.com/pnp/pnpcore/blob/a0d5c94d4c4110663830e5cd6671c571ce4c6c08/src/sdk/PnP.Core/Model/SharePoint/Core/Internal/ListItem.cs#L706C1-L716C10
Assumptions: In the current code implementation, all dates are converted to the local datetimes of the SharePoint site. I haven't been able to test whether or not this is because that the SharePoint REST API does not support the ISO 8601 format, but I'd suggest moving to that format if possible.
The code converts the local DateTime to a UTC DateTime.
Before posting to SharePoint, however, the UTC DateTime must be converted to that specific site current DateTime, taking into account any daylight savings and other biases.
It uses the internal class,
TimeZone.cs
to do this. However, the fault lies inGetTimeZoneInfoFromSharePoint
.Here, it wrongly assumes that the timezone
id: 2, (UTC) Dublin, Edinburg, Lisbon, London
maps toUTC
in theTZConvert
library. However, this assumption is wrong. The timezone should beGMT Standard Time
as can be seen in theTZConvert
Unicode Common Locale Data Repository (Search for Dublin):https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml
If users wish this timezone, they should use the SharePoint Regional Setting:
id: 93, (UTC) Coordinated Universal Time
insteadUnit tests
Unit tests passes with the CI configuration.