datetime-design-pattern: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(Mentioned Problems with Optional TIME stamps)
(rm hardcoded IRC server in prose)
 
(162 intermediate revisions by 42 users not shown)
Line 1: Line 1:
'''This page is a draft.'''
{{DISPLAYTITLE: Datetime Design Pattern }}
Use the [[HTML5]] time element for all use-cases that the Datetime Design Pattern was created for, thus use <time> instead of <abbr>, e.g.
<source lang=xml>
<time datetime="2012-08-26 20:09-0700">
  8:09pm on August 26th, 2012
</time>
</source>
<div class="usermessage">
If you cannot use the <code>&lt;time&gt;</code> element (e.g. if you're stuck with an old XHTML1 CMS), use the [[value-class-pattern#Date_and_time_values|value class pattern for dates and times]].


This is a page for exploring a datetime design pattern.
The abbr use for datetimes in particular has been dropped due to [[#accessibility_issues | accessibility issues]].
</div>


The pattern which is now used in [[hcalendar|hCalendar]] and [[hreview|hReview]] is something like this:
= Historical Archive =
The remainder of this page is kept as a historical archive.


<pre>&lt;abbr class="foo" title="YYYYMMDDTHH:MM:SS+ZZZZ"&gt;Date Time&lt;/abbr&gt;</pre>
The abbr datetime-design-pattern has been dropped.


where foo is the semantic classname which is being applied to this date/time, the title of the &lt;abbr&gt; is an ISO 8601 date/time and "Date Time" is a human-friendly representation of the same date/time.
== Purpose ==
* Use the [[value-class-pattern]] for datetimes for better accessibility.
* Deprecated: The [[datetime-design-pattern]] was used to make datetimes that are human readable also formally machine readable.
 
== Practical Need ==
* This design pattern arose as a result of solving the practical need for human readable dates and times for [[hcalendar|hCalendar]].
 
== How to use it ==
* enclose the human-friendly datetime that you want to make machine readable with <code>&lt;abbr></code>
* as per the [[class-design-pattern]], add the appropriate <code>class</code> attribute to the <code>abbr</code> element
* add a <code>title</code> attribute to the <code>abbr</code> element with the machine readable [[iso-8601|ISO8601]] datetime or date as the value
 
For ISO8601 datetimes, use the [[value-class-pattern]] instead for better accessibility.
 
==Current uses==
The pattern, which is now available as part of [[hAtom]], [[hcalendar|hCalendar]], [[hcard|hCard]] and [[hreview|hReview]], is:
 
:<pre>&lt;abbr class="foo" title="YYYY-MM-DDTHH:MM:SS+ZZ:ZZ"&gt;Date Time&lt;/abbr&gt;</pre>
 
where "foo" is the semantic classname which is being applied to this date/time, the title of the &lt;abbr&gt; is an ISO 8601 date/time, with an appropriate level of specificity, and "Date Time" is a human-friendly representation of the same date/time.
 
An alternative, if you are using UTC-based timestamps, would be:
 
:<pre>&lt;abbr class="foo" title="YYYY-MM-DDTHH:MM:SSZ"&gt;Date Time&lt;/abbr&gt;</pre>
 
with a single "Z" as per [[iso-8601|ISO 8601]]
 
<strong>Note:</strong> title strings of the form "YYYY-MM-DDTHH:MM:SSZ" may be challenging for humans to read and or understand, thus, use the [[value-class-pattern]] for datetimes.
 
=== Ruby ===
Ruby: An easy way to get this format from a DateTime is this:
:<pre>DateTime.now.to_s</pre>
 
Or alternately, if you're working with Time objects:
<pre>require 'time'
Time.now.iso8601</pre>
 
== Profile of ISO8601 ==
Any [[microformat]] using the date-time-design pattern {{should}} use a profile of [[iso-8601|ISO8601]]. There are currently two widely used profiles which {{should}} be reused.
 
* RFC 3339
* [http://www.w3.org/TR/NOTE-datetime W3C Note on Datetimes]
 
== accessibility issues==
Note: Some [[accessibility-issues]] have been raised with Datetime Design Pattern, that have been addressed with the completion of the [[value-class-pattern]].
 
Note also that the accessibility concerns are considerably lessened, even eliminated when using the [[date-design-pattern]], a subset of the [[datetime-design-pattern]].
 
== Discussion ==
<strong>This section need significant gardening, and perhaps archiving of discussions which are primarily historic, as the [[value-class-pattern]] serves to solve much of the issues raised here. [[User:Tantek|Tantek]] </strong>
 
----
 
What is the relationship of this pattern to the new <nowiki><time></nowiki> element?  Should this pattern specify additionally that IF the element is a time element AND the element has a "datetime" attribute that the value should be taken from that attribute, otherwise fall back to value-class-pattern, otherwise fall further back to abbr-design-pattern? [[User:Singpolyma|Singpolyma]] 15:22, 5 February 2010 (UTC)
 
----


This pattern is likely to be highly resuable.
This pattern is likely to be highly resuable.


--[[RyanKing]]
--[[User:RyanKing]]


Can this not be viewed as a microformat in itself?
Can this not be viewed as a microformat in itself?


--[[DimitriGlazkov]]
--[[User:DimitriGlazkov]]


It could, but inventing a microformat for the sake of inventing a microformat is against the microformat principles.
It could, but inventing a microformat for the sake of inventing a microformat is against the microformat principles.
Line 29: Line 94:
Aug 18 15:16:14 <Tantek> DanC, what do you think of RFC3339?
Aug 18 15:16:14 <Tantek> DanC, what do you think of RFC3339?
Aug 18 15:17:14 <Tantek> ISO8601 subset
Aug 18 15:17:14 <Tantek> ISO8601 subset
Aug 18 15:17:19 <DanC> Date and Time on the Internet: Timestamps http://www.ietf.org/rfc/rfc3339.txt
Aug 18 15:17:19 <DanC>         Date and Time on the Internet: Timestamps http://www.ietf.org/rfc/rfc3339.txt
Aug 18 15:17:30 <DanC> Klyne is a good guy. I wonder if I talked with him about this.
Aug 18 15:17:30 <DanC>         Klyne is a good guy. I wonder if I talked with him about this.
Aug 18 15:17:32 <Tantek> compat with W3C-NOTE-DATETIME
Aug 18 15:17:32 <Tantek> compat with W3C-NOTE-DATETIME
Aug 18 15:17:50 <Tantek> compat with xsd:dateTime
Aug 18 15:17:50 <Tantek> compat with xsd:dateTime
Aug 18 15:17:57 <Tantek> it's a strict intersection subset
Aug 18 15:17:57 <Tantek> it's a strict intersection subset
Aug 18 15:17:59 <DanC> I consider W3C-NOTE-DATETIME obsoleted by XML Schema datatype-- yeah.. xsd:dateTime
Aug 18 15:17:59 <DanC>         I consider W3C-NOTE-DATETIME obsoleted by XML Schema datatype-- yeah.. xsd:dateTime
Aug 18 15:18:32 <Tantek> compare/contrast normatively using xsd:dateTime vs. RFC3339
Aug 18 15:18:32 <Tantek> compare/contrast normatively using xsd:dateTime vs. RFC3339
Aug 18 15:18:41 <Tantek> note: Atom 1.0 chose RFC3339
Aug 18 15:18:41 <Tantek> note: Atom 1.0 chose RFC3339
Aug 18 15:18:50 <Tantek> i would like input from the microformats community on this
Aug 18 15:18:50 <Tantek> i would like input from the microformats community on this
Aug 18 15:19:27 <DanC> in what context are you evaluating RFC 3339?
Aug 18 15:19:27 <DanC>         in what context are you evaluating RFC 3339?
Aug 18 15:19:28 <jcgregorio> http://bitworking.org/news/Date_Constructs_in_the_Atom_Syndication_Format
Aug 18 15:19:28 <jcgregorio> http://bitworking.org/news/Date_Constructs_in_the_Atom_Syndication_Format
Aug 18 15:21:24 <DanC> which microformat is the question coming from, Tantek ?
Aug 18 15:21:24 <DanC>         which microformat is the question coming from, Tantek ?
Aug 18 15:23:31 <DanC> "  The grammar element time-second may have the value "60" at the end of
Aug 18 15:23:31 <DanC>         "  The grammar element time-second may have the value "60" at the end of
Aug 18 15:23:31 <DanC>   months in which a leap second occurs" The XML Schema WG is in the 27th level of leap-second-hell for the past few months, I gather.
Aug 18 15:23:31 <DanC>         months in which a leap second occurs" The XML Schema WG is in the 27th level of
Aug 18 15:24:21 <DanC> yeah... here's the scary bit: "  Leap seconds cannot be predicted far into the future.  The
                                leap-second-hell for the past few months, I gather.
Aug 18 15:24:21 <DanC>   International Earth Rotation Service publishes bulletins [IERS] that
Aug 18 15:24:21 <DanC>         yeah... here's the scary bit: "  Leap seconds cannot be predicted far into the
Aug 18 15:24:21 <DanC>   announce leap seconds with a few weeks' warning."
                                future.  The
Aug 18 15:24:21 <DanC>         International Earth Rotation Service publishes bulletins [IERS] that
Aug 18 15:24:21 <DanC>         announce leap seconds with a few weeks' warning."
Aug 18 15:26:03 <Tantek> DanC, which microformats? any/all that use datetime fields.
Aug 18 15:26:03 <Tantek> DanC, which microformats? any/all that use datetime fields.
Aug 18 15:26:36 <DanC> hard to give useful advice, then.
Aug 18 15:26:36 <DanC>         hard to give useful advice, then.
Aug 18 15:26:58 <DanC> I expect they'll use datetime fields for different things that have different cost/benefit trade-offs
Aug 18 15:26:58 <DanC>         I expect they'll use datetime fields for different things that have different
Aug 18 15:27:26 <DanC> do you know of any particular differences that matter to anybody?
                                cost/benefit trade-offs
Aug 18 15:27:26 <DanC>         do you know of any particular differences that matter to anybody?
Aug 18 15:56:43 <KragenSitaker> RFC3339 suggests -07:00, which seems like an improvement over -0700 anyway
Aug 18 15:56:43 <KragenSitaker> RFC3339 suggests -07:00, which seems like an improvement over -0700 anyway
Aug 18 15:56:49 <Tantek> Kragen, agreed
Aug 18 15:56:49 <Tantek> Kragen, agreed
Aug 18 15:57:01 <Tantek> RFC3339 is certainly preferable to the ISO8601 subset in iCalendar
Aug 18 15:57:01 <Tantek> RFC3339 is certainly preferable to the ISO8601 subset in iCalendar
Aug 18 16:05:57 <DanC> Tantek's right, Kragen; iCalendar looks like it solves the local timezone problem but doesn't.
Aug 18 16:05:57 <DanC>         Tantek's right, Kragen; iCalendar looks like it solves the local timezone
Aug 18 16:06:14 <DanC> and it's true that there's no standard solution to the local timezone problem
                                problem but doesn't.
Aug 18 16:06:39 <Tantek> so instead of appearing to solve the problem but not solving it, we chose to provide the ability to *approximate* the local timezone using e.g. "-07:00"
Aug 18 16:06:14 <DanC>         and it's true that there's no standard solution to the local timezone problem
Aug 18 16:06:49 <DanC> the simplest thing is to have people use Z time in hCalendar. But I gather that's unacceptably unusable?
Aug 18 16:06:39 <Tantek> so instead of appearing to solve the problem but not solving it, we chose to
                                provide the ability to *approximate* the local timezone using e.g. "-07:00"
Aug 18 16:06:49 <DanC>         the simplest thing is to have people use Z time in hCalendar. But I gather
                                that's unacceptably unusable?
Aug 18 16:07:35 <Tantek> DanC, yes, the simplest thing is to have everyone use UTC Z
Aug 18 16:07:35 <Tantek> DanC, yes, the simplest thing is to have everyone use UTC Z
Aug 18 16:07:38 <Tantek> However
Aug 18 16:07:38 <Tantek> However
Line 64: Line 135:
Aug 18 16:08:12 <Tantek> some degree of human verifiability is important here
Aug 18 16:08:12 <Tantek> some degree of human verifiability is important here
Aug 18 16:14:21 <Tantek> DanC, my perception is that RFC3339 is a subset
Aug 18 16:14:21 <Tantek> DanC, my perception is that RFC3339 is a subset
Aug 18 16:17:00 <DanC>   time-numoffset  = ("+" / "-") time-hour ":" time-minute
Aug 18 16:17:00 <DanC>         time-numoffset  = ("+" / "-") time-hour ":" time-minute
Aug 18 16:17:34 <DanC> ok, then I can't see any differences. (modulo recent leap seconds issues that may affect xsd:dateTime )
Aug 18 16:17:34 <DanC>         ok, then I can't see any differences. (modulo recent leap seconds issues that
                                may affect xsd:dateTime )
Aug 18 16:18:07 <Tantek> would be interesting to know why Atom 1.0 chose RFC3339 over xsd:dateTime
Aug 18 16:18:07 <Tantek> would be interesting to know why Atom 1.0 chose RFC3339 over xsd:dateTime
Aug 18 16:18:21 <Tantek> if there was a "real" reason or if it was arbitrary / coin-flip.
Aug 18 16:18:21 <Tantek> if there was a "real" reason or if it was arbitrary / coin-flip.
</pre>
Here's an exhaustive [http://www.imc.org/atom-syntax/mail-archive/msg13103.html comparison] from ndw. I think xsd:dateTime also allows unqualified local times, while RFC3339 allows only UTC with no known timezone (-00:00). In the end, Atompub followed the advice of [http://www.imc.org/atom-syntax/mail-archive/msg13244.html Sam Ruby] and [http://www.imc.org/atom-syntax/mail-archive/msg13248.html Scott Hollenbeck], our area director. Atom dates make some additional restrictions on RFC3339, such as uppercase T and Z characters for compatibility with xsd:dateTime, RFC3339, W3C-DTF, and ISO8601. --[http://franklinmint.fm Robert Sayre]
<pre>
Aug 18 16:18:43 <KragenSitaker> rfc3339 is pretty short.
Aug 18 16:18:43 <KragenSitaker> rfc3339 is pretty short.
Aug 18 16:19:36 <Tantek> DanC, BTW, which came first? REC for xsd:dateTime or RFC3339?
Aug 18 16:19:36 <Tantek> DanC, BTW, which came first? REC for xsd:dateTime or RFC3339?
Aug 18 16:19:50 <DanC> RFC3339 is dated July 2002 ...
Aug 18 16:19:50 <DanC>         RFC3339 is dated July 2002 ...
Aug 18 16:19:54 <KragenSitaker> Right --- and you might be able to understand xsd:dateTime without reading all of xml schema, you wouldn't be confident of it
Aug 18 16:19:54 <KragenSitaker> Right --- and you might be able to understand xsd:dateTime without
Aug 18 16:20:25 <DanC> W3C Recommendation 28 October 2004 ... but that's 2nd ed...
                                reading all of xml schema, you wouldn't be confident of it
Aug 18 16:20:47 <DanC> W3C Recommendation 02 May 2001
Aug 18 16:20:25 <DanC>         W3C Recommendation 28 October 2004 ... but that's 2nd ed...
Aug 18 16:22:10 <DanC> I don't see a BNF in http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime ...
Aug 18 16:20:47 <DanC>         W3C Recommendation 02 May 2001
Aug 18 16:22:43 <KragenSitaker> yeah, appendix D of the current xml schema datatypes document seems a little scanty, actually
Aug 18 16:22:10 <DanC>         I don't see a BNF in http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime ...
Aug 18 16:23:28 <DanC> ah... 2nd ed of http://www.w3.org/TR/xmlschema-2/#date is much more explicit about syntax.
Aug 18 16:22:43 <KragenSitaker> yeah, appendix D of the current xml schema datatypes document seems
                                a little scanty, actually
Aug 18 16:23:28 <DanC>         ah... 2nd ed of http://www.w3.org/TR/xmlschema-2/#date is much more
                                explicit about syntax.
Aug 18 16:23:30 <KragenSitaker> it's 1100 words but still doesn't give any examples
Aug 18 16:23:30 <KragenSitaker> it's 1100 words but still doesn't give any examples
Aug 18 16:23:35 <DanC> still, it's given in prose and not BNF
Aug 18 16:23:35 <DanC>         still, it's given in prose and not BNF
Aug 18 16:24:17 <KragenSitaker> sections 3.2.9 through 3.2.14 seem to be the relevant ones around #date
Aug 18 16:24:17 <KragenSitaker> sections 3.2.9 through 3.2.14 seem to be the relevant ones around #date
Aug 18 16:24:29 <KragenSitaker> which is another 2200 words
Aug 18 16:24:29 <KragenSitaker> which is another 2200 words
Aug 18 16:24:42 <DanC> wow... they changed the canonical form of date from always-Z to timezone-allowed between 1st edition and 2nd edition
Aug 18 16:24:42 <DanC>         wow... they changed the canonical form of date from always-Z to
                                timezone-allowed between 1st edition and 2nd edition
Aug 18 16:25:01 <Tantek> Kragen, DanC, these are very good analyses
Aug 18 16:25:01 <Tantek> Kragen, DanC, these are very good analyses
Aug 18 16:25:21 <Tantek> could I ask you to summarize the pros/cons for each in a new section at end of http://microformats.org/wiki/datetime-design-pattern
Aug 18 16:25:21 <Tantek> could I ask you to summarize the pros/cons for each in a new section at
                                end of http://microformats.org/wiki/datetime-design-pattern
Aug 18 16:25:22 <Tantek> ?
Aug 18 16:25:22 <Tantek> ?
Aug 18 16:25:58 <KragenSitaker> rfc 3339 is 4000 words, excluding the last two pages of boilerplate.
Aug 18 16:25:58 <KragenSitaker> rfc 3339 is 4000 words, excluding the last two pages of boilerplate.
Aug 18 16:26:31 <KragenSitaker> so it's actually longer than the datetime-relevant parts of XSD but it seems much more rigorous and clear
Aug 18 16:26:31 <KragenSitaker> so it's actually longer than the datetime-relevant parts of XSD but it
Aug 18 16:28:37 <DanC> my advice is: normatively cite both, and claim they specify the same syntax, and let anybody who discovers otherwise send you a bug report with a test case
                                seems much more rigorous and clear
Aug 18 16:28:37 <DanC>         my advice is: normatively cite both, and claim they specify the same
                                syntax, and let anybody who discovers otherwise send you a bug report
                                with a test case
Aug 18 16:29:12 <KragenSitaker> danc: nice hack
Aug 18 16:29:12 <KragenSitaker> danc: nice hack
</pre>
</pre>




The RFC3339 has a manditory TIME portion of the DATE-TIME. Some vCard/iCalendar DATE-TIME stamps can omit the TIME. For instance, DTSTART, if that is a full day event, then you can omit the time. BDAY in vCard can be respresented by only a DATE. I like the idea of restricting the possible date formats, but i think that TIME should be optional, which it isn't in RFC3339. - [http://suda.co.uk/ brian suda]
The RFC3339 has a mandatory TIME portion of the DATE-TIME. Some vCard/iCalendar DATE-TIME stamps can omit the TIME. For instance, DTSTART, if that is a full day event, then you can omit the time. BDAY in vCard can be respresented by only a DATE. I like the idea of restricting the possible date formats, but i think that TIME should be optional, which it isn't in RFC3339. - [http://suda.co.uk/ brian suda]
 
RFC 3339 allows lowercase 't' and 'z' while XSD doesn't. Specifying RFC 3339 plus 'T' and 'Z' MUST be caps will make them the same. - [http://bitworking.org Joe Gregorio]
 
---
 
A few questions: asked by [[User:CharlesBelov|CharlesBelov]] 16:57, 24 Apr 2007 (PDT), answered by [[User:JamesCraig|JamesCraig]] on 15:58, 5 Jul 2007 (PDT).
 
# Would it make more sense for documenting the alternative codings pitting the abbr tag vs. other tags to be on this page? ''Answer: That documentation should go on the [[assistive-technology-abbr-results]] page.''
# Would using the title attribute of the abbr tag to encode the machine-readable date in fact cause a failure of WCAG 2.0 Accessibility? What about USA Section 508?  It does appear to violate Technique for WCAG 2.0 [http://www.w3.org/TR/WCAG20-TECHS/#H28 H28: Providing definitions for abbreviations by using the abbr and acronym elements], although that is a supporting document and does not have the force of a guideline. ''Answer: Yes, it appears that is in violation of WCAG, 508, et al, so alternatives are being discussed on the  [[assistive-technology-abbr-results]] page.''
# In order to maintain accessibility, would it make sense to enclose the machine-readable date in a span with a style of "display:none" instead of using the abbr tag? ''Answer: please refer to and add any suggestions to [[assistive-technology-abbr-results]].''
# For that matter, wouldn't you want to style such an abbr tag with text-decoration:none to hide that an abbr tag was used?  Otherwise, visitors might cursor over the  time, see the machine time, and be annoyed that their time was wasted or else be confused.  And I don't think you can suppress the title from coming up if the human-readable time was inadvertently hovered. ''Answer: Microformats should not rely on CSS in order to work properly, but again, that discussion can be found here: [[assistive-technology-abbr-results]].''
 
== Code ==
The following regular expression (parsed VERBOSE) should break apart a datetime and cover many lightly broken cases seen in the wild. This has been tested under Python.
 
<pre><nowiki>
^
(?P<year>\d\d\d\d)
([-])?(?P<month>\d\d)
([-])?(?P<day>\d\d)
(
  (T|\s+)
  (?P<hour>\d\d)
  (
  ([:])?(?P<minute>\d\d)
  (
    ([:])?(?P<second>\d\d)
    (
    ([.])?(?P<fraction>\d+)
    )?
  )?
  )?
)?
(
  (?P<tzzulu>Z)
  |
  (?P<tzoffset>[-+])
  (?P<tzhour>\d\d)
  ([:])?(?P<tzminute>\d\d)
)?
$
</nowiki></pre>
 
== Other Proposals ==
'''This section needs a lot of clean-up. Proposals that have been relatively rejected need to be move to another section (or perhaps page), along with succinct summaries as to why they are untenable/infeasible/undesirable.
 
Remaining proposals probably need to be moved to proper brainstorming pages where they can be considered in a broader context.
 
Links to all proposals (whether relatively rejected or tentatively being considered) should be kept in this page for comparison purposes for this use case.
 
[[User:Tantek|Tantek]] 04:50, 4 Sep 2008 (PDT)'''
 
=== strtime instructions as class names ===
Proposal by DavidLaban (alsuren on [[IRC]]) on 8 Jun 2008
It might be possible to have a slightly more readable/extensible/elegant format:
<pre><nowiki>
<span class="strtime format:_%d_%B_%Y_" > 16 March 1987 </span>
</nowiki></pre>
Notes:
# Underscores are used to replace whitespace, because otherwise the the formatting string will be split into an unordered set of class attributes by many parsers (thanks go to bogdanlazarsb and gsnedders on irc for explaining this to me).
# Some subset of the placeholders should be chosen from those which are supported by both python http://docs.python.org/lib/module-time.html and php http://uk3.php.net/manual/en/function.strftime.php
# A name for the class should be decided upon. strtime might not be the best name.
# Measures should be taken to avoid the format string accidentally conflicting with other valid classes (In the above example, I have prefixed it with the string "format:")
# It might be sensible (when parsing) to strip excess whitespace from the format string and contents. This is not done in this example.
# Example python code follows.
 
<pre><nowiki>
date = (1987,03,16,0,0,0,0,0,0)
format = " %d %B %Y "
# To encode:
classes = ["strtime"]
encoded_format = "format:" + format.replace(' ', '_')
classes.append(encoded_format)
content = time.strftime(format, birthday)
# ... dump classes and content into your document however you want
 
# To decode (assuming that you have managed to extract class and format from the document already):
if "strtime" in classes:
    possible_formats = [ item for item in classes if item.startswith('format:') ]
    assert len(possible_formats) == 1
    format = possible_formats[0].strip('format:').replace('_', ' ')
    date = time.strptime(content, format)
</nowiki></pre>
 
==== problems with strtime proposal ====
 
# Possible abuse of the class attribute. microformats limit the use of the class attribute to marking up additional semantics about the data, not for (potentially) arbitrary processing/programming instructions
#* HTML 4.01 Recommendation [http://www.w3.org/TR/REC-html40/struct/global.html#adef-class defines] the <code>class</code> attribute as being "for general purpose processing by user agents". [[User:TobyInk|TobyInk]] 13:21, 8 Jun 2008 (PDT)
# Requires authors to think like programmers. The larger problem is that the proposal asks web authors to think like programmers, which severely limits the number of web authors which will be able to use the technique, since the vast majority of web authors are ''not'' programmers and have never heard of "strtime", whereas most authors (even people) on the web have seen dates like 2005-06-20 and easily understand what they mean.
 
In general, any publishing method that requires the author to think like a programmer is a non-starter. It is a much more of a barrier than simply using ISO8601/RFC3339, and that barrier is a far worse tradeoff than the duplication / DRY violation compromise.
[[User:Tantek|Tantek]] 09:52, 8 Jun 2008 (PDT)
 
* Another problem: if %A/%a/%B/%b are allowed, this raises potential problems with internationalisation. Will parsers be required to understand the names and abbreviations for days and months in potentially hundreds of different languages?  [[User:TobyInk|TobyInk]] 14:09, 8 Jun 2008 (PDT)
 
=== Machine-data in class===
The BBC ([http://microformats.org/discuss/mail/microformats-dev/2008-June/000552.html uf-dev archive, 20/06/08, "Using class for non-human data"]) has proposed as an alternative to the empty span and title solution to use the class name in the following way:
<pre><nowiki>
<span class="dtstart data-20051010T10:10:10-0100">10 o'clock on the 10th</span>
</nowiki></pre>
Pros:
* Allows data to be represented in a "non-harmful" way. Will not be read aloud by screenreaders or seen as tooltips.
* Minimizes mark-up used.
* Arguably more semantic than use of "title" attribute for non-human data.
 
Cons:
* data in the class attribute has already been discussed numerous times in the mailing list over the years and rejected and documented as an [[anti-pattern]] - captured [http://microformats.org/wiki?title=anti-patterns&diff=24271&oldid=24270 on the wiki this past January 2008].
* Possible misuse of class attribute, although as noted previously, the HTML spec states "for general purpose processing by user agents".
* The class attribute has been adopted by the broader web design community to "subclass" element semantics, and to layer additional semantics. To date, microformats has followed this existing practice developed by modern web designers ("paving the cow-paths"). This use of class for data is outside all current practices.
 
Discussion:
* This proposal smells icky, but I can't quite put my finger on why. Considered objectively, it does seem to be the least harmful solution proposed so far. [[User:TobyInk|TobyInk]] 06:06, 21 Jun 2008 (PDT)
* I really like it, especially given the HTML4 spec gives this as an IMO perfectly valid use (on both id and class, with the following examples given in the id section: "identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc."). Clean and simple. [[User:Dracos|Dracos]] 03:53, 23 Jun 2008 (PDT)
* I suggest dropping the redundant 'data-' prefix, unless someone can suggest a feasible case with two time-stamps requiring different prefixes.  The proposal then becomes [http://www.robertnyman.com/2008/04/28/do-we-really-need-microformats/#comment-263408 one I've made before] [[User:AshSearle|AshSearle]]
** Valid class names cannot begin with a number, so a date needs some sort of letter prefix.  It's sensible to make this prefix meaningful and reusable in some way. [[User:Phae|Phae]]
*** They can't in CSS, but they can in (X)HTML. http://examples.tobyinkster.co.uk/numeric-classes.html [[User:TobyInk|TobyInk]] 06:53, 24 Jun 2008 (PDT)
**** Creating classes in HTML that can't be referenced in CSS is a bad thing.  Using colons and starting with numbers fall into that category.  http://www.w3.org/TR/CSS21/syndata.html#characters  Also, replacing whitespace with underscores breaks the ISO compatibility, which sorta defeats the whole point of using existing standards.  Finally the class names are unordered, so trying to use them in a series is a bad idea. --[[User:Atamido|Atamido]] 11:43, 30 Jul 2008 (PDT)
***** They can be referenced in CSS, just not using the "dot notation". They can be referenced using attribute selectors, which are supported in all modern browsers (but not IE6). [[User:TobyInk|TobyInk]] 13:21, 30 Jul 2008 (PDT)
****** They could also be referenced by escaping the characters, but that still excludes >99% of current use cases.  I'd wager that most authors don't even know about the limitations and would run into issues in implementation. --[[User:Atamido|Atamido]] 13:47, 30 Jul 2008 (PDT)
***** I don't think the proposal relies on classes being in any particular order. Even if it did, I don't know of any DOM implementations which do not provide the contents of the class attribute in their original order. [[User:TobyInk|TobyInk]] 13:21, 30 Jul 2008 (PDT)
** Not to advocate too strongly for designing for parsers (generally a bad idea), *but* having a 'data-' prefix on a class name would make identifying data orders of magnitude easier for parsing. Otherwise, how do we know what's data and what's just another class name for some other purpose? [[User:DrewMcLellan|Drew]]
** A 'data-' prefix would help authors tasked with maintaining or reviewing a page to understand the purpose of a class name that may have been applied by another author. The data prefix communicates very simply that the class name is precisely that, data. Therefore the value is less likely to be accidentally removed or changed, making for a more robust design. [[User:DrewMcLellan|Drew]]
*** I concede -  regardless of whether it's valid (X)HTML / CSS - a prefix is needed to distinguish data values from genuine content.  ISO 8601 allows date-time to be as simple as "2004", which could easily be misinterpreted.  e.g. if a CMS outputs product model numbers into the class attribute for some other purpose. --[[User:AshSearle|AshSearle]] 01:42, 25 Jun 2008 (PDT)
*** Using <code>data-</code> as the prefix here is undesirable, as it now conflicts with HTML5's proposed <code>-data</code> prefix on attributes. It's undesirable to set ourselves up for future confusion with our own conflicting specification of ‘a data prefix’. A different prefix should be considered. See: [http://www.w3.org/html/wg/html5/#custom HTML5 Editors Draft: Embedding Custom Non-Visible Data] —[[User:BenWard|BenWard]] 07:34, 16 Jul 2008 (PDT)
* -1 [[User:Tantek|Tantek]]. I'm vehemently opposed to putting data in the class attribute. We ''must'' find better alternatives. We must not go down the path of invisible (dark) (meta)data - IMHO that [[principle]] is inviolable for microformats.
** [[User:JakeArchibald|JakeArchibald]] If you're so opposed, it'd be useful to see some justification.
*** See above cons. Already discussed/rejected many times in the history of microformats discussions. In short, quit wasting time on old ground. Abuses class attribute, or if you prefer, introduces a *new* use of the class attribute, unlike microformats to-date which have simply made use of a well established semantic of the class attribute.  And worst of all, completely violates the visible data [[principle]]. Rejectable on that alone.
**** The fact that something has been discussed and rejected before is not sufficient grounds for dismissing it out of hand once additional research and thinking has taken place. The &lt;abbr> datetime pattern arguably abused the title attribute and introduced a new use of the title attribute. In the example given (<code><nowiki><span class="dtstart data-20051010T10:10:10-0100">10 o'clock on the 10th</span></nowiki></code>), the data is presented as "10 o'clock on the 10th" - very visible. Yes, of course, it's possible to abuse this proposed pattern, and hide the data, but the same can be said of the abbr pattern or even the class pattern given CSS's display:none property. Experience shows that in most cases, people ''won't'' abuse the pattern to hide data, as they actually ''want'' to show the data on their pages. [[User:TobyInk|TobyInk]] 13:52, 24 Jun 2008 (PDT)
***** There has been no new "additional research and thinking" shown yet for data in the class attribute since it was originally proposed years ago, thus, it should be dismissed until that burden of reintroduction is met. [[User:Tantek|Tantek]] 22:05, 24 February 2009 (UTC)
**** It's not an abuse of the class attribute according to the HTML spec. as I read it. Whereas using title for non-human data is (the spec says audio agents may read it aloud, for example). If it's a new use, it's one the writers of HTML4 considered, so it wasn't new to them. [[User:Dracos|Dracos]] 03:38, 25 Jun 2008 (PDT)
** Relevant principles are 'humans first, machines second', and 'visible data is ''better'''.  These are ''preferences'', not inviolable principles.  Besides, the existing datetime spec doesn't adhere to these principles anyway: prioritising humans first, <code><nowiki>let's discuss this at the next meeting</nowiki></code> should be marked up as <code><nowiki>let's discuss this at the <abbr title="28th June 2008 at 3:15pm">next meeting</nowiki></code>.  There's a conflict between human- and machine-readable dates.  It makes more sense to 'hide' the machine-readable data in the only attribute available to us: <code>class</code>.  --[[User:AshSearle|AshSearle]] 03:02, 25 Jun 2008 (PDT)
*** Indeed - by their nature, ''principles'' are ''generalisations'', and while broadly useful, usually have exceptions. After experience, the microformats community is beginning to see some of these. Human vs machine dates is the one gathering the most interest at the moment, largely thanks to <abbr class="help" style="border-bottom:1px dotted" title="the Web Standards Project">WaSP</abbr> and <span class="help" style="border-bottom:1px dotted" title="the BBC">auntie</span>, but I think other properties which will probably emerge as exceptions to the general microformats principles are hReview's <code>type</code> property, and the its namesake subproperty for hCard's <code>tel</code>, <code>email</code> and <code>adr</code> (and <code>label</code>?) properties. [[User:TobyInk|TobyInk]] 12:51, 25 Jun 2008 (PDT)
**** Unless you can provide better principles, it is not reasonable to violate the principles. When principles are in conflict, then one must make reasoned cases for the various possibilities (that uphold one principle but perhaps violate another). [[User:Tantek|Tantek]] 22:05, 24 February 2009 (UTC)
 
==== Experimental Parser Support ====
 
[http://buzzword.org.uk/cognition/ Cognition 0.1 alpha 10] will include experimental support for this pattern, and the [http://srv.buzzword.org.uk Cognition web service] already does. Notes:
* Support is ''opt-in''. Publishers must explicitly request support for the pattern, by including a [[profile-uris|profile URI]] of <code><nowiki>http://purl.org/uF/pattern-data-class/1</nowiki></code> in their document head.
* Support is not limited to date-time properties, but any microformat properties.
* data-X classes must use percent-encoding to encode spaces and other characters not allowed in class names.
* The data-X class must be found on the same element as the microformat property class. That is, you cannot use: <pre><nowiki><span class="dtstart"><span class="data-20051010T10:10:10-0100">10 o'clock</span></span></nowiki></pre>
<ul><li>Multiple data-X classes may occur on the same element. When these are found, the longest string is used. This allows for: <pre><nowiki><span class="dtstart data-2005 data-200510 data-20051010">The 10th</span></nowiki></pre> which may be useful for styling or other non-microformat purposes.</li>
<li>Can be combined with value excerpting. e.g. <pre><nowiki>
<p class="dtstart">
  The concert will be held on
  <span class="value data-20080804">the 4th of August</span>
  starting at
  <span class="value data-T193000">7:30pm precisely</span>.
</p>
</nowiki></pre></li></ul>
 
=== date and time separation using value excerption ===
Moved to [[value-excerption-pattern-brainstorming#date_and_time_separation|value excerption pattern brainstorming]] which is a better way of thinking about this.
 
=== HTML 5 <code>&lt;time></code> Element ===
[http://microformats.org/wiki/hcalendar-issues#html5-time-element See hCalendar issues]
 
=== Plain Old English alternative to ISO date ===
Example (in English):
 
<pre>
<abbr title="January 25th, 2008" class="dtstart" lang="en-us">1/25</abbr>
</pre>
 
<pre>
<span class="dtstart">January 25th, 2008</span>
</pre>
 
If <code>lang="en-us"</code>, the format of the date used in the <code>title</code> attribute must conform to [http://www.ego4u.com/en/cram-up/vocabulary/date/written dates writing rules in American English].
 
Example (in French):
 
<pre>
<abbr title="25 Janvier 2008" class="dtstart" lang="fr">25/1</abbr>
</pre>
 
If <code>lang="fr"</code>, the format of the date used in the <code>title</code> attribute must conform to date writing rules in French.
 
====Benefits====
 
* Human-hearable: should work nicely with screen readers (to be tested).
* Human-readable
* Compliance with semantics of abbr.
* Very easy to use by HTML human authors.
* DRY compliant if HTML human authors are willing to write in correct English
 
==== Disadvantages ====
Most extracted from discussion below.
* huge requirement of knowledge of locale-specific information in implementations
* very high complexity of implementation , perhaps even impossible, due to the knowledge required
* unreliability in general: "Getting it wrong would be worse than not getting it at all! "
* unreliability in mixed locale content
* unreliable according to implementation experience to date (see discussion below)
* authoring drift, NLP arms race. because proposal looks like natural language, authors will try any natural language format.
* widespread implementer objection to NLP based solutions
 
====Discussion====
* Locale-specific parsing logic.
* Not all cultures use the same calendar — Dan Brickley
* There are situations where markup clues used for localisation might be misleading, such as people using microformats in a post on a site they do not themselves run that may even be in a different country. (a shared blogging site that allows html tags in posts would be a good example here) — Michael MD
** Couldn't the person or tool adding the microformat annotation also add a lang attribute at the same time? — Benjamin Hawkes-Lewis
* Cognition already supports this as a last ditch attempt at parsing dates - but I wouldn't recommend it get adopted widely. It's too unreliable; too much work to deal with internationalisation; too much work full-stop in languages that don't provide a handy library that takes care of most of the work. — [[User:TobyInk]]
** I don't think we need to support all locales at once. I don't know in how many written languages BBC publishes in, but it might be that supporting en-uk and en-us might be enough for a start. Also, one can imagine that Microformats tools could focus on the most common written languages and then expose hooks for others to implement support for other locales. — Guillaume Lebleu
** What are our priorities? Making programmers' life easier or making content authors and content readers' life easier? — Guillaume Lebleu
*** In Australia  dd/mm/yyyy is commonly used, but a significant minority of sites in Australia use US-style mm/dd/yyyy because it is the default setting in their CMS. How would a parser be able to tell which part is the day and which is the month? Getting it wrong would be worse than not getting it at all! Until the use of ambiguous formats can be ''wiped out'' we ''will'' need a version for machines! — Michael MD
***  problem which hasn't been raised with regards to this proposal is that even though you are proposing a fixed date format, because it *looks* like natural language, authors will assume that it *is* natural language, and simply start including dates in whatever format they like. Then you get an NLP "arms race" between publishers and parsers. If you don't believe that that will happen, take a look at what happened with RFC 822 dates, which are simply a mess. — [[User:TobyInk]]
**** Very true the more you make the date look like natural language, the less it looks like a fixed format. I really don't want us to get involved in any form of NLP, it just would not work. I think it was Mike who said that dates have to be parsed correctly, no level of error is acceptable. I don't want to travel to an event on the wrong day because a parser got the date wrong — Glenn Jones
 
====Notes====
* Could work alongside with the existing [[datetime-design-pattern]]: if ISO date parsing fails, try parsing the title as a human-readable plain old English/French/... date according to the locale.
 
===<code>&lt;object></code> element to represent dates===
* Re-raised by George Brocklehurst on June 25th 2008.
 
The idea was to do something like this:
 
<pre><code>&lt;object data="20050125">January 25&lt;/object></code></pre>
 
* From what Tantek [http://tantek.com/log/2005/01.html said on his blog] , the main reason for not using objects was that they were not well supported in Safari. However, Safari's object support is now much improved: fallbacks are supported and display:inline and intrinsic sizing will work correctly. Safari 2.0.2, which came out in November 2005, was the first version to [http://webkit.org/blog/32/webkit-fixes-in-safari-202-mac-os-x-1043/ contain these improvements]. — George Brocklehurst
* The following appears to be well behaved inline in Safari 2.04 and 3.1.1, Firefox 1, 1.5, 2 and 3, and Opera 7, 8 and 9: <code>&lt;object class="dtstart" data="data://20080712">&lt;/object></code>. Test case: http://pastie.org/224023 — Ben Ward
** IE 6, 7 and the beta version of IE 8 all visibly render the object element as a small box, similar to the way they would render a missing image: http://georgebrock.com/misc/object-in-ie.png — George Brocklehurst
** Absolute URIs can't start with a number, but relative ones can - and the data attribute is permitted to contain relative URIs. [Don't need to use data:// URI) — Toby A Inkster
* Could also look at <code>&lt;object class="dtstart">&lt;param name="value" value="20050125" />January 25&lt;/object></code> — Scott Reynen
 
==== issues ====
Open issues related to this proposal. Some may require additional information to be acted upon / resolved.
 
* Not providing OBJECT WIDTH and HEIGHT causes the displaying page to flicker;  --[[User:Yecril71pl|Yecril71pl]] 21:56, 24 February 2009 (UTC)
** Please provide specific implementation (maker, name, version number, platform) that cause the displaying page to flickr.
 
* OBJECT boundaries are impermeable to CSS.  --[[User:Yecril71pl|Yecril71pl]] 21:56, 24 February 2009 (UTC)
** Please provide a URL to an example use of OBJECT that demonstrates problems with applying CSS to the contents of the OBJECT (i.e. beyond its boundaries).
 
 
==== resolved issues ====
Issues raised and resolved related to this proposal. Issues that are misconceptions (e.g. easily refuted by citing the HTML4 specification) are resolved by moving to the separate misconceptions section below with explanation/citation for why they are misconceptions.
 
* The purpose of the &lt;object> element is to allow the browser to run an external application for a non-native data type (e.g., Java applet). See:  http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3. Object is not the right way to go in this case. — Sarven Capadisli
** "datetime" *is* a non-native data type, and its common presentation is essentially a lowest common denominator (what's supported) plain text fallback. Better would be for code to recognize and present date and time information to the user in a format they can understand (perhaps adjusting the presentation for the user's locale settings). Object makes sense semantically for representing date and time information, as it is a semantic for embedding arbitrary data. [[User:Tantek|Tantek]] 21:39, 24 February 2009 (UTC)
** note the mention of "external application" may sometimes cause the misconception (i.e. see below) that object MUST be used to run an external application. This is false. Authors may specify the "classid", which implies an implementation, or they may specify the "type" and "data" attributes which the browser may then display natively or use the "type" attribute to find external code to display the data. [[User:Tantek|Tantek]] 21:39, 24 February 2009 (UTC)
 
* Providing OBJECT WIDTH and HEIGHT will break the typographical consistency of running text.  --[[User:Yecril71pl|Yecril71pl]] 21:56, 24 February 2009 (UTC)
** This is a [http://tr.im/strawman Strawman] issue. This proposal never advocated using WIDTH and HEIGHT.
 
* Specifying a DATA attribute causes an unnecessary round-trip to the server.  And what if it succeeds?  --[[User:Yecril71pl|Yecril71pl]] 21:59, 24 February 2009 (UTC)
** This is a [http://tr.im/strawman Strawman] issue. This proposal lacks any examples which use "http:" in the DATA attribute or any other URI scheme which will cause a round-trip to the server.
 
==== misconceptions ====
===== external application only =====
* ''The purpose of the &lt;object> element is to allow the browser to run an external application...'' — Sarven Capadisli
* ''OBJECT elements are for external content, not for arbitrary data;'''  --[[User:Yecril71pl|Yecril71pl]] 21:56, 24 February 2009 (UTC)
 
This is false. From the [http://www.w3.org/TR/html401/struct/objects.html#h-13.3 HTML4.01 section on OBJECT]:
 
<blockquote><p>Still others [other objects] may not require additional implementation information, i.e., the user agent itself may already know how to render that type of data (e.g., GIF images).</p></blockquote>
 
Thus browsers may render OBJECTs themselves, like images, and external applications are not necessarily required. For example IE5/Mac supported native rendering of PNG images even as objects, while other browsers at the time (2000) which supported OBJECT, only rendered PNG images via external plugins.
 
===== need width and height =====
* ''OBJECT elements need WIDTH and HEIGHT''  --[[User:Yecril71pl|Yecril71pl]] 21:56, 24 February 2009 (UTC)
 
This is false. Per the [http://www.w3.org/TR/html401/struct/objects.html#h-13.3 HTML4.01 section on OBJECT], the width and height attributes are "#IMPLIED" not "#REQUIRED".
 
===Individual markup of each date/time component===
'''A variant of this idea has been documented into a [[value-excerption-pattern-brainstorming#details_for_handling_specific_property_types|specific proposal]] and is [[value-excerption-dt-separation-test|being tested]]. Please see the [[value-excerption-pattern-brainstorming#details_for_handling_specific_property_types|value excerption pattern brainstorming: date and type separation]] and [[value-excerption-dt-separation-test]] page for updated details. [[User:Tantek|Tantek]] 22:05, 24 February 2009 (UTC)'''
 
A combination of suggestions that originated from this [http://www.mail-archive.com/microformats-discuss@microformats.org/msg10218.html post]
 
This is suggested as a complementary alternative to datetime-design-pattern, when the use of the pattern is not possible due to accessibility reasons.
 
suggested class names:
* <code>date</code>
* <code>time</code>
* or maybe <code>datetime</code> ?
* <code>s</code> for seconds
* <code>min</code> for minutes
* <code>hr</code> for hours
* <code>ampm</code> for AM/PM
* <code>tz</code> for timezone. (ex. <code>GMT</code>)
* <code>tzo</code> for timezone offset (ex. <code>-7</code>)
* <code>day</code>
* <code>mo</code> for months
* <code>yr</code> for year
 
For a complete datetime:
 
<pre>
<span class="dtstart" lang="en-us">
<span class="date">
<span class="mo">October</span> <span class="day">5</span>, <span class="yr">2004</span>
<span> at
<span class="time">
<span class="hr">6</span><span class="">PM</span>
</span>
</span>
</pre>
 
<code>date</code> maybe not required since <code>dtstart</code> IS a <code>date</code>.
 
For a duration:
 
<pre>
<span class="duration">
    <span class="h">1</span>:
    <span class="min">3</span>:
    <span class="s">42</span>
</span>
</pre>
 
* An example of this is also documented on [[ISO-31-1]]
 
'''Issues'''
* the internationalization issue is not addressed, but it is limited to the month of the year.
* Tonnes and tonnes of nested elements to mark up something that's essentially very simple. Microformats are "for humans first, machines second", but this suggestion appears to be friendly to neither! [[User:TobyInk|TobyInk]] 02:21, 12 Aug 2008 (PDT)
** Also worth pointing out that the complexity issue applies less to durations. With durations, most people will probably only want to use a combination of 1 to 3 time components (e.g. d+h, h+min+s, h+min, min+s, d only, h only, min only, s only) But with datetimes, they're likely to want to specify at least five components (y+m+d+h+min) and often also the timezone (seconds, and fractions thereof, are not especially useful for the majority of use cases). So marking up the time components might be OK for durations, but becomes onerous for datetimes.
 
== See Also ==
 
* [[Main_Page#Design_Patterns|All microformat design patterns]]
* [[abbr-design-pattern]] is used by [[datetime-design-pattern]]
* [[date-design-pattern]] is a subset of [[datetime-design-pattern]]
* HTML 4.01 definition of <code>&lt;[http://www.w3.org/TR/REC-html40/struct/text.html#edef-ABBR abbr]></code> element
* RFC [http://www.faqs.org/rfcs/rfc3339.html 3339]: Date and Time on the Internet: Timestamps
* W3C: [http://www.w3.org/TR/NOTE-datetime Note on Datetimes]
* W3C: [http://www.w3.org/QA/Tips/iso-date Use international date format (ISO) - Quality Web Tips]
* Markus Kuhn: [http://www.cl.cam.ac.uk/~mgk25/iso-time.html A summary of the international standard date and time notation]
* Wikipedia: [http://en.wikipedia.org/wiki/ISO_8601 ISO 8601]

Latest revision as of 19:20, 23 October 2024

Use the HTML5 time element for all use-cases that the Datetime Design Pattern was created for, thus use <time> instead of <abbr>, e.g.

<time datetime="2012-08-26 20:09-0700">
  8:09pm on August 26th, 2012
</time>

If you cannot use the <time> element (e.g. if you're stuck with an old XHTML1 CMS), use the value class pattern for dates and times.

The abbr use for datetimes in particular has been dropped due to accessibility issues.

Historical Archive

The remainder of this page is kept as a historical archive.

The abbr datetime-design-pattern has been dropped.

Purpose

Practical Need

  • This design pattern arose as a result of solving the practical need for human readable dates and times for hCalendar.

How to use it

  • enclose the human-friendly datetime that you want to make machine readable with <abbr>
  • as per the class-design-pattern, add the appropriate class attribute to the abbr element
  • add a title attribute to the abbr element with the machine readable ISO8601 datetime or date as the value

For ISO8601 datetimes, use the value-class-pattern instead for better accessibility.

Current uses

The pattern, which is now available as part of hAtom, hCalendar, hCard and hReview, is:

<abbr class="foo" title="YYYY-MM-DDTHH:MM:SS+ZZ:ZZ">Date Time</abbr>

where "foo" is the semantic classname which is being applied to this date/time, the title of the <abbr> is an ISO 8601 date/time, with an appropriate level of specificity, and "Date Time" is a human-friendly representation of the same date/time.

An alternative, if you are using UTC-based timestamps, would be:

<abbr class="foo" title="YYYY-MM-DDTHH:MM:SSZ">Date Time</abbr>

with a single "Z" as per ISO 8601

Note: title strings of the form "YYYY-MM-DDTHH:MM:SSZ" may be challenging for humans to read and or understand, thus, use the value-class-pattern for datetimes.

Ruby

Ruby: An easy way to get this format from a DateTime is this:

DateTime.now.to_s

Or alternately, if you're working with Time objects:

require 'time'
Time.now.iso8601

Profile of ISO8601

Any microformat using the date-time-design pattern SHOULD use a profile of ISO8601. There are currently two widely used profiles which SHOULD be reused.

accessibility issues

Note: Some accessibility-issues have been raised with Datetime Design Pattern, that have been addressed with the completion of the value-class-pattern.

Note also that the accessibility concerns are considerably lessened, even eliminated when using the date-design-pattern, a subset of the datetime-design-pattern.

Discussion

This section need significant gardening, and perhaps archiving of discussions which are primarily historic, as the value-class-pattern serves to solve much of the issues raised here. Tantek


What is the relationship of this pattern to the new <time> element? Should this pattern specify additionally that IF the element is a time element AND the element has a "datetime" attribute that the value should be taken from that attribute, otherwise fall back to value-class-pattern, otherwise fall further back to abbr-design-pattern? Singpolyma 15:22, 5 February 2010 (UTC)


This pattern is likely to be highly resuable.

--User:RyanKing

Can this not be viewed as a microformat in itself?

--User:DimitriGlazkov

It could, but inventing a microformat for the sake of inventing a microformat is against the microformat principles. If there is a specific real world problem (and uses cases) that such an elemental microformat would solve, then it would be worth considering.

Until then it is best to keep the <abbr> datetime concept merely as a microformat design pattern, to be used in _actual_ microformats that have a demonstrated practical need.

-- Tantek

Excerpt from #microformats Aug 18th. Please edit!

Aug 18 15:16:14 <Tantek>	DanC, what do you think of RFC3339?
Aug 18 15:17:14 <Tantek>	ISO8601 subset
Aug 18 15:17:19 <DanC>	        Date and Time on the Internet: Timestamps http://www.ietf.org/rfc/rfc3339.txt
Aug 18 15:17:30 <DanC>	        Klyne is a good guy. I wonder if I talked with him about this.
Aug 18 15:17:32 <Tantek>	compat with W3C-NOTE-DATETIME
Aug 18 15:17:50 <Tantek>	compat with xsd:dateTime
Aug 18 15:17:57 <Tantek>	it's a strict intersection subset
Aug 18 15:17:59 <DanC>	        I consider W3C-NOTE-DATETIME obsoleted by XML Schema datatype-- yeah.. xsd:dateTime
Aug 18 15:18:32 <Tantek>	compare/contrast normatively using xsd:dateTime vs. RFC3339
Aug 18 15:18:41 <Tantek>	note: Atom 1.0 chose RFC3339
Aug 18 15:18:50 <Tantek>	i would like input from the microformats community on this
Aug 18 15:19:27 <DanC>	        in what context are you evaluating RFC 3339?
Aug 18 15:19:28 <jcgregorio>	http://bitworking.org/news/Date_Constructs_in_the_Atom_Syndication_Format
Aug 18 15:21:24 <DanC>	        which microformat is the question coming from, Tantek ?
Aug 18 15:23:31 <DanC>	        "   The grammar element time-second may have the value "60" at the end of
Aug 18 15:23:31 <DanC>	        months in which a leap second occurs" The XML Schema WG is in the 27th level of
                                leap-second-hell for the past few months, I gather.
Aug 18 15:24:21 <DanC>	        yeah... here's the scary bit: "   Leap seconds cannot be predicted far into the
                                future.  The
Aug 18 15:24:21 <DanC>	        International Earth Rotation Service publishes bulletins [IERS] that
Aug 18 15:24:21 <DanC>	        announce leap seconds with a few weeks' warning."
Aug 18 15:26:03 <Tantek>	DanC, which microformats? any/all that use datetime fields.
Aug 18 15:26:36 <DanC>	        hard to give useful advice, then.
Aug 18 15:26:58 <DanC>	        I expect they'll use datetime fields for different things that have different
                                cost/benefit trade-offs
Aug 18 15:27:26 <DanC>	        do you know of any particular differences that matter to anybody?
Aug 18 15:56:43 <KragenSitaker>	RFC3339 suggests -07:00, which seems like an improvement over -0700 anyway
Aug 18 15:56:49 <Tantek>	Kragen, agreed
Aug 18 15:57:01 <Tantek>	RFC3339 is certainly preferable to the ISO8601 subset in iCalendar
Aug 18 16:05:57 <DanC>	        Tantek's right, Kragen; iCalendar looks like it solves the local timezone
                                problem but doesn't.
Aug 18 16:06:14 <DanC>	        and it's true that there's no standard solution to the local timezone problem
Aug 18 16:06:39 <Tantek>	so instead of appearing to solve the problem but not solving it, we chose to
                                provide the ability to *approximate* the local timezone using e.g. "-07:00"
Aug 18 16:06:49 <DanC>	        the simplest thing is to have people use Z time in hCalendar. But I gather
                                that's unacceptably unusable?
Aug 18 16:07:35 <Tantek>	DanC, yes, the simplest thing is to have everyone use UTC Z
Aug 18 16:07:38 <Tantek>	However
Aug 18 16:07:50 <Tantek>	it is not *nearly* as usuable/verifiable
Aug 18 16:07:55 <Tantek>	as -07:00 etc.
Aug 18 16:08:02 <Tantek>	hence the decision to go with the latter
Aug 18 16:08:12 <Tantek>	some degree of human verifiability is important here
Aug 18 16:14:21 <Tantek>	DanC, my perception is that RFC3339 is a subset
Aug 18 16:17:00 <DanC>	        time-numoffset  = ("+" / "-") time-hour ":" time-minute
Aug 18 16:17:34 <DanC>	        ok, then I can't see any differences. (modulo recent leap seconds issues that
                                may affect xsd:dateTime )
Aug 18 16:18:07 <Tantek>	would be interesting to know why Atom 1.0 chose RFC3339 over xsd:dateTime
Aug 18 16:18:21 <Tantek>	if there was a "real" reason or if it was arbitrary / coin-flip.

Here's an exhaustive comparison from ndw. I think xsd:dateTime also allows unqualified local times, while RFC3339 allows only UTC with no known timezone (-00:00). In the end, Atompub followed the advice of Sam Ruby and Scott Hollenbeck, our area director. Atom dates make some additional restrictions on RFC3339, such as uppercase T and Z characters for compatibility with xsd:dateTime, RFC3339, W3C-DTF, and ISO8601. --Robert Sayre

Aug 18 16:18:43 <KragenSitaker>	rfc3339 is pretty short.
Aug 18 16:19:36 <Tantek>	DanC, BTW, which came first? REC for xsd:dateTime or RFC3339?
Aug 18 16:19:50 <DanC>	        RFC3339 is dated July 2002 ...
Aug 18 16:19:54 <KragenSitaker>	Right --- and you might be able to understand xsd:dateTime without
                                reading all of xml schema, you wouldn't be confident of it
Aug 18 16:20:25 <DanC>	        W3C Recommendation 28 October 2004 ... but that's 2nd ed...
Aug 18 16:20:47 <DanC>	        W3C Recommendation 02 May 2001
Aug 18 16:22:10 <DanC>	        I don't see a BNF in http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime ...
Aug 18 16:22:43 <KragenSitaker>	yeah, appendix D of the current xml schema datatypes document seems
                                a little scanty, actually
Aug 18 16:23:28 <DanC>	        ah... 2nd ed of http://www.w3.org/TR/xmlschema-2/#date is much more
                                explicit about syntax.
Aug 18 16:23:30 <KragenSitaker>	it's 1100 words but still doesn't give any examples
Aug 18 16:23:35 <DanC>	        still, it's given in prose and not BNF
Aug 18 16:24:17 <KragenSitaker>	sections 3.2.9 through 3.2.14 seem to be the relevant ones around #date
Aug 18 16:24:29 <KragenSitaker>	which is another 2200 words
Aug 18 16:24:42 <DanC>	        wow... they changed the canonical form of date from always-Z to
                                timezone-allowed between 1st edition and 2nd edition
Aug 18 16:25:01 <Tantek>	Kragen, DanC, these are very good analyses
Aug 18 16:25:21 <Tantek>	could I ask you to summarize the pros/cons for each in a new section at
                                end of http://microformats.org/wiki/datetime-design-pattern
Aug 18 16:25:22 <Tantek>	?
Aug 18 16:25:58 <KragenSitaker>	rfc 3339 is 4000 words, excluding the last two pages of boilerplate.
Aug 18 16:26:31 <KragenSitaker>	so it's actually longer than the datetime-relevant parts of XSD but it
                                seems much more rigorous and clear
Aug 18 16:28:37 <DanC>	        my advice is: normatively cite both, and claim they specify the same
                                syntax, and let anybody who discovers otherwise send you a bug report
                                with a test case
Aug 18 16:29:12 <KragenSitaker>	danc: nice hack


The RFC3339 has a mandatory TIME portion of the DATE-TIME. Some vCard/iCalendar DATE-TIME stamps can omit the TIME. For instance, DTSTART, if that is a full day event, then you can omit the time. BDAY in vCard can be respresented by only a DATE. I like the idea of restricting the possible date formats, but i think that TIME should be optional, which it isn't in RFC3339. - brian suda

RFC 3339 allows lowercase 't' and 'z' while XSD doesn't. Specifying RFC 3339 plus 'T' and 'Z' MUST be caps will make them the same. - Joe Gregorio

---

A few questions: asked by CharlesBelov 16:57, 24 Apr 2007 (PDT), answered by JamesCraig on 15:58, 5 Jul 2007 (PDT).

  1. Would it make more sense for documenting the alternative codings pitting the abbr tag vs. other tags to be on this page? Answer: That documentation should go on the assistive-technology-abbr-results page.
  2. Would using the title attribute of the abbr tag to encode the machine-readable date in fact cause a failure of WCAG 2.0 Accessibility? What about USA Section 508? It does appear to violate Technique for WCAG 2.0 H28: Providing definitions for abbreviations by using the abbr and acronym elements, although that is a supporting document and does not have the force of a guideline. Answer: Yes, it appears that is in violation of WCAG, 508, et al, so alternatives are being discussed on the assistive-technology-abbr-results page.
  3. In order to maintain accessibility, would it make sense to enclose the machine-readable date in a span with a style of "display:none" instead of using the abbr tag? Answer: please refer to and add any suggestions to assistive-technology-abbr-results.
  4. For that matter, wouldn't you want to style such an abbr tag with text-decoration:none to hide that an abbr tag was used? Otherwise, visitors might cursor over the time, see the machine time, and be annoyed that their time was wasted or else be confused. And I don't think you can suppress the title from coming up if the human-readable time was inadvertently hovered. Answer: Microformats should not rely on CSS in order to work properly, but again, that discussion can be found here: assistive-technology-abbr-results.

Code

The following regular expression (parsed VERBOSE) should break apart a datetime and cover many lightly broken cases seen in the wild. This has been tested under Python.

 ^
 (?P<year>\d\d\d\d)
 ([-])?(?P<month>\d\d)
 ([-])?(?P<day>\d\d)
 (
  (T|\s+)
  (?P<hour>\d\d)
  (
   ([:])?(?P<minute>\d\d)
   (
    ([:])?(?P<second>\d\d)
    (
     ([.])?(?P<fraction>\d+)
    )?
   )?
  )?
 )?
 (
  (?P<tzzulu>Z)
  |
  (?P<tzoffset>[-+])
  (?P<tzhour>\d\d)
  ([:])?(?P<tzminute>\d\d)
 )?
 $

Other Proposals

This section needs a lot of clean-up. Proposals that have been relatively rejected need to be move to another section (or perhaps page), along with succinct summaries as to why they are untenable/infeasible/undesirable.

Remaining proposals probably need to be moved to proper brainstorming pages where they can be considered in a broader context.

Links to all proposals (whether relatively rejected or tentatively being considered) should be kept in this page for comparison purposes for this use case.

Tantek 04:50, 4 Sep 2008 (PDT)

strtime instructions as class names

Proposal by DavidLaban (alsuren on IRC) on 8 Jun 2008 It might be possible to have a slightly more readable/extensible/elegant format:

<span class="strtime format:_%d_%B_%Y_" > 16 March 1987 </span>

Notes:

  1. Underscores are used to replace whitespace, because otherwise the the formatting string will be split into an unordered set of class attributes by many parsers (thanks go to bogdanlazarsb and gsnedders on irc for explaining this to me).
  2. Some subset of the placeholders should be chosen from those which are supported by both python http://docs.python.org/lib/module-time.html and php http://uk3.php.net/manual/en/function.strftime.php
  3. A name for the class should be decided upon. strtime might not be the best name.
  4. Measures should be taken to avoid the format string accidentally conflicting with other valid classes (In the above example, I have prefixed it with the string "format:")
  5. It might be sensible (when parsing) to strip excess whitespace from the format string and contents. This is not done in this example.
  6. Example python code follows.
date = (1987,03,16,0,0,0,0,0,0)
format = " %d %B %Y "
# To encode:
classes = ["strtime"]
encoded_format = "format:" + format.replace(' ', '_')
classes.append(encoded_format)
content = time.strftime(format, birthday)
# ... dump classes and content into your document however you want

# To decode (assuming that you have managed to extract class and format from the document already):
if "strtime" in classes:
    possible_formats = [ item for item in classes if item.startswith('format:') ]
    assert len(possible_formats) == 1
    format = possible_formats[0].strip('format:').replace('_', ' ')
    date = time.strptime(content, format)

problems with strtime proposal

  1. Possible abuse of the class attribute. microformats limit the use of the class attribute to marking up additional semantics about the data, not for (potentially) arbitrary processing/programming instructions
    • HTML 4.01 Recommendation defines the class attribute as being "for general purpose processing by user agents". TobyInk 13:21, 8 Jun 2008 (PDT)
  2. Requires authors to think like programmers. The larger problem is that the proposal asks web authors to think like programmers, which severely limits the number of web authors which will be able to use the technique, since the vast majority of web authors are not programmers and have never heard of "strtime", whereas most authors (even people) on the web have seen dates like 2005-06-20 and easily understand what they mean.

In general, any publishing method that requires the author to think like a programmer is a non-starter. It is a much more of a barrier than simply using ISO8601/RFC3339, and that barrier is a far worse tradeoff than the duplication / DRY violation compromise. Tantek 09:52, 8 Jun 2008 (PDT)

  • Another problem: if %A/%a/%B/%b are allowed, this raises potential problems with internationalisation. Will parsers be required to understand the names and abbreviations for days and months in potentially hundreds of different languages? TobyInk 14:09, 8 Jun 2008 (PDT)

Machine-data in class

The BBC (uf-dev archive, 20/06/08, "Using class for non-human data") has proposed as an alternative to the empty span and title solution to use the class name in the following way:

<span class="dtstart data-20051010T10:10:10-0100">10 o'clock on the 10th</span>

Pros:

  • Allows data to be represented in a "non-harmful" way. Will not be read aloud by screenreaders or seen as tooltips.
  • Minimizes mark-up used.
  • Arguably more semantic than use of "title" attribute for non-human data.

Cons:

  • data in the class attribute has already been discussed numerous times in the mailing list over the years and rejected and documented as an anti-pattern - captured on the wiki this past January 2008.
  • Possible misuse of class attribute, although as noted previously, the HTML spec states "for general purpose processing by user agents".
  • The class attribute has been adopted by the broader web design community to "subclass" element semantics, and to layer additional semantics. To date, microformats has followed this existing practice developed by modern web designers ("paving the cow-paths"). This use of class for data is outside all current practices.

Discussion:

  • This proposal smells icky, but I can't quite put my finger on why. Considered objectively, it does seem to be the least harmful solution proposed so far. TobyInk 06:06, 21 Jun 2008 (PDT)
  • I really like it, especially given the HTML4 spec gives this as an IMO perfectly valid use (on both id and class, with the following examples given in the id section: "identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc."). Clean and simple. Dracos 03:53, 23 Jun 2008 (PDT)
  • I suggest dropping the redundant 'data-' prefix, unless someone can suggest a feasible case with two time-stamps requiring different prefixes. The proposal then becomes one I've made before AshSearle
    • Valid class names cannot begin with a number, so a date needs some sort of letter prefix. It's sensible to make this prefix meaningful and reusable in some way. Phae
      • They can't in CSS, but they can in (X)HTML. http://examples.tobyinkster.co.uk/numeric-classes.html TobyInk 06:53, 24 Jun 2008 (PDT)
        • Creating classes in HTML that can't be referenced in CSS is a bad thing. Using colons and starting with numbers fall into that category. http://www.w3.org/TR/CSS21/syndata.html#characters Also, replacing whitespace with underscores breaks the ISO compatibility, which sorta defeats the whole point of using existing standards. Finally the class names are unordered, so trying to use them in a series is a bad idea. --Atamido 11:43, 30 Jul 2008 (PDT)
          • They can be referenced in CSS, just not using the "dot notation". They can be referenced using attribute selectors, which are supported in all modern browsers (but not IE6). TobyInk 13:21, 30 Jul 2008 (PDT)
            • They could also be referenced by escaping the characters, but that still excludes >99% of current use cases. I'd wager that most authors don't even know about the limitations and would run into issues in implementation. --Atamido 13:47, 30 Jul 2008 (PDT)
          • I don't think the proposal relies on classes being in any particular order. Even if it did, I don't know of any DOM implementations which do not provide the contents of the class attribute in their original order. TobyInk 13:21, 30 Jul 2008 (PDT)
    • Not to advocate too strongly for designing for parsers (generally a bad idea), *but* having a 'data-' prefix on a class name would make identifying data orders of magnitude easier for parsing. Otherwise, how do we know what's data and what's just another class name for some other purpose? Drew
    • A 'data-' prefix would help authors tasked with maintaining or reviewing a page to understand the purpose of a class name that may have been applied by another author. The data prefix communicates very simply that the class name is precisely that, data. Therefore the value is less likely to be accidentally removed or changed, making for a more robust design. Drew
      • I concede - regardless of whether it's valid (X)HTML / CSS - a prefix is needed to distinguish data values from genuine content. ISO 8601 allows date-time to be as simple as "2004", which could easily be misinterpreted. e.g. if a CMS outputs product model numbers into the class attribute for some other purpose. --AshSearle 01:42, 25 Jun 2008 (PDT)
      • Using data- as the prefix here is undesirable, as it now conflicts with HTML5's proposed -data prefix on attributes. It's undesirable to set ourselves up for future confusion with our own conflicting specification of ‘a data prefix’. A different prefix should be considered. See: HTML5 Editors Draft: Embedding Custom Non-Visible DataBenWard 07:34, 16 Jul 2008 (PDT)
  • -1 Tantek. I'm vehemently opposed to putting data in the class attribute. We must find better alternatives. We must not go down the path of invisible (dark) (meta)data - IMHO that principle is inviolable for microformats.
    • JakeArchibald If you're so opposed, it'd be useful to see some justification.
      • See above cons. Already discussed/rejected many times in the history of microformats discussions. In short, quit wasting time on old ground. Abuses class attribute, or if you prefer, introduces a *new* use of the class attribute, unlike microformats to-date which have simply made use of a well established semantic of the class attribute. And worst of all, completely violates the visible data principle. Rejectable on that alone.
        • The fact that something has been discussed and rejected before is not sufficient grounds for dismissing it out of hand once additional research and thinking has taken place. The <abbr> datetime pattern arguably abused the title attribute and introduced a new use of the title attribute. In the example given (<span class="dtstart data-20051010T10:10:10-0100">10 o'clock on the 10th</span>), the data is presented as "10 o'clock on the 10th" - very visible. Yes, of course, it's possible to abuse this proposed pattern, and hide the data, but the same can be said of the abbr pattern or even the class pattern given CSS's display:none property. Experience shows that in most cases, people won't abuse the pattern to hide data, as they actually want to show the data on their pages. TobyInk 13:52, 24 Jun 2008 (PDT)
          • There has been no new "additional research and thinking" shown yet for data in the class attribute since it was originally proposed years ago, thus, it should be dismissed until that burden of reintroduction is met. Tantek 22:05, 24 February 2009 (UTC)
        • It's not an abuse of the class attribute according to the HTML spec. as I read it. Whereas using title for non-human data is (the spec says audio agents may read it aloud, for example). If it's a new use, it's one the writers of HTML4 considered, so it wasn't new to them. Dracos 03:38, 25 Jun 2008 (PDT)
    • Relevant principles are 'humans first, machines second', and 'visible data is better'. These are preferences, not inviolable principles. Besides, the existing datetime spec doesn't adhere to these principles anyway: prioritising humans first, let's discuss this at the next meeting should be marked up as let's discuss this at the <abbr title="28th June 2008 at 3:15pm">next meeting. There's a conflict between human- and machine-readable dates. It makes more sense to 'hide' the machine-readable data in the only attribute available to us: class. --AshSearle 03:02, 25 Jun 2008 (PDT)
      • Indeed - by their nature, principles are generalisations, and while broadly useful, usually have exceptions. After experience, the microformats community is beginning to see some of these. Human vs machine dates is the one gathering the most interest at the moment, largely thanks to WaSP and auntie, but I think other properties which will probably emerge as exceptions to the general microformats principles are hReview's type property, and the its namesake subproperty for hCard's tel, email and adr (and label?) properties. TobyInk 12:51, 25 Jun 2008 (PDT)
        • Unless you can provide better principles, it is not reasonable to violate the principles. When principles are in conflict, then one must make reasoned cases for the various possibilities (that uphold one principle but perhaps violate another). Tantek 22:05, 24 February 2009 (UTC)

Experimental Parser Support

Cognition 0.1 alpha 10 will include experimental support for this pattern, and the Cognition web service already does. Notes:

  • Support is opt-in. Publishers must explicitly request support for the pattern, by including a profile URI of http://purl.org/uF/pattern-data-class/1 in their document head.
  • Support is not limited to date-time properties, but any microformat properties.
  • data-X classes must use percent-encoding to encode spaces and other characters not allowed in class names.
  • The data-X class must be found on the same element as the microformat property class. That is, you cannot use:
    <span class="dtstart"><span class="data-20051010T10:10:10-0100">10 o'clock</span></span>
  • Multiple data-X classes may occur on the same element. When these are found, the longest string is used. This allows for:
    <span class="dtstart data-2005 data-200510 data-20051010">The 10th</span>
    which may be useful for styling or other non-microformat purposes.
  • Can be combined with value excerpting. e.g.
    <p class="dtstart">
      The concert will be held on
      <span class="value data-20080804">the 4th of August</span>
      starting at
      <span class="value data-T193000">7:30pm precisely</span>.
    </p>
    

date and time separation using value excerption

Moved to value excerption pattern brainstorming which is a better way of thinking about this.

HTML 5 <time> Element

See hCalendar issues

Plain Old English alternative to ISO date

Example (in English):

<abbr title="January 25th, 2008" class="dtstart" lang="en-us">1/25</abbr>
<span class="dtstart">January 25th, 2008</span>

If lang="en-us", the format of the date used in the title attribute must conform to dates writing rules in American English.

Example (in French):

<abbr title="25 Janvier 2008" class="dtstart" lang="fr">25/1</abbr>

If lang="fr", the format of the date used in the title attribute must conform to date writing rules in French.

Benefits

  • Human-hearable: should work nicely with screen readers (to be tested).
  • Human-readable
  • Compliance with semantics of abbr.
  • Very easy to use by HTML human authors.
  • DRY compliant if HTML human authors are willing to write in correct English

Disadvantages

Most extracted from discussion below.

  • huge requirement of knowledge of locale-specific information in implementations
  • very high complexity of implementation , perhaps even impossible, due to the knowledge required
  • unreliability in general: "Getting it wrong would be worse than not getting it at all! "
  • unreliability in mixed locale content
  • unreliable according to implementation experience to date (see discussion below)
  • authoring drift, NLP arms race. because proposal looks like natural language, authors will try any natural language format.
  • widespread implementer objection to NLP based solutions

Discussion

  • Locale-specific parsing logic.
  • Not all cultures use the same calendar — Dan Brickley
  • There are situations where markup clues used for localisation might be misleading, such as people using microformats in a post on a site they do not themselves run that may even be in a different country. (a shared blogging site that allows html tags in posts would be a good example here) — Michael MD
    • Couldn't the person or tool adding the microformat annotation also add a lang attribute at the same time? — Benjamin Hawkes-Lewis
  • Cognition already supports this as a last ditch attempt at parsing dates - but I wouldn't recommend it get adopted widely. It's too unreliable; too much work to deal with internationalisation; too much work full-stop in languages that don't provide a handy library that takes care of most of the work. — User:TobyInk
    • I don't think we need to support all locales at once. I don't know in how many written languages BBC publishes in, but it might be that supporting en-uk and en-us might be enough for a start. Also, one can imagine that Microformats tools could focus on the most common written languages and then expose hooks for others to implement support for other locales. — Guillaume Lebleu
    • What are our priorities? Making programmers' life easier or making content authors and content readers' life easier? — Guillaume Lebleu
      • In Australia dd/mm/yyyy is commonly used, but a significant minority of sites in Australia use US-style mm/dd/yyyy because it is the default setting in their CMS. How would a parser be able to tell which part is the day and which is the month? Getting it wrong would be worse than not getting it at all! Until the use of ambiguous formats can be wiped out we will need a version for machines! — Michael MD
      • problem which hasn't been raised with regards to this proposal is that even though you are proposing a fixed date format, because it *looks* like natural language, authors will assume that it *is* natural language, and simply start including dates in whatever format they like. Then you get an NLP "arms race" between publishers and parsers. If you don't believe that that will happen, take a look at what happened with RFC 822 dates, which are simply a mess. — User:TobyInk
        • Very true the more you make the date look like natural language, the less it looks like a fixed format. I really don't want us to get involved in any form of NLP, it just would not work. I think it was Mike who said that dates have to be parsed correctly, no level of error is acceptable. I don't want to travel to an event on the wrong day because a parser got the date wrong — Glenn Jones

Notes

  • Could work alongside with the existing datetime-design-pattern: if ISO date parsing fails, try parsing the title as a human-readable plain old English/French/... date according to the locale.

<object> element to represent dates

  • Re-raised by George Brocklehurst on June 25th 2008.

The idea was to do something like this:

<code><object data="20050125">January 25</object></code>
  • From what Tantek said on his blog , the main reason for not using objects was that they were not well supported in Safari. However, Safari's object support is now much improved: fallbacks are supported and display:inline and intrinsic sizing will work correctly. Safari 2.0.2, which came out in November 2005, was the first version to contain these improvements. — George Brocklehurst
  • The following appears to be well behaved inline in Safari 2.04 and 3.1.1, Firefox 1, 1.5, 2 and 3, and Opera 7, 8 and 9: <object class="dtstart" data="data://20080712"></object>. Test case: http://pastie.org/224023 — Ben Ward
    • IE 6, 7 and the beta version of IE 8 all visibly render the object element as a small box, similar to the way they would render a missing image: object-in-ie.png — George Brocklehurst
    • Absolute URIs can't start with a number, but relative ones can - and the data attribute is permitted to contain relative URIs. [Don't need to use data:// URI) — Toby A Inkster
  • Could also look at <object class="dtstart"><param name="value" value="20050125" />January 25</object> — Scott Reynen

issues

Open issues related to this proposal. Some may require additional information to be acted upon / resolved.

  • Not providing OBJECT WIDTH and HEIGHT causes the displaying page to flicker; --Yecril71pl 21:56, 24 February 2009 (UTC)
    • Please provide specific implementation (maker, name, version number, platform) that cause the displaying page to flickr.
  • OBJECT boundaries are impermeable to CSS. --Yecril71pl 21:56, 24 February 2009 (UTC)
    • Please provide a URL to an example use of OBJECT that demonstrates problems with applying CSS to the contents of the OBJECT (i.e. beyond its boundaries).


resolved issues

Issues raised and resolved related to this proposal. Issues that are misconceptions (e.g. easily refuted by citing the HTML4 specification) are resolved by moving to the separate misconceptions section below with explanation/citation for why they are misconceptions.

  • The purpose of the <object> element is to allow the browser to run an external application for a non-native data type (e.g., Java applet). See: http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3. Object is not the right way to go in this case. — Sarven Capadisli
    • "datetime" *is* a non-native data type, and its common presentation is essentially a lowest common denominator (what's supported) plain text fallback. Better would be for code to recognize and present date and time information to the user in a format they can understand (perhaps adjusting the presentation for the user's locale settings). Object makes sense semantically for representing date and time information, as it is a semantic for embedding arbitrary data. Tantek 21:39, 24 February 2009 (UTC)
    • note the mention of "external application" may sometimes cause the misconception (i.e. see below) that object MUST be used to run an external application. This is false. Authors may specify the "classid", which implies an implementation, or they may specify the "type" and "data" attributes which the browser may then display natively or use the "type" attribute to find external code to display the data. Tantek 21:39, 24 February 2009 (UTC)
  • Providing OBJECT WIDTH and HEIGHT will break the typographical consistency of running text. --Yecril71pl 21:56, 24 February 2009 (UTC)
    • This is a Strawman issue. This proposal never advocated using WIDTH and HEIGHT.
  • Specifying a DATA attribute causes an unnecessary round-trip to the server. And what if it succeeds? --Yecril71pl 21:59, 24 February 2009 (UTC)
    • This is a Strawman issue. This proposal lacks any examples which use "http:" in the DATA attribute or any other URI scheme which will cause a round-trip to the server.

misconceptions

external application only
  • The purpose of the <object> element is to allow the browser to run an external application... — Sarven Capadisli
  • OBJECT elements are for external content, not for arbitrary data;' --Yecril71pl 21:56, 24 February 2009 (UTC)

This is false. From the HTML4.01 section on OBJECT:

Still others [other objects] may not require additional implementation information, i.e., the user agent itself may already know how to render that type of data (e.g., GIF images).

Thus browsers may render OBJECTs themselves, like images, and external applications are not necessarily required. For example IE5/Mac supported native rendering of PNG images even as objects, while other browsers at the time (2000) which supported OBJECT, only rendered PNG images via external plugins.

need width and height
  • OBJECT elements need WIDTH and HEIGHT --Yecril71pl 21:56, 24 February 2009 (UTC)

This is false. Per the HTML4.01 section on OBJECT, the width and height attributes are "#IMPLIED" not "#REQUIRED".

Individual markup of each date/time component

A variant of this idea has been documented into a specific proposal and is being tested. Please see the value excerption pattern brainstorming: date and type separation and value-excerption-dt-separation-test page for updated details. Tantek 22:05, 24 February 2009 (UTC)

A combination of suggestions that originated from this post

This is suggested as a complementary alternative to datetime-design-pattern, when the use of the pattern is not possible due to accessibility reasons.

suggested class names:

  • date
  • time
  • or maybe datetime ?
  • s for seconds
  • min for minutes
  • hr for hours
  • ampm for AM/PM
  • tz for timezone. (ex. GMT)
  • tzo for timezone offset (ex. -7)
  • day
  • mo for months
  • yr for year

For a complete datetime:

<span class="dtstart" lang="en-us">
<span class="date">
<span class="mo">October</span> <span class="day">5</span>, <span class="yr">2004</span>
<span> at 
<span class="time">
<span class="hr">6</span><span class="">PM</span>
</span>
</span>

date maybe not required since dtstart IS a date.

For a duration:

<span class="duration">
    <span class="h">1</span>:
    <span class="min">3</span>:
    <span class="s">42</span>
</span>
  • An example of this is also documented on ISO-31-1

Issues

  • the internationalization issue is not addressed, but it is limited to the month of the year.
  • Tonnes and tonnes of nested elements to mark up something that's essentially very simple. Microformats are "for humans first, machines second", but this suggestion appears to be friendly to neither! TobyInk 02:21, 12 Aug 2008 (PDT)
    • Also worth pointing out that the complexity issue applies less to durations. With durations, most people will probably only want to use a combination of 1 to 3 time components (e.g. d+h, h+min+s, h+min, min+s, d only, h only, min only, s only) But with datetimes, they're likely to want to specify at least five components (y+m+d+h+min) and often also the timezone (seconds, and fractions thereof, are not especially useful for the majority of use cases). So marking up the time components might be OK for durations, but becomes onerous for datetimes.

See Also