Skip to content

Add DateOnly and TimeOnly support#2

Merged
ScarletKuro merged 4 commits intomasterfrom
copilot/add-dateonly-timeonly-support
Jan 15, 2026
Merged

Add DateOnly and TimeOnly support#2
ScarletKuro merged 4 commits intomasterfrom
copilot/add-dateonly-timeonly-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 15, 2026

Extends the library to support DateOnly, DateOnly?, TimeOnly, and TimeOnly? types with custom format serialization.

Changes

  • Converters: Added 4 converters following existing DateTime/DateTimeOffset patterns

    • DateOnlyConverter, DateOnlyNullableConverter
    • TimeOnlyConverter, TimeOnlyNullableConverter
    • Non-nullable types throw JsonException on invalid input; nullable types return null
  • Factory registration: Updated DateTimeConverterFactoryHelper and JsonDateTimeFormatConverter.CanConvert() to recognize new types

  • Tests: Added 18 tests covering all serialization approaches (reflection, source generator, resolver) with distinctive formats to verify custom converters work correctly

  • Documentation: Updated README.md and AGENT.md with new type support and examples

Usage

All existing usage patterns now support DateOnly/TimeOnly:

// Reflection-based
public class Order
{
    [JsonDateTimeConverter("MM/dd/yyyy")]
    public DateOnly DeliveryDate { get; set; }
    
    [JsonDateTimeConverter("HH:mm")]
    public TimeOnly DeliveryTime { get; set; }
}

// Source generator with format converter
public class DateOnlyFormat : IJsonDateTimeFormat
{
    public static string Format => "MM/dd/yyyy";
}

[JsonConverter(typeof(JsonDateTimeFormatConverter<DateOnlyFormat>))]
public DateOnly DeliveryDate { get; set; }

// Source generator with resolver (.NET 9+)
[JsonDateTimeFormat("MM/dd/yyyy")]
public DateOnly DeliveryDate { get; set; }
Original prompt

Add support for
DateOnly
DateOnly?
TimeOnly
TimeOnly?

Update/Add tests, Readme.MD, and Agent.MD to reflect the changes


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 15, 2026 20:24
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
@ScarletKuro ScarletKuro marked this pull request as ready for review January 15, 2026 20:29
@ScarletKuro ScarletKuro changed the title [WIP] Add support for DateOnly and TimeOnly types Add support for DateOnly and TimeOnly types Jan 15, 2026
Copilot AI changed the title Add support for DateOnly and TimeOnly types Add DateOnly and TimeOnly support Jan 15, 2026
Copilot AI requested a review from ScarletKuro January 15, 2026 20:30
@ScarletKuro ScarletKuro merged commit debcbfb into master Jan 15, 2026
1 check passed
@ScarletKuro ScarletKuro deleted the copilot/add-dateonly-timeonly-support branch January 15, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants