[Mono-dev] DateTime.Parse difference with .NET

Martin Hinks mhinks at gmail.com
Tue Aug 9 04:55:47 EDT 2005


Here's the bug with culture info included:

namespace DateFail
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			 
			IFormatProvider culture = new CultureInfo("en-GB", true);
        
			DateTime.Parse("17/07/2005 00:00:00", culture,
DateTimeStyles.NoCurrentDateDefault);
			
		}
	}
}

Please note that 17/07/2005 is a valid GB (Great Britain = UK) date
denoting the 17th of July 2005 (dd/mm/yyyy).

Martin Hinks
http://www.m-s-d.net

On 8/9/05, Alfredo Jose Muela Romero <aioros at ono.com> wrote:
> 
>        Hello,
> 
> El Tue, 09 Aug 2005 13:30:19 +0900
> Atsushi Eno <atsushi at ximian.com> escribió:
> 
> > Hello,
> 
>        [...]
> 
> > In fact using DateTime.Parse() is somewhat stupid ;-) Read
> > here:
> >
> > http://msdn.microsoft.com/msdnmag/issues/05/03/CultureInfo/default
> > .aspx?side=true#a
> >
> >       The DateTime.Parse method in the Microsoft .NET Framework
> >       has goals much like its predecessors, but unfortunately
> >       it suffers from some of the same problems. The code is
> >       slower since the extra checking takes time, and there
> >       will always be some new format that is not properly
> >       detected. In those older products, you may remember, the
> >       behavior was sometimes disparagingly referred to as "evil
> >       date parsing."
> >
> > At least DateTime.Parse() is COM dependent where the behavior
> > is totally unpredictable and not countable from
> > DateTimeFormatInfo.
> 
> 
>        But in [1] we find that format string we need to specify as a
> valid format (see Globalization.DateTimeFormatInfo) it is
> unfinished :-S
> 
>        May be I lost something... what do you suggest to use instead of
> DateTime.Parse() or DateTime.ParseExact()?
> 
> 
> 
>                        Alfredo.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 


-- 
Martin Hinks
http://www.m-s-d.net



More information about the Mono-devel-list mailing list