You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version 19, .net Core 7
Date times such as: DateTimeOffset.Parse("2022-09-25T17:59:59-07:00")
Get saved to diff file as: 2022-09-25 18:00 --7
A clear and concise description of what you expected to happen:
Ideally the result would be: 2022-09-25 18:00 -7
Add any other context about the problem here.
Issue is in: src/Verify/Serialization/DateFormatter.cs
GetDateOffset adds a dash "-" to the front of the negative number 7.
For some reason offsetMinutes will also be negative for the offset minute case:
DateTimeOffset.Parse("2022-09-25T17:59:59-07:30") => --7--30
static string GetDateOffset(DateTimeOffset value)
{
var offset = value.Offset;
if (offset > TimeSpan.Zero)
{
if (offset.Minutes == 0)
{
return $"+{offset.TotalHours:0}";
}
return $"+{offset.Hours:0}-{offset.Minutes:00}";
}
if (offset < TimeSpan.Zero)
{
if (offset.Minutes == 0)
{
return $"-{offset.Hours:0}";
}
return $"-{offset.Hours:0}-{offset.Minutes):00}";
}
return "+0";
}
Minimal Repro
[Fact]
public async Task DateTest() {
var dto = DateTimeOffset.Parse("2022-09-25T17:59:59-07:30");
await Verify(dto)
.DontScrubDateTimes();
}
Submit a PR that fixes the bug
static string GetDateOffset(DateTimeOffset value)
{
var offset = value.Offset;
if (offset > TimeSpan.Zero)
{
if (offset.Minutes == 0)
{
return $"+{offset.TotalHours:0}";
}
return $"+{offset.Hours:0}-{offset.Minutes:00}";
}
if (offset < TimeSpan.Zero)
{
if (offset.Minutes == 0)
{
// remove dash
return $"{offset.Hours:0}";
}
var minutes = Math.Abs(offset.Minutes);
// remove dash, make sure positive
return $"{offset.Hours:0}-{minutes:00}";
}
return "+0";
}
The text was updated successfully, but these errors were encountered:
Describe the bug
Version 19, .net Core 7
Date times such as: DateTimeOffset.Parse("2022-09-25T17:59:59-07:00")
Get saved to diff file as: 2022-09-25 18:00 --7
A clear and concise description of what you expected to happen:
Ideally the result would be: 2022-09-25 18:00 -7
Add any other context about the problem here.
Issue is in: src/Verify/Serialization/DateFormatter.cs
GetDateOffset adds a dash "-" to the front of the negative number 7.
For some reason offsetMinutes will also be negative for the offset minute case:
DateTimeOffset.Parse("2022-09-25T17:59:59-07:30") => --7--30
Minimal Repro
Submit a PR that fixes the bug
The text was updated successfully, but these errors were encountered: