<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Date has a smal bug]]></title><description><![CDATA[<pre><code>
    //
    // Reading and writing
    //
    public Date(ByteQueue queue) {
        readTag(queue);
        year = queue.popU1B() + 1900;
        month = Month.valueOf(queue.pop());
        day = queue.popU1B();
        dayOfWeek = DayOfWeek.valueOf(queue.pop());
    }

</code></pre>
<p dir="auto">the fix offset of 1900 is wrong.<br />
it should be:</p>
<pre><code>
        int tmpyear = queue.popU1B();
        if (tmpyear != 255)
        {
        	tmpyear += 1900;
        }
        year = tmpyear;

</code></pre>
<p dir="auto">else the function isYearUnspecified will never return true.<br />
causes a glitch when displaying an unspecified year.</p>
<p dir="auto">regards<br />
robert</p>
]]></description><link>https://forum.mango-os.com/topic/675/date-has-a-smal-bug</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Nov 2026 08:27:16 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/675.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 10 Dec 2010 10:29:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Date has a smal bug on Mon, 13 Dec 2010 09:56:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joolz" aria-label="Profile: joolz">@<bdi>joolz</bdi></a> said:</p>
<blockquote>
<p dir="auto">What a coincidence, ...<br />
hi,</p>
</blockquote>
<p dir="auto">thanks for testing  :-)</p>
<p dir="auto">regards<br />
robert</p>
]]></description><link>https://forum.mango-os.com/post/5096</link><guid isPermaLink="true">https://forum.mango-os.com/post/5096</guid><dc:creator><![CDATA[robert bouwens]]></dc:creator><pubDate>Mon, 13 Dec 2010 09:56:48 GMT</pubDate></item><item><title><![CDATA[Reply to Date has a smal bug on Mon, 13 Dec 2010 01:01:29 GMT]]></title><description><![CDATA[<p dir="auto">What a coincidence, I came online to report the exact same thing, as my schedules were being created with the wrong year for the effective date range when I used unspecified.</p>
<p dir="auto">I've tried your modifications, and they do the trick.</p>
<blockquote>
<p dir="auto">I don't recall now why the Date class is storing a +1900 year value internally anyway. Maybe it should just use 0-255 internally and provide convenience methods for +1900? Agreed.  I think that would be the most sensible solution</p>
</blockquote>
]]></description><link>https://forum.mango-os.com/post/5095</link><guid isPermaLink="true">https://forum.mango-os.com/post/5095</guid><dc:creator><![CDATA[joolz]]></dc:creator><pubDate>Mon, 13 Dec 2010 01:01:29 GMT</pubDate></item><item><title><![CDATA[Reply to Date has a smal bug on Fri, 10 Dec 2010 15:37:10 GMT]]></title><description><![CDATA[<p dir="auto">How's this:</p>
<pre><code>    public Date(int year, Month month, int day, DayOfWeek dayOfWeek) {
        if (year &amp;gt 1900)
            year -= 1900;
        else if (year == -1)
            year = 255;
        if (day == -1)
            day = 255;

        this.year = year;
        this.month = month;
        this.day = day;
        this.dayOfWeek = dayOfWeek;
    }

</code></pre>
<pre><code>    public Date(GregorianCalendar now) {
        this.year = now.get(Calendar.YEAR) - 1900;
        this.month = Month.valueOf((byte) (now.get(Calendar.MONTH) + 1));
        this.day = now.get(Calendar.DATE);
        this.dayOfWeek = DayOfWeek.valueOf((byte) (((now.get(Calendar.DAY_OF_WEEK) + 5) % 7) + 1));
    }

</code></pre>
<pre><code>    public int getCenturyYear() {
        return year + 1900;
    }

</code></pre>
<pre><code>    public Date(ByteQueue queue) {
        readTag(queue);
        year = queue.popU1B();
        month = Month.valueOf(queue.pop());
        day = queue.popU1B();
        dayOfWeek = DayOfWeek.valueOf(queue.pop());
    }

    @Override
    public void writeImpl(ByteQueue queue) {
        queue.push(year);
        queue.push(month.getId());
        queue.push((byte) day);
        queue.push(dayOfWeek.getId());
    }

</code></pre>
]]></description><link>https://forum.mango-os.com/post/5086</link><guid isPermaLink="true">https://forum.mango-os.com/post/5086</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Fri, 10 Dec 2010 15:37:10 GMT</pubDate></item><item><title><![CDATA[Reply to Date has a smal bug on Fri, 10 Dec 2010 15:29:31 GMT]]></title><description><![CDATA[<p dir="auto">I don't recall now why the Date class is storing a +1900 year value internally anyway. Maybe it should just use 0-255 internally and provide convenience methods for +1900?</p>
]]></description><link>https://forum.mango-os.com/post/5085</link><guid isPermaLink="true">https://forum.mango-os.com/post/5085</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Fri, 10 Dec 2010 15:29:31 GMT</pubDate></item><item><title><![CDATA[Reply to Date has a smal bug on Fri, 10 Dec 2010 10:46:11 GMT]]></title><description><![CDATA[<p dir="auto">also</p>
<pre><code>

    @Override
    public void writeImpl(ByteQueue queue) {
    	int shortYear = year;
    	if (shortYear &gt; 1900)
    	{
    		shortYear -= 1900;
    	}

</code></pre>
]]></description><link>https://forum.mango-os.com/post/5083</link><guid isPermaLink="true">https://forum.mango-os.com/post/5083</guid><dc:creator><![CDATA[robert bouwens]]></dc:creator><pubDate>Fri, 10 Dec 2010 10:46:11 GMT</pubDate></item></channel></rss>