Skip to content

Comments

[Repo Assist] Add DateOnly/TimeOnly inference support (closes #1461)#1609

Merged
dsyme merged 12 commits intomainfrom
repo-assist/feature-dateonly-timeonly-1461-03f39b53850547db
Feb 22, 2026
Merged

[Repo Assist] Add DateOnly/TimeOnly inference support (closes #1461)#1609
dsyme merged 12 commits intomainfrom
repo-assist/feature-dateonly-timeonly-1461-03f39b53850547db

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant for this repository.

Closes #1461

Summary

Adds DateOnly and TimeOnly support to FSharp.Data's type inference pipeline, as requested by @dsyme in issue #1461.

Changes

Multi-targeting

All library projects now target netstandard2.0;net8.0 (previously netstandard2.0 only). This is required for #if NET6_0_OR_GREATER guards to activate in library code.

Automatic DateOnly inference

  • Date-only strings like "2022-06-11" are now inferred as DateOnly on .NET 6+ targets.
  • DateOnly is a subtype of DateTime in the type hierarchy — columns mixing DateOnly and DateTime values unify to DateTime (no breaking change for mixed columns).
  • AsDateOnly guards against the DateOnly.TryParse gotcha: DateOnly.TryParse("2022-06-12T01:02:03") returns true (ignores the time component). The fix checks for non-zero TimeOfDay after a successful parse and returns None in that case.

TimeOnly — explicit annotation only

TimeOnly is not automatically inferred from string values. The string "00:30:00" is valid both as TimeOnly and TimeSpan, making automatic inference ambiguous and a breaking change for existing code.

  • TimeOnly is available via explicit column annotation (timeonly? or timeonly option in CSV column headers / XML/JSON schema).
  • All TimeOnly runtime methods (AsTimeOnly, ConvertTimeOnly, etc.) are present.
  • AsTimeOnly guards against the same gotcha as AsDateOnly: TimeOnly.TryParse("2016-10-05T04:05:03") returns true.

Files changed

File Change
**/FSharp.Data*.fsproj (5 files) netstandard2.0netstandard2.0;net8.0
TextConversions.fs AsDateOnly, AsTimeOnly with datetime-string guards
TextRuntime.fs ConvertDateOnly, ConvertTimeOnly, back-conversion methods
StructuralTypes.fs DateOnly, TimeOnly cases in InferedTypeTag DU
StructuralInference.fs DateOnly in primitiveTypes, typeTag, conversionTable, nameToType, matchValue; TimeOnly in nameToType only
ConversionsGenerator.fs DateOnly/TimeOnly quotation branches
JsonConversionsGenerator.fs DateOnly/TimeOnly quotation branches
JsonConversions.fs AsDateOnly, AsTimeOnly
JsonRuntime.fs ConvertDateOnly, ConvertTimeOnly, match cases
CsvInference.fs dateonly?, timeonly?, dateonly option, timeonly option schema names
Test files Updated DateTimeDateOnly for date-only values

Design decisions

  1. No TimeOnly auto-inference — avoids breaking all existing TimeSpan-inferred code. Explicit annotation is unambiguous and sufficient for the use cases described in Support DateOnly and TimeOnly types #1461.
  2. DateOnly before DateTime in matchValueAsDateOnly is tried before AsDateTime so pure date strings resolve to DateOnly. AsDateTimeOffset is tried first (unchanged).
  3. Subtype relationship preservedDateOnly ⊆ DateTime, TimeOnly ⊆ TimeSpan. Mixed columns behave the same as before.

Test Status

  • Build: dotnet build FSharp.Data.sln -c Release -maxcpucount:1 — succeeded
  • FSharp.Data.Core.Tests: 2843 passed, 1 skipped — pre-existing network failure (HTTP 403 from google.com in sandbox)
  • FSharp.Data.Tests: 248 passed, 0 failed

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@077cdbca7864e820e3425e9598cf1269d3dce05a. View source at https://github.com/githubnext/agentics/tree/077cdbca7864e820e3425e9598cf1269d3dce05a/workflows/repo-assist.md.

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • www.google.com

- Multi-target library projects to netstandard2.0;net8.0 to enable
  NET6_0_OR_GREATER conditional compilation
- Add AsDateOnly/AsTimeOnly to TextConversions with guards against
  datetime strings being accepted by DateOnly/TimeOnly parsers
- Add DateOnly to automatic type inference (matchValue); TimeOnly is
  NOT auto-inferred (ambiguous with TimeSpan) but available via explicit
  schema annotation (dateonly?/timeonly? in CSV headers)
- Add DateOnly as subtype of DateTime in conversionTable; columns with
  mixed DateOnly+DateTime values unify to DateTime
- Add ConvertDateOnly/ConvertTimeOnly to TextRuntime and JsonRuntime
- Add DateOnly/TimeOnly cases to StructuralTypes, ConversionsGenerator,
  JsonConversionsGenerator, JsonConversions, JsonRuntime, CsvInference
- Update tests for new DateOnly inference behaviour

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Feb 22, 2026

@dsyme I've opened a new pull request, #1610, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 22, 2026 11:48
Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Docs: Update CsvProvider and JsonProvider for DateOnly/TimeOnly inference
@dsyme
Copy link
Contributor

dsyme commented Feb 22, 2026

@copilot There is a problem in the design time tests:

Error: System.Exception : The design-time type 'System.DateOnly' utilized by a type provider was not found in the target reference assembly set '[tgt assembly FSharp.Data, Version=6.7.0.0, Culture=neutral, PublicKeyToken=49286adf818aa259;

See failing CI run

Copy link
Contributor

Copilot AI commented Feb 22, 2026

@dsyme I've opened a new pull request, #1611, to work on those changes. Once the pull request is ready, I'll request review from you.

@dsyme dsyme merged commit 243e97b into main Feb 22, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/feature-dateonly-timeonly-1461-03f39b53850547db branch February 22, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants