mail-archives/mono-bugs/2010-July/101915.html

141 строка
5.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 619811] New: TimeZoneInfo.ConvertTimeFromUtc throws a NullReferenceException for US/Hawaii timezone
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20619811%5D%20New%3A%20TimeZoneInfo.ConvertTimeFromUtc%0A%20throws%20a%20NullReferenceException%20for%20US/Hawaii%20timezone&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="101914.html">
<LINK REL="Next" HREF="102057.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 619811] New: TimeZoneInfo.ConvertTimeFromUtc throws a NullReferenceException for US/Hawaii timezone</H1>
<B>bugzilla_noreply at novell.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20619811%5D%20New%3A%20TimeZoneInfo.ConvertTimeFromUtc%0A%20throws%20a%20NullReferenceException%20for%20US/Hawaii%20timezone&In-Reply-To="
TITLE="[Mono-bugs] [Bug 619811] New: TimeZoneInfo.ConvertTimeFromUtc throws a NullReferenceException for US/Hawaii timezone">bugzilla_noreply at novell.com
</A><BR>
<I>Sun Jul 4 21:04:10 EDT 2010</I>
<P><UL>
<LI>Previous message: <A HREF="101914.html">[Mono-bugs] [Bug 619808] New: System.PlatformID not reported correctly in Mac OSX
</A></li>
<LI>Next message: <A HREF="102057.html">[Mono-bugs] [Bug 619811] TimeZoneInfo.ConvertTimeFromUtc throws a NullReferenceException for US/Hawaii timezone
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#101915">[ date ]</a>
<a href="thread.html#101915">[ thread ]</a>
<a href="subject.html#101915">[ subject ]</a>
<a href="author.html#101915">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE><A HREF="http://bugzilla.novell.com/show_bug.cgi?id=619811">http://bugzilla.novell.com/show_bug.cgi?id=619811</A>
<A HREF="http://bugzilla.novell.com/show_bug.cgi?id=619811#c0">http://bugzilla.novell.com/show_bug.cgi?id=619811#c0</A>
Summary: TimeZoneInfo.ConvertTimeFromUtc throws a
NullReferenceException for US/Hawaii timezone
Classification: Mono
Product: Mono: Class Libraries
Version: 2.4.x
Platform: 64bit
OS/Version: UNIX Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">graham.wagener at gmail.com</A>
QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.86 Safari/533.4
I get the following exception and truncated stack trace when calling
ConvertTimeFromUtc with destinationTimeZone of &quot;US/Hawaii&quot;.
TimeZoneInfo hawaiiTZI = TimeZoneInfo.FindSystemTimeZoneById(&quot;US/Hawaii&quot;);
DateTime gmt = new DateTime(...);
DateTime local = TimeZoneInfo(gmt, hawaiiTZI);
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
at System.TimeZoneInfo.GetApplicableRule (DateTime dateTime) [0x00000]
at System.TimeZoneInfo.ConvertTimeFromUtc (DateTime dateTime) [0x00000]
at System.TimeZoneInfo.ConvertTimeFromUtc (DateTime dateTime,
System.TimeZoneInfo destinationTimeZone) [0x00000]
Hawaii does not observe Daylight Savings Time so hawaiiTZI.GetAdjustmentRules()
returns an empty array or possibly null, which presumably leads to the NRE in
GetApplicableRule.
A workaround and example of related code that does work is using GetUtcOffset.
On Windows under .NET the following returns the same value as
ConvertTimeFromUtc and does not throw an exception in mono:
DateTime local = gmt + hawaiiTZI.GetUtcOffset(gmt);
Reproducible: Always
Steps to Reproduce:
see code in description
Actual Results:
exception
Expected Results:
no exception
--
Configure bugmail: <A HREF="http://bugzilla.novell.com/userprefs.cgi?tab=email">http://bugzilla.novell.com/userprefs.cgi?tab=email</A>
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="101914.html">[Mono-bugs] [Bug 619808] New: System.PlatformID not reported correctly in Mac OSX
</A></li>
<LI>Next message: <A HREF="102057.html">[Mono-bugs] [Bug 619811] TimeZoneInfo.ConvertTimeFromUtc throws a NullReferenceException for US/Hawaii timezone
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#101915">[ date ]</a>
<a href="thread.html#101915">[ thread ]</a>
<a href="subject.html#101915">[ subject ]</a>
<a href="author.html#101915">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>