Skip to content

Support culture-independent seconds matching in millisecond date formatting (Fixes #40356) - #56664

Open
Manish-1kumar wants to merge 2 commits into
dotnet:mainfrom
Manish-1kumar:users/manish/issue-40356-milliseconds-full-datetime-pattern
Open

Manish-1kumar wants to merge 2 commits into
dotnet:mainfrom
Manish-1kumar:users/manish/issue-40356-milliseconds-full-datetime-pattern

Conversation

@Manish-1kumar

@Manish-1kumar Manish-1kumar commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #40356

Summary of Changes

  • Replaces culture-inflexible colon-dependent regex (:ss|:s)\ in C# and Visual Basic snippets with a culture-independent regex matching unquoted seconds specifiers \s\ or \ss\ outside literal quotation marks.
  • Fixes formatting in cultures where \FullDateTimePattern\ does not use colons as time separators (such as \da-DK, \ i-FI, \ r-CA, \�s-IN, \id-ID, etc.).
  • Encloses the culture's decimal separator in single quotes ('{NumberDecimalSeparator}'fff) to prevent special format token misinterpretation when passed to \ToString().
  • Updates \docs/standard/base-types/how-to-display-milliseconds-in-date-and-time-values.md\ with updated explanation and verified build.

Internal previews

File Preview link
docs/standard/base-types/how-to-display-milliseconds-in-date-and-time-values.md Learn preview
docs/standard/base-types/snippets/how-to-display-milliseconds-in-date-and-time-values/csharp/Program.cs Learn preview
docs/standard/base-types/snippets/how-to-display-milliseconds-in-date-and-time-values/vb/Program.vb Learn preview

Build report

@dotnetrepoman dotnetrepoman Bot added this to the November 2026 milestone Nov 1, 2026
@dotnet-policy-service dotnet-policy-service Bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Nov 1, 2026
@BillWagner
BillWagner requested a balanced review from Copilot November 25, 2026 16:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The VB and C# regexes mishandle escaped characters and quoted literals, causing milliseconds to be omitted, duplicated, or inserted into literal text.

2 open issues
What changed in this PR

This PR addresses #40356 by updating the .NET documentation samples to insert milliseconds without requiring colon-based time separators.

Changes:

  • Replaces colon-dependent seconds matching in the C# and Visual Basic samples.
  • Quotes the culture-specific decimal separator in the date/time format.
  • Updates the article’s explanation and date metadata.
File Description
docs/​standard/​base-types/​snippets/​how-to-display-milliseconds-in-date-and-time-values/​vb/​Program.vb Updates seconds matching and decimal-separator quoting in Visual Basic.
docs/​standard/​base-types/​snippets/​how-to-display-milliseconds-in-date-and-time-values/​csharp/​Program.cs Updates seconds matching and decimal-separator quoting in C#.
docs/​standard/​base-types/​how-to-display-milliseconds-in-date-and-time-values.md Explains culture-independent seconds matching and refreshes the article date.

Review effort: Balanced

@Manish-1kumar
Manish-1kumar force-pushed the users/manish/issue-40356-milliseconds-full-datetime-pattern branch from 3a84f62 to b488075 Compare November 30, 2026 17:40
@BillWagner

Copy link
Copy Markdown
Member

@tarekgh PTAL. Would you prefer a RegEx based example that handles all cultures?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"(:ss|:s)" regex in the milliseconds example does not match FullDateTimePattern in all cultures

3 participants