microsoftgraph / microsoftgraph/msgraph-sdk-dotnet-core
DateTimeTimeZoneExtensions should respect the TimeZone Kind
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 164
- Forks
- 65
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
Describe the bug
In DateTimeZoneExtensions.cs, the Method ToDateTimeOffset does not respect the Timezone identifier. The method needs to add DateTimeStyles.RoundTrip to the DateTime.ParseExact invocation.
A reproducable example is published here. To reproduce this the user has to be outside of the UTC Timezone.
Expected behavior
The DateTime Timezone should be respected (Z specifier for ZULU time at the end of the datetime string)
How to reproduce
Create a utc time, use it to create a DateTimeTimeZone, convert it to a DateTimeOffset when your local system is not UTC time
SDK Version
5.67.0
Latest version known to work for scenario above?
No response
Known Workarounds
See the provided example, it already contains the fix
Debug output
Configuration
- OS: Windosw
- Architecture: x64
Other information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open DateTimeZoneExtensions.cs and inspect ToDateTimeOffset, then reproduce the conversion described in the issue on a non-UTC system. Verify that DateTime.ParseExact uses the stated DateTimeStyles.RoundTrip behavior and that UTC input retains its Z time-zone semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100