Skip to content

Comments

Document tt and HH/H incompatibility in parsing format strings#51828

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-parseexact-hh-requirement
Open

Document tt and HH/H incompatibility in parsing format strings#51828
Copilot wants to merge 3 commits intomainfrom
copilot/fix-parseexact-hh-requirement

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

  • Add a note to the "tt" custom format specifier section explaining that when parsing, you must use "hh"/"h" (12-hour clock) instead of "HH"/"H" (24-hour clock), because they're incompatible and will throw a FormatException
  • Add a note to the "HH" custom format specifier section mentioning that it's incompatible with the "tt" AM/PM designator in parsing operations (throws FormatException)
  • Use "throws" instead of "causes" for FormatException in both notes
  • Add ai-usage: ai-assisted to frontmatter
Original prompt

This section details on the original issue you should resolve

<issue_title>When parsing with "tt", it requires using "hh"</issue_title>
<issue_description>According to stackoverflow (and this matches my tests locally), you can't call DateTime.ParseExact with both HH and tt. Instead you must use hh.

https://stackoverflow.com/questions/2596969/why-can-t-datetime-parseexact-parse-the-am-pm-in-4-4-2010-42000-pm-using

This would be good to mention in the docs.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Internal previews

📄 File 🔗 Preview link
docs/standard/base-types/custom-date-and-time-format-strings.md docs/standard/base-types/custom-date-and-time-format-strings

Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix DateTime.ParseExact usage with HH and tt in documentation Document tt and HH/H incompatibility in parsing format strings Feb 19, 2026
Copilot AI requested a review from meaghanlewis February 19, 2026 22:41
@meaghanlewis meaghanlewis marked this pull request as ready for review February 19, 2026 23:22
@meaghanlewis meaghanlewis requested review from a team and adegeo as code owners February 19, 2026 23:22
Copilot AI review requested due to automatic review settings February 19, 2026 23:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds documentation clarifying that 24-hour hour specifiers (H/HH) are incompatible with AM/PM designators (t/tt) when parsing with exact-format APIs (for example, DateTime.ParseExact), and that mixing them results in FormatException.

Changes:

  • Adds a [!NOTE] under the "HH" specifier warning against combining H/HH with t/tt in parsing format strings.
  • Adds a symmetric [!NOTE] under the "tt" specifier recommending h/hh for parsing when an AM/PM designator is present.

…matter

Co-authored-by: meaghanlewis <10103121+meaghanlewis@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.

When parsing with "tt", it requires using "hh"

2 participants