<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Imagination in VGA &#187; Microsoft</title>
	<atom:link href="http://joshuamorse.com/tag/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshuamorse.com</link>
	<description>Thoughts on Usability, Design, and Gadgets from Josh Morse, Information Architect</description>
	<lastBuildDate>Wed, 10 Mar 2010 01:00:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Zune Leap Year Bug: Source Code</title>
		<link>http://joshuamorse.com/2009/01/02/the-zune-leap-year-bug/</link>
		<comments>http://joshuamorse.com/2009/01/02/the-zune-leap-year-bug/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 18:24:55 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://joshuamorse.com/?p=23</guid>
		<description><![CDATA[For those who have been watching the news, Microsoft&#8217;s Zune mp3 player froze for owners on December 31.  Microsoft blamed the bug on the leap year, and it seems that things have resolved themselves.  Looking at the Zune source code, one can see exactly where things went wrong:
while (days &#62; 365)
   [...]]]></description>
			<content:encoded><![CDATA[<p>For those who have been watching the news, Microsoft&#8217;s Zune mp3 player froze for owners on December 31.  Microsoft <a href="http://www.forbes.com/afxnewslimited/feeds/afx/2009/01/01/afx5872995.html">blamed the bug on the leap year</a>, and it seems that things have resolved themselves.  Looking at the <a href="http://pastie.org/349916">Zune source code</a>, one can see exactly where things went wrong:</p>
<pre class="textmate-source"><span class="keyword keyword_control keyword_control_c">while</span> (days &gt; 365)
    {
        <span class="keyword keyword_control keyword_control_c">if</span>(IsLeapYear(year))
        {
            <span style="color: #ff0000;"><span class="keyword keyword_control keyword_control_c">if</span> (days &gt; 366)</span>
            {
                days -= <span class="constant constant_numeric constant_numeric_c">366</span>;
                year += <span class="constant constant_numeric constant_numeric_c">1</span>;
            }
        }
        <span class="keyword keyword_control keyword_control_c">else</span>
        {
            days -= <span class="constant constant_numeric constant_numeric_c">365</span>;
            year += <span class="constant constant_numeric constant_numeric_c">1</span>;
        }
    }</pre>
<p>For those without a programming background, the problem is that there is no &#8220;if&#8221; for day 366, just for days greater than 366 (which would be January 1 of 2009).  This means that the code gets caught in in infinite loop on the 366th day (December 31) of the year.  On January 1 of 2009, however, the &#8220;days&#8221; variable is set to 367, which causes the day to be set back to 1 (January 1) and the year to be incremented to 2009.  So the bug only lasts a day.</p>
<p>Programming 101 &#8211; be sure to test all of your cases, particularly those inside of loops.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshuamorse.com/2009/01/02/the-zune-leap-year-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
