Conversation
…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>
Contributor
Author
|
✅ Pull request created: #1617 |
4 tasks
…nspecified-timezone-337ee53d40b4e899
…nspecified-timezone-337ee53d40b4e899
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>
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.
🤖 This is an automated draft PR from Repo Assist, an AI assistant.
Summary
Fixes #1437 —
xs:dateTimeXML values without an explicit timezone suffix (e.g.2022-04-28T10:09:17, noZor+HH:MM) now parse correctly when the declared type isDateTimeOffset.Root Cause
TextConversions.AsDateTimeOffsetreturnsNonefor any datetime whereParseISO8601FormattedDateTimeproducesDateTimeKind.Unspecified(i.e. no timezone in the string). This is intentional for inference — without a timezone,DateTimeis a better inferred type thanDateTimeOffset.However, at runtime, when an XSD schema declares
xs:dateTime, the generated code always callsTextRuntime.ConvertDateTimeOffset. If the XML value has no timezone,AsDateTimeOffsetreturnsNone, which bubbles up as aGetNonOptionalValueexception.Fix
In
TextRuntime.ConvertDateTimeOffset, fall back toTextConversions.AsDateTimewhenAsDateTimeOffsetreturnsNone.AsDateTimealready convertsDateTimeKind.UnspecifiedtoDateTimeKind.Local, soDateTimeOffset(dt)then uses the local timezone offset — which is the standard interpretation of timezone-lessxs:dateTimevalues.This keeps
AsDateTimeOffsetstrict (preserving inference behaviour) while making the runtime lenient when the declared type isDateTimeOffset.Files Changed
src/FSharp.Data.Runtime.Utilities/TextRuntime.fs—ConvertDateTimeOffsetfalls back toAsDateTimetests/FSharp.Data.Tests/XmlProvider.fs— regression test: parsexs:dateTime="2022-04-28T10:09:17"(no timezone)Trade-offs
xs:dateTimevalues are treated as local time (not UTC). This matches the common interpretation andAsDateTime's existing behaviour.DateTime, notDateTimeOffset.Test Status
✅ All 249 tests pass (
dotnet test tests/FSharp.Data.Tests/FSharp.Data.Tests.fsproj -c Release). New regression testxs:dateTime without timezone parses as DateTimeOffset (issue 1437)added and passing.