Skip to content

fix: map dublin timezone correctly #1665

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

Merged
merged 1 commit into from
Jun 24, 2025
Merged

fix: map dublin timezone correctly #1665

merged 1 commit into from
Jun 24, 2025

Conversation

tikki100
Copy link
Contributor

@tikki100 tikki100 commented Jun 22, 2025

Fixes #1664

When a SharePoint site has the TimeZone set to (UTC) Dublin, Edinburg, Lisbon, London, PnP.Core incorrectly maps this to UTC. 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 to GMT 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 in GetTimeZoneInfoFromSharePoint.

Here, it wrongly assumes that the timezone id: 2, (UTC) Dublin, Edinburg, Lisbon, London maps to UTC in the TZConvert library. However, this assumption is wrong. The timezone should be GMT Standard Time as can be seen in the TZConvert 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 instead

Unit tests

Unit tests passes with the CI configuration.

@jansenbe jansenbe self-assigned this Jun 24, 2025
jansenbe pushed a commit that referenced this pull request Jun 24, 2025
@jansenbe jansenbe merged commit 1000e89 into pnp:dev Jun 24, 2025
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

Successfully merging this pull request may close these issues.

PnP.Core does not support Dublin UTC Daylight savings
2 participants