[Mono-bugs] [Bug 621366] System.DateTime converts NSDate to UTC

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jul 14 12:15:19 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=621366

http://bugzilla.novell.com/show_bug.cgi?id=621366#c2


Miguel de Icaza <miguel at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |miguel at novell.com

--- Comment #2 from Miguel de Icaza <miguel at novell.com> 2010-07-14 16:15:18 UTC ---
A quick workaround is to not use the implicit NSDate to DateTime conversion,
this is merely an operator implicit in MonoTouch.

This is the code that does the change, so you can just avoid this by having
your own routines with your own rules:


    public partial class NSDate {
        const long NSDATE_TICKS = 631139040000000000;

        public static implicit operator DateTime (NSDate d)
        {
            return new DateTime ((long)(d.SecondsSinceReferenceDate *
TimeSpan.TicksPerSecond + NSDATE_TICKS), DateTimeKind.Utc);
        }

        public static implicit operator NSDate (DateTime dt)
        {
            return FromTimeIntervalSinceReferenceDate ((dt.ToUniversalTime
().Ticks - NSDATE_TICKS) / TimeSpan.TicksPerSecond);
        }

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


More information about the mono-bugs mailing list