[Mono-dev] : DateTime.Parse patch

Eyal Alaluf eyala at mainsoft.com
Wed Aug 15 10:03:08 EDT 2007

Hi, all.

Attached is a patch for the infamous DateTime.Parse method.
The current logic for Parse is to try all the culture date time formats
and then try some special formats in invariant culture.
This solution is not sufficient because it is not very compatible with
MS behavior, it is difficult to maintain and is very inefficient.

The current patch aims to improve all of these issues. The patch defines
two sets of formats 'date' only formats and 'time' only formats.
The Parse method will check all the date formats for a match. If the
date format matches the string beginning it will combine it with all the
time formats. It will check similarly all the time formats and match to
them the date formats.
Only if this fails it will look at all the culture date formats (making
the TrypParse negative flow still very slow). This is done because
additional effort is required to define the culture specific separators.
The result is that many more formats are recognizable by DateTime.Parse
and that it is easier to add formats if necessary.

In different flows the patch improves performance by a factor of 3-5
times on Mono.

Please review and provide feedback since this is a fairly major change
to a really sensitive spot.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DateTime.patch
Type: application/octet-stream
Size: 37105 bytes
Desc: DateTime.patch
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070815/74e07e70/attachment.obj 

More information about the Mono-devel-list mailing list