<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>XMPP Date and Time Profiles</title>
  <abstract>This document specifies a standardization of ISO 8601 profiles and their lexical representation for use in XMPP protocol extensions.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0082</number>
  <status>Active</status>
  <type>Informational</type>
  <sig>Standards</sig>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>ISO 8601</spec>
    <spec>XML Schema Part 2</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>N/A</shortname>
  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  
  <author>
    <firstname>Tobias</firstname>
    <surname>Markmann</surname>
    <email>tobias.markmann@isode.com</email>
    <jid>tm@ayena.de</jid>
  </author>

  <revision>
    <version>1.1.1</version>
    <date>2021-08-31</date>
    <initials>@Yquas</initials>
    <remark><p>Fix typos</p></remark>
  </revision>
  <revision>
    <version>1.1</version>
    <date>2013-09-26</date>
    <initials>tm</initials>
    <remark>Added security notice about possible privacy concerns.</remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2003-05-28</date>
    <initials>psa</initials>
    <remark>Per a vote of the Jabber Council, advanced status to Active.</remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2003-05-22</date>
    <initials>psa</initials>
    <remark>Added examples; added section on migration.</remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2003-05-19</date>
    <initials>psa</initials>
    <remark>Adjusted wording regarding several XML Schema references; added implementation notes.</remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2003-05-16</date>
    <initials>psa</initials>
    <remark>Updated to refer to XML Schema datatypes; removed "Precise Datetime" profile; added "Time" profile for recurring events.</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2003-05-08</date>
    <initials>psa</initials>
    <remark>Clarified registration format, deleted references to undocumented protocols, removed implementation notes.</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2003-04-28</date>
    <initials>psa</initials>
    <remark>Added "Precise Datetime" profile.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2003-04-21</date>
    <initials>psa</initials>
    <remark>Initial version.</remark>
  </revision>
</header>
<section1 topic="Introduction">
  <p>A number of XMPP protocol extensions specify that dates and times should follow the format defined in <span class="ref"><link url="http://www.cl.cam.ac.uk/~mgk25/iso-time.html">ISO 8601</link></span> <note>ISO 8601: Representation of Dates and Times (2000). This specification is not freely available; however, a good summary is located at &lt;<link url="http://www.cl.cam.ac.uk/~mgk25/iso-time.html">http://www.cl.cam.ac.uk/~mgk25/iso-time.html</link>&gt;.</note>. 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 (<link url="http://www.ietf.org/rfc/rfc3339.txt">http://www.ietf.org/rfc/rfc3339.txt</link>) and a W3C Note (<link url="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 <span class="ref"><link url="http://www.w3.org/TR/xmlschema11-2/">XML Schema Part 2</link></span> <note>XML Schema Part 2: Datatypes &lt;<link url="http://www.w3.org/TR/xmlschema11-2/">http://www.w3.org/TR/xmlschema11-2/</link>&gt;.</note>.</p>
</section1>
<section1 topic="Terminology">
  <section2 topic="Time Terms">
    <p>The following acronyms and characters are used herein to represent time-related concepts:</p>
    <table caption="Acronyms and Characters">
      <tr><th>Term</th><th>Definition</th></tr>
      <tr><td>CCYY</td><td>four-digit year portion of Date <note>According to the XML schema datatypes specification &lt;<link url="http://www.w3.org/TR/xmlschema11-2/#dateTime">http://www.w3.org/TR/xmlschema11-2/#dateTime</link>&gt;, 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>
      <tr><td>MM</td><td>two-digit month portion of Date</td></tr>
      <tr><td>DD</td><td>two-digit day portion of Date</td></tr>
      <tr><td>-</td><td>ISO 8601 separator among Date portions</td></tr>
      <tr><td>T</td><td>ISO 8601 separator between Date and Time</td></tr>
      <tr><td>hh</td><td>two-digit hour portion of Time (00 through 23)</td></tr>
      <tr><td>mm</td><td>two-digit minutes portion of Time (00 through 59)</td></tr>
      <tr><td>ss</td><td>two-digit seconds portion of Time (00 through 59)</td></tr>
      <tr><td>:</td><td>ISO 8601 separator among Time portions</td></tr>
      <tr><td>.</td><td>ISO 8601 separator between seconds and milliseconds</td></tr>
      <tr><td>sss</td><td>fractional second addendum to Time (MAY contain any number of digits)</td></tr>
      <tr><td>TZD</td><td>Time Zone Definition (either "Z" for UTC or "(+|-)hh:mm" for a specific time zone)</td></tr>
    </table>
  </section2>
