<!--
RSS generated by JIRA (4.4#649-r158309) at Sat May 25 01:27:25 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+10010+AND+labels+%3D+instant&tempMax=1000&field=key&field=summary
-->
<!-- If you wish to do custom client-side styling of RSS, uncomment this:
<?xml-stylesheet href="http://dev.clojure.org/jira/styles/jiraxml2html.xsl" type="text/xsl"?>
-->
<rss version="0.92">
    <channel>
        <title>Clojure JIRA</title>
        <link>http://dev.clojure.org/jira/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+10010+AND+labels+%3D+instant</link>
        <description>An XML representation of a search request</description>
                <language>en-us</language>
                        <issue start="0" end="1" total="1"/>
                <build-info>
            <version>4.4</version>
            <build-number>649</build-number>
            <build-date>25-07-2011</build-date>
        </build-info>
<item>
            <title>[CLJ-926] Instant literals do not round trip correctly</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-926</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;When using java.util.Date for instant literals (which is the default) instants do not round-trip properly during daylight savings. Here is an example:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;(read-string &quot;#inst \&quot;2010-11-12T13:14:15.666-06:00\&quot;&quot;)
#inst &quot;2010-11-13T06:14:15.666+10:00&quot;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I&apos;m currently in Melbourne, which is normally GMT+10. However, on November 12th daylight savings is in effect, so the proper GMT offset is +11. The date above is actually using the correct local time (6:14:15) but with the wrong offset. The problem is more obvious when you attempt to round-trip the instant that was read.&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;user&amp;gt; #inst &quot;2010-11-13T06:14:15.666+10:00&quot;
#inst &quot;2010-11-13T07:14:15.666+10:00&quot;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;Notice that we read 6:14am but the output was 7:14 with the same offset. Upon digging deeper the real culprit seems to be the use of String.format (through clojure.core/format) when outputting java.util.Date. Notice the following inside caldate-&amp;gt;rfc3339&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;(format &quot;#inst \&quot;%1$tFT%1$tT.%1$tL%1$tz\&quot;&quot; d))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let&apos;s compare the timezone offset in the underlying date with what is printed by %1$tz&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;user&amp;gt; (def d #inst &quot;2010-11-13T06:14:15.666+10:00&quot;)
#&apos;clojure.instant/d                                                                                                                                                                                         
user&amp;gt; (.getHours d)
7                                                                                                                                                                                                           
user&amp;gt; (.getTimezoneOffset d)
-660
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For reference, the definition of getTimezoneOffset is &lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;-(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;So far it looks good. 6am in GMT+10 becomes 7am in GMT+11. Let&apos;s see how String.format handles it though.&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;                                                                                               
clojure.instant&amp;gt; (format &quot;%1$tz&quot; d)
&quot;+1000&quot;                                                                                                                                                                                                     
clojure.instant&amp;gt; (format &quot;%1$tT&quot; d)
&quot;07:14:15&quot;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;String.format prints the correct hour, but with the wrong offset. The recommended way for formatting dates is to use a DateFormatter. &lt;/p&gt;

&lt;p&gt;The String.format approach appears to work properly for Calendar, but not for Date. Therefore the attached patch keeps the current &lt;br/&gt;
implementation for java.util.Calendar but uses SimpleDateFormat to handle java.util.Date correctly. This fixes the roundtrip problem.&lt;/p&gt;

</description>
                <environment></environment>
            <key id="15202">CLJ-926</key>
            <summary>Instant literals do not round trip correctly</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                <priority id="3" iconUrl="http://dev.clojure.org/jira/images/icons/priority_major.gif">Major</priority>
                    <status id="6" iconUrl="http://dev.clojure.org/jira/images/icons/status_closed.gif">Closed</status>
                    <resolution id="2">Declined</resolution>
                                <assignee username="-1">Unassigned</assignee>
                                <reporter username="cosmin">Cosmin Stejerean</reporter>
                        <labels>
                        <label>instant</label>
                        <label>reader</label>
                        <label>tagged-literals</label>
                    </labels>
                <created>Sun, 5 Feb 2012 21:23:19 -0600</created>
                <updated>Fri, 17 Feb 2012 15:55:14 -0600</updated>
                    <resolved>Fri, 17 Feb 2012 15:55:14 -0600</resolved>
                            <version>Release 1.4</version>
                                                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="27675" author="cosmin" created="Sun, 5 Feb 2012 21:29:22 -0600"  >&lt;p&gt;Not quite sure how to create a repeatable test for this since the issue depends on the local timezone.&lt;/p&gt;</comment>
                    <comment id="27676" author="steveminer@gmail.com" created="Mon, 6 Feb 2012 08:33:11 -0600"  >&lt;p&gt;java.util.TimeZone/setDefault could be used for testing in various timezones.&lt;/p&gt;</comment>
                    <comment id="27677" author="steveminer@gmail.com" created="Mon, 6 Feb 2012 08:37:12 -0600"  >&lt;p&gt;Regarding the patch: SimpleDateFormat is a relatively heavy-weight object, so it seems bad to allocate one every time you print a Date.  Unfortunately, SimpleDateFormat is not thread-safe, so you can&apos;t just share one.  The Java world seems to agree that you should use JodaTime instead, but if you&apos;re stuck with the JDK, you need to have a ThreadLocal SimpleDateFormat. I&apos;m working on my own patch along those lines.&lt;/p&gt;</comment>
                    <comment id="27683" author="fogus" created="Mon, 6 Feb 2012 19:38:17 -0600"  >&lt;p&gt;Excellent analysis.  I&apos;ll keep track of this case and vet any patches that come along.  Please do attach a regression test if possible.&lt;/p&gt;</comment>
                    <comment id="27684" author="cosmin" created="Mon, 6 Feb 2012 20:39:09 -0600"  >&lt;p&gt;I attached a new patch using a SimpleDateFormat per thread using a thread local. I&apos;ll try to add some tests next.&lt;/p&gt;</comment>
                    <comment id="27687" author="cosmin" created="Mon, 6 Feb 2012 22:42:01 -0600"  >&lt;p&gt;A combined patch that uses a thread local SimpleDateFormat, tests round-tripping at a known daylight savings point (by overriding the default timezone) and checks round tripping at multiple points throughout the year (every hour of the first 4 weeks of every month of the year).&lt;/p&gt;

&lt;p&gt;Steve, thanks for the suggestions on using a thread local and TimeZone/setDefault.&lt;/p&gt;</comment>
                    <comment id="27690" author="steveminer@gmail.com" created="Tue, 7 Feb 2012 13:32:11 -0600"  >&lt;p&gt;I filed &lt;a href=&quot;http://dev.clojure.org/jira/browse/CLJ-928&quot; title=&quot;instant literal for Date and Timestamp should print in UTC&quot;&gt;&lt;del&gt;CLJ-928&lt;/del&gt;&lt;/a&gt; with my patch for fixing the printing of Date and Timestamp using UTC.  I copied the tests from the &lt;a href=&quot;http://dev.clojure.org/jira/browse/CLJ-926&quot; title=&quot;Instant literals do not round trip correctly&quot;&gt;&lt;del&gt;CLJ-926&lt;/del&gt;&lt;/a&gt; patch to make sure we&apos;re compatible.&lt;/p&gt;</comment>
                    <comment id="27692" author="fogus" created="Tue, 7 Feb 2012 15:11:58 -0600"  >&lt;p&gt;Thanks for the regression test also.  I&apos;ll vett this patch ASAP.&lt;/p&gt;</comment>
                    <comment id="27741" author="fogus" created="Fri, 17 Feb 2012 13:24:09 -0600"  >&lt;p&gt;Seems reasonable to me.&lt;/p&gt;</comment>
                    <comment id="27744" author="stuart.sierra" created="Fri, 17 Feb 2012 13:46:25 -0600"  >&lt;p&gt;Vetted. Will apply later.&lt;/p&gt;</comment>
                    <comment id="27746" author="stuart.sierra" created="Fri, 17 Feb 2012 13:56:49 -0600"  >&lt;p&gt;Not Vetted. Test. That thing.&lt;/p&gt;</comment>
                    <comment id="27749" author="stuart.sierra" created="Fri, 17 Feb 2012 14:10:14 -0600"  >&lt;p&gt;No, it&apos;s &quot;Screened,&quot; not &quot;Test.&quot; Somebody save me.&lt;/p&gt;</comment>
                    <comment id="27760" author="stuart.sierra" created="Fri, 17 Feb 2012 15:55:14 -0600"  >&lt;p&gt;Superseded by &lt;a href=&quot;http://dev.clojure.org/jira/browse/CLJ-928&quot; title=&quot;instant literal for Date and Timestamp should print in UTC&quot;&gt;&lt;del&gt;CLJ-928&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10895" name="CLJ-926-round-trip-date-instants-with-tests.patch" size="5506" author="cosmin" created="Mon, 6 Feb 2012 22:42:01 -0600" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Approval</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10004">Screened</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                    <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                            <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Patch</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10002">Code and Test</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                    <customfield id="customfield_10003" key="com.atlassian.jira.plugin.system.customfieldtypes:userpicker">
                <customfieldname>Waiting On</customfieldname>
                <customfieldvalues>
                    <customfieldvalue>stuart.sierra</customfieldvalue>
                </customfieldvalues>
            </customfield>
                            </customfields>
    </item>
</channel>
</rss>