<abstract>This document specifies a standardization of ISO 8601 profiles and their lexical representation for use in XMPP protocol extensions.</abstract>
<p>A number of XMPP protocol extensions specify that dates and times should follow the format defined in &iso8601;. Unfortunately, ISO 8601 provides a great deal of flexibility with regard to the possible date and time "profiles" <note>The concept of an ISO 8601 profile is used in both RFC 3339 (<linkurl='http://www.ietf.org/rfc/rfc3339.txt'>http://www.ietf.org/rfc/rfc3339.txt</link>) and a W3C Note (<linkurl='http://www.w3.org/TR/NOTE-datetime'>http://www.w3.org/TR/NOTE-datetime</link>).</note> as well as their lexical representation. While that flexibility can lead to confusion, it is also true that the Jabber/XMPP community has tended to use only a few restricted profiles of ISO 8601 dates and times (albeit with inconsistent lexical representations). This document formalizes those profiles and their lexical representation through reference to the datatypes defined in &w3xmlschema2;.</p>
<tr><td>CCYY</td><td>four-digit year portion of Date <note>According to the XML schema datatypes specification <<linkurl='http://www.w3.org/TR/xmlschema11-2/#dateTime'>http://www.w3.org/TR/xmlschema11-2/#dateTime</link>>, the year portion of a Date can be more than four digits (for years after 9999) and can be preceded by a minus sign (for years before 1 BCE); given that Jabber/XMPP technologies did not exist before 1999, the use of the minus sign is not recommended.</note></td></tr>
<p>This profile is equivalent to the 'date' datatype defined in XML Schema <note>The 'date' datatype is defined at <<linkurl='http://www.w3.org/TR/xmlschema11-2/#date'>http://www.w3.org/TR/xmlschema11-2/#date</link>>.</note>. When an XML schema is used to define an XMPP protocol extension that uses this profile, the datatype MUST be an XML Schema 'date'. If there are differences between the description in this document and those in XML Schema, the latter overrule.</p>
<examplecaption='The date of American independence'>
1776-07-04
</example>
</section2>
<section2topic='DateTime'>
<p>The DateTime profile is used to specify a non-recurring moment in time to an accuracy of seconds (or, optionally, fractions of a second). The format is as follows:</p>
<p>The Time Zone Definition is mandatory and MUST be either UTC (denoted by addition of the character 'Z' to the end of the string) or some offset from UTC (denoted by addition of '[+|-]' and 'hh:mm' to the end of the string). The fractions of a second are optional and MAY be ignored if included (although an XMPP protocol extension using the DateTime profile MAY require the fractions of a second).</p>
<p>This profile is equivalent to the 'dateTime' datatype defined in XML Schema <note>The 'dateTime' datatype is defined at <<linkurl='http://www.w3.org/TR/xmlschema11-2/#dateTime'>http://www.w3.org/TR/xmlschema11-2/#dateTime</link>>.</note>. When an XML schema is used to define a Jabber protocol that uses this profile, the datatype MUST be an XML Schema 'dateTime'. If there are differences between the description in this document and those in XML Schema, the latter overrule.</p>
<p>The Time Zone Definition is optional; if included, it MUST be either UTC (denoted by addition of the character 'Z' to the end of the string) or some offset from UTC (denoted by addition of '[+|-]' <note>Inclusion of the '+' character means that the time in that zone is ahead of UTC; e.g., a Time Zone Definition of "+07:00" means that if the UTC time is 12:00 then the local time is 19:00 (typically this is true of an area that is east of 0° degrees latitude and west of 180° latitude, such as Bangkok, Thailand). Inclusion of the '-' character means that the time in that zone is behind UTC; e.g., a Time Zone Definition of "-07:00" means that if the UTC time is 12:00 then the local time is 05:00 (typically this is true of an area that is west of 0° degrees latitude and east of 180° latitude, such as Denver, Colorado, USA).</note> and 'hh:mm' to the end of the string). The fractions of a second are optional and MAY be ignored if included (although a Jabber protocol using the DateTime profile MAY require the fractions of a second).</p>
<p>This profile is equivalent to the 'time' datatype defined in XML Schema <note>The 'time' datatype is defined at <<linkurl='http://www.w3.org/TR/xmlschema11-2/#time'>http://www.w3.org/TR/xmlschema11-2/#time</link>>.</note>. When an XML schema is used to define a Jabber protocol that uses this profile, the datatype MUST be an XML Schema 'time'. If there are differences between the description in this document and those in XML Schema, the latter overrule.</p>
<p>Some existing Jabber protocols use a different lexical representation for datetimes than the representation defined in XML Schema and specified by this document. These are &xep0090; (superseded by &xep0202;), &xep0091; (superseded by &xep0203;), and &xep0009;. (The representation of dates in &xep0054; matches that specified herein.) These older protocols represent datetimes as follows:</p>
<p>The primary standard notation recommended by ISO 8601 includes the separators ("-" for dates and ":" for times), although ISO 8601 allows omission of the separators for applications in which compactness is more important than human readability. It is arguable whether Jabber applications using 'jabber:iq:time' and 'jabber:x:delay' require such compactness, but these protocols are in wide use today and have been implemented using the format shown above. Therefore, applications receiving data in those namespaces SHOULD be liberal in what they accept by handling datetimes either in the "CCYYMMDDThh:mm:ss" format or in the lexical representation defined in XML Schema and specified by this document. Applications generating data in those namespaces SHOULD use the existing format ("CCYYMMDDThh:mm:ss"), and are effectively "grandfathered" with respect to the date and time formats defined herein. While eventually it would be good to deprecate the older datetime representation for these protocols, the schedule for such deprecation (if any) shall be specified in official XEPs for these older protocols.</p>
<p>Jabber-RPC is a special case, since the specification for &xmlrpc; includes only one example for datetimes, which is of the format "CCYYMMDDThh:mm:ss". Apparently many implementations of XML-RPC have taken this lexical representation as canonical, and do not support any other representation; because Jabber-RPC normally provides an interface to software that is outside the Jabber network, it is prudent for Jabber-RPC implementations to generate dates in the format shown in the XML-RPC specification, not that defined in this document.</p>
<p>The 'date', 'dateTime', and 'time' datatypes defined in XML Schema address several "edge cases" such as dates before the year 0000 and after the year 9999, as well as odd timezones no longer in use; most Jabber applications can safely ignore these edge cases, since it is highly unlikely that a Jabber entity will generate such representations.</p>
<p>The timezone specifier of a ISO 8601 encoded time can reveal a geographic location to some degree, if it's set to the local time of a user, and thus concerns users' privcacy. To avoid this issue developers are advised to convert local time to UTC before sending ISO 8601 encoded times into the XMPP network.</p>