Skip to content

[Repo Assist] Fix #1437: xs:dateTime values without timezone now parse correctly as DateTimeOffset#1617

Merged
dsyme merged 3 commits intomainfrom
repo-assist/fix-issue-1437-datetime-offset-unspecified-timezone-337ee53d40b4e899
Feb 22, 2026
Merged

[Repo Assist] Fix #1437: xs:dateTime values without timezone now parse correctly as DateTimeOffset#1617
dsyme merged 3 commits intomainfrom
repo-assist/fix-issue-1437-datetime-offset-unspecified-timezone-337ee53d40b4e899

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated draft PR from Repo Assist, an AI assistant.

Summary

Fixes #1437xs:dateTime XML values without an explicit timezone suffix (e.g. 2022-04-28T10:09:17, no Z or +HH:MM) now parse correctly when the declared type is DateTimeOffset.

Root Cause

TextConversions.AsDateTimeOffset returns None for any datetime where ParseISO8601FormattedDateTime produces DateTimeKind.Unspecified (i.e. no timezone in the string). This is intentional for inference — without a timezone, DateTime is a better inferred type than DateTimeOffset.

However, at runtime, when an XSD schema declares xs:dateTime, the generated code always calls TextRuntime.ConvertDateTimeOffset. If the XML value has no timezone, AsDateTimeOffset returns None, which bubbles up as a GetNonOptionalValue exception.

Fix

In TextRuntime.ConvertDateTimeOffset, fall back to TextConversions.AsDateTime when AsDateTimeOffset returns None. AsDateTime already converts DateTimeKind.Unspecified to DateTimeKind.Local, so DateTimeOffset(dt) then uses the local timezone offset — which is the standard interpretation of timezone-less xs:dateTime values.

This keeps AsDateTimeOffset strict (preserving inference behaviour) while making the runtime lenient when the declared type is DateTimeOffset.

Files Changed

  • src/FSharp.Data.Runtime.Utilities/TextRuntime.fsConvertDateTimeOffset falls back to AsDateTime
  • tests/FSharp.Data.Tests/XmlProvider.fs — regression test: parse xs:dateTime="2022-04-28T10:09:17" (no timezone)

Trade-offs

  • Timezone-less xs:dateTime values are treated as local time (not UTC). This matches the common interpretation and AsDateTime's existing behaviour.
  • No change to inference: CSV/JSON/XML files whose sample values lack timezones will still infer as DateTime, not DateTimeOffset.

Test Status

✅ All 249 tests pass (dotnet test tests/FSharp.Data.Tests/FSharp.Data.Tests.fsproj -c Release). New regression test xs:dateTime without timezone parses as DateTimeOffset (issue 1437) added and passing.

Generated by Repo Assist

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

…e-less xs:dateTime values

xs:dateTime values without a timezone suffix (e.g. '2022-04-28T10:09:17') are parsed by
ParseISO8601FormattedDateTime as DateTimeKind.Unspecified. AsDateTimeOffset rejects these
(returning None) to keep inference strict, causing a runtime exception when the XSD
declares the field as xs:dateTime.

Fix: In TextRuntime.ConvertDateTimeOffset, fall back to AsDateTime when AsDateTimeOffset
returns None. AsDateTime already converts Unspecified to Local, so DateTimeOffset(dt)
uses the local timezone offset — matching standard xs:dateTime semantics for timezone-free
values.

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

✅ Pull request created: #1617

@dsyme dsyme marked this pull request as ready for review February 22, 2026 18:48
@dsyme dsyme merged commit c0d22d1 into main Feb 22, 2026
1 of 2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-1437-datetime-offset-unspecified-timezone-337ee53d40b4e899 branch February 22, 2026 19:11
github-actions bot added a commit that referenced this pull request Feb 23, 2026
Add entries for:
- #1613: CSS pseudo-class NotSupportedException fix (#1383)
- #1617: ConvertDateTimeOffset xs:dateTime fallback fix (#1437)
- #1618: Microsoft.Build security bump
- #1619: XmlProvider EmbeddedResource GetSchema fix (#1310)
- #1621: StrictBooleans parameter for CsvProvider
- #1625: CsvProvider.InferRows multiline quoted field fix (#1439)
- #1626: XSD group reference cycle guard (#1419)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Reading a DateTime fails when the DateTime.Kind property gets set to Unspecified

1 participant