<!-- 
RSS generated by JIRA (4.4#649-r158309) at Wed May 22 20:43:06 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/si/jira.issueviews:issue-xml/CLJ-928/CLJ-928.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[CLJ-928] instant literal for Date and Timestamp should print in UTC</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-928</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;The default #inst returns a java.util.Date.  Date is always in UTC, and doesn&apos;t know about time zones, but the implementation of the print method always renders it in the default time zone.  For example,&lt;/p&gt;

&lt;p&gt;user=&amp;gt; #inst &quot;2012Z&quot;&lt;br/&gt;
#inst &quot;2011-12-31T19:00:00.000-05:00&quot;&lt;/p&gt;

&lt;p&gt;RFC3339 says:&lt;/p&gt;

&lt;p&gt;4.3. Unknown Local Offset Convention&lt;/p&gt;

&lt;p&gt;  If the time in UTC is known, but the offset to local time is unknown,&lt;br/&gt;
  this can be represented with an offset of &quot;-00:00&quot;.  This differs&lt;br/&gt;
  semantically from an offset of &quot;Z&quot; or &quot;+00:00&quot;, which imply that UTC&lt;br/&gt;
  is the preferred reference point for the specified time.&lt;/p&gt;

&lt;p&gt;java.sql.Timestamp should also print in UTC since that class doesn&apos;t keep timezone information.  The print-method for Timestamp seems broken.&lt;/p&gt;

&lt;p&gt;user=&amp;gt; (binding &lt;span class=&quot;error&quot;&gt;&amp;#91;*data-readers* {&apos;inst #&apos;clojure.instant/read-instant-timestamp}] (read-string &quot;#inst \&quot;2012Z\&quot;&quot;))&lt;br/&gt;
#inst &quot;2011-12-31T19:000000000000000-05:00&quot;&lt;br/&gt;
&lt;br/&gt;
user=&amp;gt; (binding [&lt;b&gt;data-readers&lt;/b&gt; {&apos;inst #&apos;clojure.instant/read-instant-timestamp}&amp;#93;&lt;/span&gt; (read-string &quot;#inst \&quot;2012-01-01T01:23:45.678+00:00\&quot;&quot;))&lt;br/&gt;
#inst &quot;2011-12-31T20:267800000000000-05:00&quot;&lt;/p&gt;

&lt;p&gt;user=&amp;gt; (java.sql.Timestamp. 0)&lt;br/&gt;
#inst &quot;1969-12-31T19:000000000000000-05:00&quot;&lt;/p&gt;


&lt;p&gt;The implementations of the print-methods for Data, GregorianCalendar and Timestamp do too much string manipulation.  I suggest doing some refactoring.  (Patch coming soon.)&lt;/p&gt;

&lt;p&gt;Also, the documentation needs some updating.  clojure.instant/read-instant-date, etc. mention &lt;b&gt;instant-reader&lt;/b&gt; but I think that mechanism was generalized as &lt;b&gt;data-readers&lt;/b&gt;.&lt;/p&gt;</description>
                <environment>1.4-beta1, Mac OS X 10.7.3, java version &amp;quot;1.6.0_30&amp;quot;</environment>
            <key id="15207">CLJ-928</key>
            <summary>instant literal for Date and Timestamp should print in UTC</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="1">Completed</resolution>
                                <assignee username="-1">Unassigned</assignee>
                                <reporter username="steveminer@gmail.com">Steve Miner</reporter>
                        <labels>
                        <label>reader</label>
                    </labels>
                <created>Tue, 7 Feb 2012 13:19:34 -0600</created>
                <updated>Fri, 1 Mar 2013 12:46:58 -0600</updated>
                    <resolved>Fri, 24 Feb 2012 15:29:11 -0600</resolved>
                            <version>Release 1.4</version>
                                                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="27689" author="steveminer@gmail.com" created="Tue, 7 Feb 2012 13:28:29 -0600"  >&lt;p&gt;#inst literals for Date and Timestamp should print in UTC.  Fixed round-tripping problem with Timestamp nanos (and re-enabled test).  Refactored print-methods to avoid some string manipulations, particularly regarding Calendar timezone offsets.  Added tests including those from &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;, which this patch also fixes.  Fixed doc on read-instant-date, etc.&lt;/p&gt;</comment>
                    <comment id="27691" author="fogus" created="Tue, 7 Feb 2012 15:10:58 -0600"  >&lt;p&gt;Thank you.  I will run this patch through the paces ASAP.&lt;/p&gt;</comment>
                    <comment id="27693" author="cosmin" created="Tue, 7 Feb 2012 19:09:47 -0600"  >&lt;p&gt;&quot;Date is always in UTC, and doesn&apos;t know about time zones&quot;&lt;/p&gt;

&lt;p&gt;Given that pretty much all of the methods on Date return results in the local timezone, I wouldn&apos;t quite say that Date is always in UTC. Granted, most of those methods are deprecated; toString() however isn&apos;t and it also displays the date in the local timezone.&lt;/p&gt;

&lt;p&gt;We can certainly force printing of dates in UTC, by overriding the timezone setting on SimpleDateFormat, and there might be other valid reasons for always forcing UTC representation. Dates not being timezone aware however doesn&apos;t seem like one to me.&lt;/p&gt;</comment>
                    <comment id="27698" author="steveminer@gmail.com" created="Wed, 8 Feb 2012 08:54:11 -0600"  >&lt;p&gt;It&apos;s only a slight exaggeration to say that a java.util.Date is intrinsically a long (milliseconds since &quot;the epoch&quot;).  For Clojure&apos;s purposes, an &quot;instant&quot; is a point in time in a universal sense (not situated in a timezone) so UTC makes sense as the canonical form.  RFC 3339 section 4.3 says to use &quot;-00:00&quot; for the offset when timezone information is unknown.  java.sql.Timestamp is like a Date with an extra field for nanos so it also should use UTC for the canonical form.&lt;/p&gt;

&lt;p&gt;My argument for UTC as the canonical form is that it best matches the desired semantics of a Clojure instant.  I think it&apos;s the most conservative way to go and offers the best approach to interoperability by following RFC 3339.&lt;/p&gt;

&lt;p&gt;java.util.Calendar is by design cognizant of timezones so it arguably makes sense to preserve the timezone information.  Note that comparisons of Calendars take into account the timezone so two Calendar objects might be the same instant in a sense but not be equal because of the timezones.  That might be a bit tricky for Clojure users who want a clean abstraction of &quot;instant&quot; with multiple implementations.  Presumably they know what they are doing if they decide to use read-instant-calendar.  It might be a good idea to be more explicit about this in the documentation.&lt;/p&gt;</comment>
                    <comment id="27781" author="fogus" created="Mon, 20 Feb 2012 15:22:01 -0600"  >&lt;p&gt;Modified priting to conform to the following:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Instant instances are stored in UTC format without offset information.&lt;/li&gt;
	&lt;li&gt;Instant literals with offset information will be parsed and stored with offset applied.&lt;/li&gt;
	&lt;li&gt;Instant literals without offset information will be parsed as UTC format without offset information.&lt;/li&gt;
	&lt;li&gt;Instants will print as time having local offset applied and without offset printed.&lt;/li&gt;
	&lt;li&gt;Instants without offset info will be print-dup&apos;d as UTC format with RFC-3339 default offset information (-00:00)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;    This provides a canonical storage and read format of UTC and a print format relative to the local offset.&lt;/p&gt;</comment>
                    <comment id="27846" author="stuart.sierra" created="Fri, 24 Feb 2012 14:11:18 -0600"  >&lt;p&gt;With Fogus&apos; patch on Feb. 20, instant literals do not round-trip unless &lt;tt&gt;&amp;#42;print-dup&amp;#42;&lt;/tt&gt; is bound true:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;user=&amp;gt;  (let [i (read-string &lt;span class=&quot;code-quote&quot;&gt;&quot;#inst \&quot;&lt;/span&gt;2012-02-24T14:41-02:00\&quot;&quot;)
              j (read-string (pr-str i))]
          (prn i)
          (prn j)
          (prn (= i j)))
#inst &lt;span class=&quot;code-quote&quot;&gt;&quot;2012-02-24T11:41:00.000&quot;&lt;/span&gt;
#inst &lt;span class=&quot;code-quote&quot;&gt;&quot;2012-02-24T06:41:00.000&quot;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;
nil
user=&amp;gt;(binding [*print-dup* &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;]
        (let [i (read-string &lt;span class=&quot;code-quote&quot;&gt;&quot;#inst \&quot;&lt;/span&gt;2012-02-24T14:41-02:00\&quot;&quot;)
              j (read-string (pr-str i))]
          (prn i)
          (prn j)
          (prn (= i j))))
#inst &lt;span class=&quot;code-quote&quot;&gt;&quot;2012-02-24T16:41:00.000-00:00&quot;&lt;/span&gt;
#inst &lt;span class=&quot;code-quote&quot;&gt;&quot;2012-02-24T16:41:00.000-00:00&quot;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
nil&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The docstring of &lt;tt&gt;&amp;#42;print-dup&amp;#42;&lt;/tt&gt; says nothing about print/read values being equal (by Clojure&apos;s definition of =) only that print/read values will be of the same type. &quot;Type&quot; is not a particularly meaningful concept when applied to data literals.&lt;/p&gt;

&lt;p&gt;We (Stuart &amp;amp; Luke) believe that print/read values should &lt;b&gt;always&lt;/b&gt; print in such a way that they can be read back as the same instant.  Printing an instant should either:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;print in local time, with local offset&lt;/li&gt;
	&lt;li&gt;always print in UTC, with zero offset&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Instants should &lt;b&gt;never&lt;/b&gt; print without any time zone offset, as this admits too much confusion.&lt;/p&gt;</comment>
                    <comment id="27848" author="stuart.sierra" created="Fri, 24 Feb 2012 14:46:56 -0600"  >&lt;p&gt;Just spoke with Rich Hickey, who made the following assertions:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Instants should always represent an exact point in time, unambiguously. This representation may include time zone information.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;Our specification for instant literals allows any part on the right to be omitted. Omitting the time zone offset means UTC is assumed. It is not important whether or not the default printer includes the UTC &quot;00:00&quot; offset or omits it.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;If we are printing an instant literal based on a type that does &lt;b&gt;not&lt;/b&gt; contain time zone information (e.g., java.util.Date) then we should &lt;b&gt;not&lt;/b&gt; add time zone information but simply print in UTC.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;If we are printing an instant literal based on a type that &lt;b&gt;can&lt;/b&gt; contain time zone information (e.g., java.util.Calendar) then we &lt;b&gt;may&lt;/b&gt; print with the time zone offset included. This is a nice-to-have feature, not a requirement. It is always permissible to print instants in UTC.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;It is possible that round-trip print/read of an instant &lt;b&gt;may&lt;/b&gt; lose time zone information, depending on the types used, but it this should not change the meaning of the instant in UTC.&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    <comment id="27851" author="steveminer@gmail.com" created="Fri, 24 Feb 2012 15:13:29 -0600"  >&lt;p&gt;I believe my original patch satisfies the requirements stated above.  I&apos;m happy to work on this if you want something changed.&lt;/p&gt;</comment>
                    <comment id="27852" author="stuart.sierra" created="Fri, 24 Feb 2012 15:22:53 -0600"  >&lt;p&gt;Rejected Fogus&apos; patch of Feb. 20.&lt;/p&gt;

&lt;p&gt;Screened Steve Miner&apos;s patch of Feb. 7. Ready for Rich.&lt;/p&gt;</comment>
                    <comment id="27853" author="stuart.sierra" created="Fri, 24 Feb 2012 15:29:11 -0600"  >&lt;p&gt;Patch applied.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10933" name="CLJ-928-instant-literals-for-Date-and-Timestamp-fogus.patch" size="21551" author="fogus" created="Mon, 20 Feb 2012 15:22:01 -0600" />
                    <attachment id="10896" name="CLJ-928-instant-literals-for-Date-and-Timestamp.patch" size="13173" author="steveminer@gmail.com" created="Tue, 7 Feb 2012 13:28:29 -0600" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Approval</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10007">Ok</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>
                                                                                        </customfields>
    </item>
</channel>
</rss>