</section1>
<section1 topic="Profiles">
   <p>Three profiles are defined herein.</p>
   <section2 topic="Date">
     <p>The Date profile defines a date without including the time of day. The lexical representation is as follows:</p>
     <code>
     CCYY-MM-DD
     </code>
     <p>This profile is equivalent to the 'date' datatype defined in XML Schema <note>The 'date' datatype is defined at &lt;<link url="http://www.w3.org/TR/xmlschema11-2/#date">http://www.w3.org/TR/xmlschema11-2/#date</link>&gt;.</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>
     <example caption="The date of American independence">
     1776-07-04
     </example>
   </section2>
   <section2 topic="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>
     <code>
     CCYY-MM-DDThh:mm:ss[.sss]TZD
     </code>
     <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 &lt;<link url="http://www.w3.org/TR/xmlschema11-2/#dateTime">http://www.w3.org/TR/xmlschema11-2/#dateTime</link>&gt;.</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>
     <example caption="Datetime of the first human steps on the Moon (UTC)">
     1969-07-21T02:56:15Z
     </example>
     <example caption="Datetime of the first human steps on the Moon (Houston time)">
     1969-07-20T21:56:15-05:00
     </example>
   </section2>
   <section2 topic="Time">
     <p>The Time profile is used to specify an instant of time that recurs (e.g., every day). The lexical representation is as follows:</p>
     <code>
     hh:mm:ss[.sss][TZD]
     </code>
     <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 &lt;<link url="http://www.w3.org/TR/xmlschema11-2/#time">http://www.w3.org/TR/xmlschema11-2/#time</link>&gt;.</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>
     <example caption="Time for tea">
     16:00:00
     </example>
   </section2>
</section1>
<section1 topic="Migration">
  <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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0090.html">Legacy Entity Time (XEP-0090)</link></span> <note>XEP-0090: Legacy Entity Time &lt;<link url="https://xmpp.org/extensions/xep-0090.html">https://xmpp.org/extensions/xep-0090.html</link>&gt;.</note> (superseded by <span class="ref"><link url="https://xmpp.org/extensions/xep-0202.html">Entity Time (XEP-0202)</link></span> <note>XEP-0202: Entity Time &lt;<link url="https://xmpp.org/extensions/xep-0202.html">https://xmpp.org/extensions/xep-0202.html</link>&gt;.</note>), <span class="ref"><link url="https://xmpp.org/extensions/xep-0091.html">Legacy Delayed Delivery (XEP-0091)</link></span> <note>XEP-0091: Legacy Delayed Delivery &lt;<link url="https://xmpp.org/extensions/xep-0091.html">https://xmpp.org/extensions/xep-0091.html</link>&gt;.</note> (superseded by <span class="ref"><link url="https://xmpp.org/extensions/xep-0203.html">Delayed Delivery (XEP-0203)</link></span> <note>XEP-0203: Delayed Delivery &lt;<link url="https://xmpp.org/extensions/xep-0203.html">https://xmpp.org/extensions/xep-0203.html</link>&gt;.</note>), and <span class="ref"><link url="https://xmpp.org/extensions/xep-0009.html">Jabber-RPC (XEP-0009)</link></span> <note>XEP-0009: Jabber-RPC &lt;<link url="https://xmpp.org/extensions/xep-0009.html">https://xmpp.org/extensions/xep-0009.html</link>&gt;.</note>. (The representation of dates in <span class="ref"><link url="https://xmpp.org/extensions/xep-0054.html">vcard-temp (XEP-0054)</link></span> <note>XEP-0054: vcard-temp &lt;<link url="https://xmpp.org/extensions/xep-0054.html">https://xmpp.org/extensions/xep-0054.html</link>&gt;.</note> matches that specified herein.) These older protocols represent datetimes as follows:</p>
  <code>
  CCYYMMDDThh:mm:ss
  </code>
  <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 <span class="ref"><link url="http://www.xmlrpc.com/spec">XML-RPC</link></span> <note>XML-RPC &lt;<link url="http://www.xmlrpc.com/spec">http://www.xmlrpc.com/spec</link>&gt;.</note> 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>New protocols approved by the XMPP Standards Foundation MUST use the lexical representations defined in this document.</p>
</section1>
<section1 topic="Implementation Notes">
  <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>
</section1>
<section1 topic="Security Considerations">
  <p>The timezone specifier of an 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' privacy. To avoid this issue developers are advised to convert local time to UTC before sending ISO 8601 encoded times into the XMPP network.</p>
</section1>
<section1 topic="IANA Considerations">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>This document requires no interaction with the <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note>.</p>
</section1>
<section1 topic="Acknowledgements" anchor="acks">
  <p>Thanks to Matt Miller for his feedback.</p>
</section1>
</xep>
