[Mono-bugs] [Bug 352210] Serialization and deserialization of datetime to and from xml, "shifts" the time with the timezone

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Feb 3 15:48:17 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=352210

User jdpurcell2 at yahoo.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=352210#c7





--- Comment #7 from James Purcell <jdpurcell2 at yahoo.com>  2008-02-03 13:48:16 MST ---
Created an attachment (id=192962)
 --> (https://bugzilla.novell.com/attachment.cgi?id=192962)
patch

I've created a patch that fixes several issues with DateTime parsing having the
wrong time zone or the wrong DateTimeKind.

DateTime.cs:
1) Simplified the useutc, use_localtime, explicit_kind stuff.  This fixes
returning the wrong DateTimeKind and a bug where AssumeUniversal forced useutc
even if a timezone was specified in the date/time string.  Probably fixes some
other stuff too, to be honest the old code was quite confusing so I'm not sure
what it did.
2) Fixed handling of "GMT" in format or date/time string.  For the part where
it checked with "CompareInfo.IndexOf", I don't know if that was being used
because it was only for !exact and I don't think the predefined format strings
have "GMT" in them.  Even so, this code was incorrect because you should be
able to use a single quoted GMT (i.e. " 'GMT' ") in the format string without
it affecting useutc.  But this is now handled properly inside the parse loop,
and it also corrects a bug with ParseExact not setting useutc when "GMT" was in
the format string.  Note that this needs to be a case sensitive comparison, so
_ParseString shouldn't be used, unlike checking the date/time string with
flexibleTwoPartsParsing for "GMT" where it is correct to ignore case.  Speaking
of the flexibleTwoPartsParsing "GMT" parsing code, it should actually behave
different in .NET 2.0 to allow the "GMT" to appear before the time part (e.g.
"GMT date time", "date GMT time", "GMT time date", etc), which is included in
the patch.

DateTimeUtils.cs
1) For the 'u' format string, it should not set useutc unless being used in the
context of DateTimeOffset.
2) MSDN says 'o', 's', and 'u' use invariant culture.  This doesn't seem to
make any difference but I think it's a good idea to set it anyway.
3) Uppercase 'o' ('O') should be allowed as well.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list