Clarify XmlConvert.ToDateTimeOffset format handling - #12987
Open
steveisok wants to merge 2 commits into
Open
Conversation
Document the exact ParseExact behavior for the custom-format ToDateTimeOffset overloads and clarify UTC designator handling.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the ECMAXML documentation for System.Xml.XmlConvert.ToDateTimeOffset to more precisely describe how the custom-format overloads interpret format/formats, including exact-match parsing behavior, invariant formatting, and timezone designator handling.
Changes:
- Reframed
format/formatsas .NET standard/custom date and time format strings (not XML Schema dateTime patterns). - Documented that the overloads behave like
DateTimeOffset.ParseExactusing invariant formatting and allowing leading/trailing whitespace. - Clarified that
z/zz/zzzrequire signed numeric offsets and thatKsupports the XMLZUTC designator.
Show a summary per file
| File | Description |
|---|---|
| xml/System.Xml/XmlConvert.xml | Clarifies ToDateTimeOffset overload docs for ParseExact equivalence, accepted format strings, UTC offset specifiers, and FormatException conditions. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (3)
xml/System.Xml/XmlConvert.xml:1168
- Use “whitespace” consistently (one word) in exception text, to match other parts of this file.
<paramref name="format" /> is invalid, or <paramref name="s" /> doesn't exactly match <paramref name="format" /> under the invariant culture rules, except for leading or trailing white space.</exception>
xml/System.Xml/XmlConvert.xml:1220
- Use “whitespace” consistently (one word) to match other wording in this file.
This overload is equivalent to calling <xref:System.DateTimeOffset.ParseExact(System.String,System.String%5B%5D,System.IFormatProvider,System.Globalization.DateTimeStyles)?displayProperty=nameWithType> with <xref:System.Globalization.DateTimeFormatInfo.InvariantInfo?displayProperty=nameWithType> and the <xref:System.Globalization.DateTimeStyles.AllowLeadingWhite> and <xref:System.Globalization.DateTimeStyles.AllowTrailingWhite> flags. Leading and trailing white space is ignored, but `s` must otherwise exactly match one of the strings in `formats`. The `formats` parameter uses .NET [standard date and time format strings](/dotnet/standard/base-types/standard-date-and-time-format-strings) or [custom date and time format strings](/dotnet/standard/base-types/custom-date-and-time-format-strings), not XML Schema dateTime patterns.
xml/System.Xml/XmlConvert.xml:1252
- Use “whitespace” consistently (one word) in exception text, to match other parts of this file.
<exception cref="T:System.FormatException">An element of <paramref name="formats" /> is invalid, or <paramref name="s" /> doesn't exactly match any element of <paramref name="formats" /> under the invariant culture rules, except for leading or trailing white space.</exception>
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
gewarren
approved these changes
Aug 14, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
jeffhandley
approved these changes
Aug 16, 2026
jeffhandley
enabled auto-merge (squash)
August 16, 2026 00:13
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.
Summary
XmlConvert.ToDateTimeOffsetoverloads callDateTimeOffset.ParseExactwith invariant formatting and leading/trailing whitespace enabledformatandformatsas .NET standard or custom date and time format strings rather than XML Schema patternsz,zz, andzzzrequire signed numeric UTC offsets, whileKsupports the XML UTC designatorZFormatExceptiondocumentation with exact format matchingValidation
xmllint --noout xml/System.Xml/XmlConvert.xmlgit diff --checkFixes dotnet/runtime#125579
Internal previews