DateTimePicker lose leading 0 in milliseconds when lose focus.

Open
#1,796 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp
Domain
desktop

Research direction

Start in ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimeUpDown/Implementation/DateTimeParser.cs, at ComputeDateTimeString and its millisecondsPart calculation. Reproduce the focus-loss case with 28.04.2025 16:26:16.080 and inspect the resulting value. Done means the leading zero is preserved after the DateTimePicker loses focus.

Written by the indexing model from the issue text.

Description

Error location

https://github.com/xceedsoftware/wpftoolkit/blob/master/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimeUpDown/Implementation/DateTimeParser.cs

DateTimeParser.cs

private static string ComputeDateTimeString( string dateTime, string format, DateTime currentDate, CultureInfo cultureInfo, bool autoClipTimeParts )

//Has error here.
string millisecondsPart = currentDate.Millisecond.ToString();

Case

If picker has dateTime value like this '28.04.2025 16:26:16.080'

millisecondsPart = "80";

We have lost leading 0.

in the end we have a result like this '28.04.2025 16:26:16.80'

'28.04.2025 16:26:16.80' == '28.04.2025 16:26:16.800'
'28.04.2025 16:26:16.80' != '28.04.2025 16:26:16.080'

Summary

Control lost focus and value changed.

Dominant language
C#
Stars
4.2k
Forks
912
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xceedsoftware/wpftoolkit

All issues in xceedsoftware/wpftoolkit

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.