Closed
Description
DESCRIPTION
A filter expression containing a DateTime with "Z" instead of "+00:00" gets parsed as local time instead of UTC.
STEPS TO REPRODUCE
Using a model with a datetime
property like this:
public partial class Item : IIdentifiable<Guid>
{
// ...
[Column(TypeName = "datetime")]
[Attr(PublicName = "changedAt")]
public DateTime? ChangedAt { get; set; }
}
Create test data:
item.ChangedAt = new DateTime(2024, 4, 8, 10, 0, 5, DateTimeKind.Local); // Local is CEST, which is +2h on April, 8th
- Send a request to
/items?filter=equals(changedAt,'2024-04-08T08:00:05Z')
- JADNC returns no results (wrong)
- Send a request to
/items?filter=equals(changedAt,'2024-04-08T08:00:05+00:00')
- JADNC returns 1 result (correct)
- Send a request to
/items?filter=equals(changedAt,'2024-04-08T10:00:05+02:00')
- JADNC returns 1 result (correct)
Using DateTimeOffset instead of DateTime or specifying DateTimeKind.Utc instead of Local changes the behavior, but the results are still inconsistent.
EXPECTED BEHAVIOR
The "Z" zone designator should be treated like a "+00:00" offset.
ACTUAL BEHAVIOR
The "Z" designator seems to be ignored and the datetime treated as local time.
VERSIONS USED
- JsonApiDotNetCore version: 5.5.1
- ASP.NET Core version: 7.0.15
- Entity Framework Core version: 7.0.15
- Database provider: SqlServer