Assume that the Unspecified datetime is user's local time zone.#24049
Merged
maliming merged 6 commits intoabpframework:devfrom Jan 3, 2026
Merged
Assume that the Unspecified datetime is user's local time zone.#24049maliming merged 6 commits intoabpframework:devfrom
Unspecified datetime is user's local time zone.#24049maliming merged 6 commits intoabpframework:devfrom
Conversation
AbpDateTimeModelBinder to align with the current TZUnspecified datetime is user's local time zone.
maliming
approved these changes
Jan 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements timezone-aware datetime handling for unspecified DateTime values by treating them as being in the user's local timezone and converting them to UTC. This closes issue #24048.
Key Changes
- Created a new base class
AbpDateTimeConverterBase<T>to consolidate common datetime conversion logic for System.Text.Json converters - Updated datetime converters (both System.Text.Json and Newtonsoft.Json) to detect unspecified DateTimeKind values and convert them from the user's timezone to UTC
- Enhanced
AbpDateTimeModelBinderto apply the same timezone conversion logic for model binding scenarios - Added comprehensive test coverage for the new timezone-aware datetime handling
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
ModelBindingController_Tests.cs |
Added three new test methods to verify timezone-aware datetime handling for simple, nullable, and complex type scenarios |
ModelBindingController.cs |
Added four new controller action methods that return both the DateTimeKind and the formatted datetime value for testing purposes |
AbpNullableDateTimeConverter.cs |
Refactored to inherit from the new AbpDateTimeConverterBase<DateTime?> class |
AbpDateTimeConverterBase.cs |
New abstract base class that consolidates datetime reading, writing, and timezone-aware normalization logic |
AbpDateTimeConverter.cs |
Refactored to inherit from the new AbpDateTimeConverterBase<DateTime> class |
AbpDateTimeConverter.cs (Newtonsoft) |
Added timezone conversion logic in the Normalize method to handle unspecified datetime values |
AbpDateTimeModelBinderProvider.cs |
Updated to inject ICurrentTimezoneProvider and ITimezoneProvider dependencies |
AbpDateTimeModelBinder.cs |
Added timezone conversion logic for unspecified datetime values before normalization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...bp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ModelBinding/ModelBindingController_Tests.cs
Outdated
Show resolved
Hide resolved
...bp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ModelBinding/ModelBindingController_Tests.cs
Outdated
Show resolved
Hide resolved
...bp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ModelBinding/ModelBindingController_Tests.cs
Outdated
Show resolved
Hide resolved
...bp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ModelBinding/ModelBindingController_Tests.cs
Outdated
Show resolved
Hide resolved
....Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpDateTimeConverterBase.cs
Outdated
Show resolved
Hide resolved
...k/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinder.cs
Show resolved
Hide resolved
...Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ModelBinding/ModelBindingController.cs
Outdated
Show resolved
Hide resolved
....Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpDateTimeConverterBase.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpDateTimeConverter.cs
Outdated
Show resolved
Hide resolved
...bp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ModelBinding/ModelBindingController_Tests.cs
Outdated
Show resolved
Hide resolved
…adjustments in model binding and JSON converters
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...bp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ModelBinding/ModelBindingController_Tests.cs
Show resolved
Hide resolved
....Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpDateTimeConverterBase.cs
Show resolved
Hide resolved
framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpDateTimeConverter.cs
Show resolved
Hide resolved
...k/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinder.cs
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #24048