Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Closed Issue: DateTimeParser.GetDateParts [20389]

$
0
0
DateTimeParser.cs

Method: GetDateParts

This method can result in a DateTime being incorrectly parsed from the display text when the text box is selected in certain circumstances.

This method splits the supplied string in to date parts using the CultureInfo.DateTimeFormat.DateSeparator for the current culture. However, there is no guarantee that this separator is the one being used in the supplied string.

This can arise in several scenarios for example when the ShortDatePattern for the current culture is overridden at application level.

This method should use an array of all possible separators in the same way DateTimeParser.ComputeDateTimeString does.

A possible work around is:

```
var dateTimeSeparators = new[] { ",", " ", "-", ".", "/", cultureInfo.DateTimeFormat.DateSeparator, cultureInfo.DateTimeFormat.TimeSeparator };
var dateFormatParts = cultureInfo.DateTimeFormat.ShortDatePattern.Split(dateTimeSeparators, StringSplitOptions.RemoveEmptyEntries).ToList();
```
Comments: Fixed in v2.1.

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>