Skip to content

DateTimeTimeZoneExtensions should respect the TimeZone Kind #983

@Mrnikbobjeff

Description

@Mrnikbobjeff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions