-
-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description:
WinRT originate error - 0x80070057 : 'The UTC Offset for Utc DateTime instances must be 0. (Parameter 'offset')'.
The issues is originated from here:
internal static class DateTimeExtensions
{
/// <summary>
/// Converts a DateTime to a DateTimeOffset using the local time zone.
/// </summary>
/// <param name="dateTime">The DateTime to convert.</param>
/// <returns>A DateTimeOffset representing the same point in time as the DateTime.</returns>
public static DateTimeOffset ToDateTimeOffset(this DateTime dateTime)
{
return new DateTimeOffset(dateTime, TimeZoneInfo.Local.GetUtcOffset(dateTime));
}
I think the issue is TImeZoneInfo.Local and not TimeZoneInfo.Utc:
I think it could be reproduced with this test:
[TestMethod]
public void ToDateTimeOffset_FromDateTime_UTC_UsesLocalOffset()
{
var dt = new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc);
var dto = dt.ToDateTimeOffset();
var expected = new DateTimeOffset(dt, TimeZoneInfo.Utc.GetUtcOffset(dt));
Assert.AreEqual(expected, dto);
}
But I did not manage to get tests running locally.
Environment:
- Package Version: 1.4.0
- WinAppSDK Version: 1.8.251106002
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working