[Mono-bugs] [Bug 583556] New: Conversions between Utc and other timezones don't work in DateTimeOffset

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Feb 26 03:53:24 EST 2010


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

http://bugzilla.novell.com/show_bug.cgi?id=583556#c0


           Summary: Conversions between Utc and other timezones don't work
                    in DateTimeOffset
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: x86-64
        OS/Version: SLES 11
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: paszczi at go2.pl
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Invoking the following code:
var utcNow = DateTimeOffset.UtcNow;
var tz = TimeZoneInfo.GetSystemTimeZones ().FirstOrDefault (o => o.Id ==
"Europe/Warsaw" || o.Id == "Central European Standard Time");
var cestOffset = tz.GetUtcOffset(utcNow);
var cestDate = utcNow.ToOffset(cestOffset);

This throws exception:
ArgumentException ("dateTime.Kind equals Utc and offset does not equal zero.")
On .NET the code works as expected. We currently use this workaround and it
seems to do the job:

var utcOffset = info.GetUtcOffset (time.UtcDateTime);
var newDate = time.UtcDateTime + utcOffset;
var cestDate = new DateTimeOffset(newDate.Ticks, utcOffset);

-- 
Configure bugmail: http://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