A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on IRC (such as one of these permanent autoconfirmed members) or send an e-mail to admin@wiki.whatwg.org with your desired username and an explanation of the first edit you'd like to make. (Do not use this e-mail address for any other inquiries, as they will be ignored or politely declined.)

Time element

From WHATWG Wiki
Jump to: navigation, search

Summary: Research, data, use cases, issues, and enhancements related to the HTML5 time element (see also W3C TR time snapshot).


HTML5's new <time> element presents a huge opportunity to improve the publishing of datetime information on the web, the biggest opportunity since the introduction of hCalendar and other time-based microformats.

The time element has been improved through the research done on this page. See:

  • Time element: accepted proposals

Please read the following proposals for improving the <time> element, grouped by category, and offer your opinions, use-cases, evidence and - hopefully - support in the respective discussion sections.

Thanks for your consideration,

Tantek (and other proposal authors).

Please add new proposals to the end of the most relevantly related section, or if you're not sure where (or if there is no related section), at the end of the Miscellaneous proposals section.

Contents

  • 1 Date granularity
  • 2 HTML5 internal consistency
    • 2.1 impedance match new date time inputs
    • 2.2 inputs to impedance match new time granularity
  • 3 Proposals extending scope
    • 3.1 Fuzzy dates
    • 3.2 Calendar scale
      • 3.2.1 Calendar scale example
      • 3.2.2 Calendar scale processing
      • 3.2.3 Calendar scale use cases
      • 3.2.4 Calendar scale discussion
      • 3.2.5 Calendar scale related posts
  • 4 Syntax improvements
    • 4.1 permit space instead of T in datetimes
      • 4.1.1 summary of permit date-space-time
      • 4.1.2 existing implementation support of date-space-time
      • 4.1.3 date-space-time issues questions
        • 4.1.3.1 gratuitous departure from ISO8601
      • 4.1.4 date-space-time discussion
    • 4.2 reducing DRY violations overview
    • 4.3 composite nested time elements
      • 4.3.1 background
      • 4.3.2 microformats value class pattern DRY advantage
      • 4.3.3 simple nested time example improvement
      • 4.3.4 summary of updated datetime algorithm
      • 4.3.5 applicability to microdata
      • 4.3.6 nested time example with datetime attribute
      • 4.3.7 nested time example with two datetimes
      • 4.3.8 nested time discussion
    • 4.4 am pm and coarser time parsing
      • 4.4.1 am pm syntax summary
      • 4.4.2 am pm syntax details
      • 4.4.3 simple am pm example
      • 4.4.4 am pm example with nested time elements
      • 4.4.5 am pm discussion
      • 4.4.6 am pm FAQ
        • 4.4.6.1 noon and midnight
        • 4.4.6.2 am pm i18n
  • 5 Other types of time
    • 5.1 duration
      • 5.1.1 duration examples
      • 5.1.2 duration faq
      • 5.1.3 duration discussion
    • 5.2 timezone
      • 5.2.1 timezone examples
      • 5.2.2 timezone discussion
    • 5.3 tz attribute
      • 5.3.1 tz attribute examples
      • 5.3.2 tz attribute discussion
  • 6 Minor editorial fixes
    • 6.1 Update hCalendar example
      • 6.1.1 Current example
      • 6.1.2 Updated example
  • 7 Miscellaneous proposals
    • 7.1 Choose different default date
  • 8 Issues without specific proposals
    • 8.1 Specification ambiguities
  • 9 See Also
  • 10 External links
    • 10.1 Tag
    • 10.2 Prior discussion
    • 10.3 Resources

Date granularity

All Date granularity proposals have been accepted. See: Time element accepted.

HTML5 internal consistency

impedance match new date time inputs

The proposal to impedance match new date time inputs was partially accepted (additional time element granularity). See: Time element accepted.

inputs to impedance match new time granularity

While this could be documented on an input element page, it made sense to keep it here as it's a part of time element discussion.

For each time element granularity, there should be a corresponding input element.

The time element should be able to represent every granularity of times and dates that the new date time <input> elements allow and vice-versa. Here is a list of all the date time <input> elements along with the corresponding <time> element usage (if applicable)

<input type="date">           - <time>YYYY-MM-DD</time>
<input type="datetime">       - <time>YYYY-MM-DDTHH:MM:SS</time>
<input type="month">          - <time>YYYY-MM</time> (accepted as of 2011-11-18)
<input type="week">           - <time>YYYY-Www</time> (accepted as of 2011-11-18)
<input type="time">           - <time>HH:MM:SS</time>
<input type="datetime-local"> - <time>HH:MM:SS-ZZ:YY</time>
New proposed input elements:
<input type="year">           - <time>YYYY</time> (accepted as of 2011-11-18)
<input type="month-day">      - <time>--MM-DD</time> (accepted as of 2011-11-18)


The following input elements are proposed to represent the respective time element granularity:

  • input type="year"
  • input type="month-day"

Opinions / discussion:

  • +1 Tantek
  • +1 Andy Mabbett
  • +1 Asbjørn Ulsberg
  • ...

Proposals extending scope

Fuzzy dates

The time element should accept fuzzy (uncertain, approximate) dates ("around 18 June 1855" "summer 1970", "circa December 1963", "flourished 1580-1600"[1]), centuries, and allow eras ("Edwardian", "bronze age", "Jurassic") in a manner to be determined; perhaps once defined by EDTF efforts.

Use cases
1. "... an application that might input Wikipedia data and output an annotated visual timeline. For movements or trends rather than events, it would need to output rough dates and date ranges like 2001-2003, rather than exact dates."[2]
Implemented, see [3], (target site currently broken, but worked previously; a fix is promised shortly), but can only map precise dates, because there is currently no way to mark up fuzzy dates in a machine-readable format. The acceptance of this proposal would allow this implementation and others to map all such dates. Note that the implementation works with any site, not just Wikipedia, by parsing hCalendar microformats.
2. Time periods in astronomy
building on the English Heritage Periods list and Timelines thesaurus - see Douglas Tudhope's mailing list post and prior discussion
3. www.fish-forum.info/i_apl_e.htm Archaeological Periods list via Archaeological Periods list meta page - see Nick Boldrini's mailing list post
4 ...

Opinions / discussion:

  • +1 Andy Mabbett (Per use cases in "Extended Date Time Format" proposals & TEI - see external links)
    • Uncertainty possibly resolved by a "certainty" attribute:
      <time datetime="1855-06-18" certainty="3days">around 18 June 1855</time>
      <time datetime="1970-06" certainty="45days">summer 1970</time>
      (with "45days" meaning "+/- 45 days" - in other words, a 90-day window, and similar allowance for year or other ranges; or:
      <time datetime="1963-12" certainty="circa">circa December 1963</time>
      with pre-defined prose values allowed, such as "flourished", "notbefore", "notafter", etc.
  • +1 Jérôme Beau provided that 'certainty' attribute use a standard format as well, such as the time duration syntax :
    <time datetime="1855-06-18" certainty="P3D">around 18 June 1855</time>
    Optionally, when uncertainty differ in past and future, a second, comma-separated duration should be interpreted as the specific future-incertainty.
    <time datetime="1855-06-18" certainty="P3D,P5D">around 18 June 1855, up to 3 days before or 5 days later</time>
  • +1 Jim O'Donnell (Dates such as 'circa 1910' published on Flickr eg. The RNVR Training Ship 'Buzzard'… also a list of fuzzy dates for a set of photos.)
  • 0 (comments) Tantek - Update: the syntax still seems a bit loose/imprecise, however, I appreciate the improvements being made. Some additional changes for consideration:
    • certainty attribute, empty or missing is equivalent to "0" (absolute certainty presumably)
    • certainty attribute takes an ISO8601 duration.
    • alternatively it might make more sense to introduce a compound time structure for ranges such as the use case example of 2001-2003. Here is a strawman markup example (feel free to pick alternative markup, but re-using nested time elements for portions of a range seem useful)
      • <range><time>2001</time>-<time>2003</time></range>
  • +1 Bruce Darcus says: "[While] I definitely think the use case is important...
    • "...I'm of the very strong opinion that an extended data-time format ought to be self-contained, and so not rely on format-specific extensions like X/HTML attributes. One ought to be able to use the same representation in an HTML attribute, or a JSON or RDF value, and losslessly convert among them. For that reason, I very much prefer the current draft idea in EDTF of doing "2000?" or "2000~"."
  • +1 Asbjørn Ulsberg I like the concept, but the syntax should be less verbose and more precise.
    • "Circa" can be indicated with a tilde prefix "~"
    • Ranges can use ISO-8601 time interval syntax, like "2007/2008" or "2007-2008" which is also allowed (according to section 4.4.2).
  • 0 Lars Gunther One of the benefits of the time element is machine parsability. I can't see what benefit it adds for non-parsable text. There are bigger fish to fry.
    • The proposal is to make such dates machine parsable. Pigsonthewing 09:54, 17 August 2010 (UTC)
  • -1 Martin Janecke - I don't object to the idea of fuzzy dates in general (a well defined certainty attribute sounds interesting) but this doesn't seem to be well thought through yet. E.g. "bronze age" rather defines a stage of development of a culture than a time, just as "adolescence" does for a human. The time element could be suitable for adding markup to the term "bronze age" in a text talking about a specific culture. But you would really add markup to the term, not use this term as time markup, exactly because "bronze age" does not tell a time. Please don't make the time element too unspecific as I am afraid this would reduce its usability rather than adding to it. Ocolon 12:54, 22 August 2010 (UTC)
    • It is not proposed to define terms like "bronze age" here; but to cater for a) any definitions emerging from the EDTF efforts and/or b) a publisher using their own definition, such as, say . It's not that "this isn't well thought through" so much as "this is brought here for the community to think through". Pigsonthewing 22:34, 22 August 2010 (UTC)
      • I wrote "this doesn't seem to be well thought through yet", of course implying this can change. Thanks for the details on the "bronze age" example. Should the introduction sentence to the fuzzy date section be edited to reflect this? Currently it does propose "bronze age" etc. as examples for future time values. Ocolon 01:17, 23 August 2010 (UTC)
        • Done. Pigsonthewing 11:24, 23 August 2010 (UTC)
  • ...

Calendar scale

The time element should accept a calendar scale (CALSCALE; default is GREGORIAN) per (and to facilitate interoperability with) the emergent vCard 4 specification, to allow for the the mark-up of non-Gregorian (e.g. Julian) dates, using one of a set of pre-defined CALSCALE types.

Calendar scale example

Example:

<time datetime="1330-06-01" calscale="julian">1 June 1330</time>

Calendar scale processing

User agents could be instructed to ignore any unrecognised CALSCALE value, treating the contents of the element as plain text for data-processing (but not styling) purposes. This would prevent, for example the processing of the above example by an agent written to deal only with Gregorian dates. (At some point, CSS should recognise CALSCALE, allowing authors to, say, style all Julian dates differently to Gregorian dates.)

Calendar scale use cases

Use case research:

  • The Wikipedia timeline example in HTML5 Super Friends Technical Details: time element proposes to map a timeline of dates from Wikipedia (e.g. 2001-2003 Gregorian). However, Wikipedia includes several thousand articles about or referring to pre-Gregorian era events, usually using the Julian calendar, such as the birth and death of Julius Ceaser and, in the same article, the Ides of March (15 March) 44 BC. The existing timeline implementation (see [4] - target site currently broken, but worked previously; a fix is promised shortly) can only map Wikipedia's Gregorian dates, because there is currently no way to mark up Julian dates in a machine-readable format. The use of CALSCALE as suggested would allow this implementation and others to map all of these dates. (Note that the implementation works with any site, not just Wikipedia, parsing hCalendar microformats.)
  • Julian dates in timeline of Georgia:
  • General: non-Gregorian dates are published in documents about museum artifacts, history, archaeology, genealogy etc. and in archives of historic documents.
  • Documenting pre-Gregorian time travel in science fiction
    • Dr Who time travel
  • See also various use cases under #Fuzzy dates, above for eras pre-dating the Gregorian calendar

Calendar scale discussion

Opinions / discussion:

  • +1 Andy Mabbett (Per use cases in VCARDDAV, EDTF & TEI - see external links)
  • 0 Tantek - Update: I have mixed feelings about this. On one hand, despite years of the presence of the CALSCALE feature in iCalendar etc., there are no implementations (AFAIK) of non-GREGORIAN CALSCALE values in iCalendar etc. user agents, thus there is no reason to believe that specifying it in HTML5 would actually encourage any other user agents to implement it either. On the other hand the Wikipedia long-term timeline use case does appeal to me so overall I've upgraded my opinion on this from -1 to 0 neutral.
  • 0 Martin Janecke - I'm afraid the current proposal is too "Western World" centered. If you plan to allow Julian and Gregorian dates – what about the Islamic, Chinese, Hebrew, …, Mesopotamian and Mayan calenders? I don't mean to say we mustn't incorporate other calender scales – but if we do, we'll probably have to implement all of them, making things easier in some and much more complicated in many aspects. This could result in many parsers not being able to understand many of the dates, making the time element less useful. I'd rather use just one scale as it is in the spec right now. The Gregorian calender is an international standard, so it should be fine. But I don't know if it is right to expect others to use "my" calendar (which the Gregorian calender is), hence the neutral vote.
    • Dates from 2000+ years ago in non-European calendars such as those you mention can be converted to Julian calendar dates (but not Gregorian dates), just as modern dates in those calendars can be converted to the Gregorian calendar. The use of Julian extends the range of dates which can be expressed. Pigsonthewing 22:40, 22 August 2010 (UTC)
  • +1 John Dalziel Non-Gregorian reckoning is common in many fields (history, archeology, geology and astronomy to name just a few). However, given that all standard temporal datatypes are derived from ISO8601 then I think we're currently stuck with Gregorian for machine-readable dates. This puts the onus on the author to make (an often error-prone) conversion to Gregorian.

Calendar scale related posts

Related posts (listed with quotes directly related to Calendar scale) :

  • 2009-02-23 Dates and coordinates in HTML5 blog post by Andy Mabbett -
    The issue of non-Gregorian (chiefly Julian) dates is a vexing one; and has already caused problems on Wikipedia. So far as I am aware, there is no ISO-, RFC- or similar standard for such dates, other than converting them to Gregorian dates. It is not the job of the HTML5 working group to solve this problem; but I think the group should recognise that at some point a solution must be forthcoming. One way to do so would be allow something like [(refers to prototype CALSCALE)] where the schema defaults to ISO 8601 if not stated, and the whole element is treated as simply [date in plain text] if the schema is unrecognised; thereby ensuring backwards compatibility. That way, if a hypothetical ISO- or other standard for Julian dates emerges in the future, authors may simply start to use it without any revision to HTML 5 being required.
  • 2009-02-25 HTML 5, politics and me blog post by Bruce Lawson - look for mention of "time element" which mentions:
    I see no reason why authors shouldn’t be able to mark up BCE dates... which are currently disallowed by the spec
    BCE dates are typically in the Julian (or other?) calendar and thus a request for BCE dates markup implies something at least like Calendar scale
  • 2010-02-09 The time element (and microformats) blog post on HTML5 Doctor by Bruce Lawson - mentions:
    The only trouble with <time> is that the it must contain positive date on the Proleptic Gregorian calendar, meaning you can’t encode a date before the Christian Era.
    Again, seemingly implying a desire for non-Gregorian calendars as well.
  • Dates before the Christian/Common Era could be specified by adding an era attribute that can take two values: CE (Common Era) or BCE (Before Common Era). If the attribute isn't present, then a default value of CE is assumed. The Dionysian "Common Era" doesn't have a "year 0" thus eliminating that potential issue.
    • See related: add era attribute to time element change proposal

Syntax improvements

permit space instead of T in datetimes

Status
2011-12-06 Adopted in WHATWG HTML.[5]
Summary
The date-and-time microsyntaxes should permit a single space as a separator as an alternative to "T".

summary of permit date-space-time

Current date-and-time microsyntaxes require a "T" between the date and time per ISO8601:

2011-12-06T13:28:00

This proposal modifies that requirement to permit a single space (U+0020) instead of the "T", for both better human readability and the fact that that slight modification of ISO8601 date-and-time syntax is already widely supported by various tools.

2011-12-06 13:28:00

This proposal should be applied to the 'datetime' attribute of both the <time> element and the <ins> & <del> elements.

Inspired by the first part of this proposal by Marat Tanalin, with additional references/issues documented from #whatwg on 2011-12-01.

existing implementation support of date-space-time

Note that this specific proposal of allowing a single space instead of "T" is supported by several existing implementations:

  • Python. The date time python module outputs " " instead of "T" for str(aDatetime).
  • Perl. "Perl's Date::Parse also takes dates in that format, although it's not int he documentation. But we've been relying on it doing so, for years, in Bugzilla." -mkanat [6]
  • MySQL. MySQL takes and sends all its dates in date-space-time format.
  • postgresql "also accepts that format, and its commandline omits T by default as well (2011-12-06 15:27:00.706385-07)" -zewt [7]
  • Javascript Date.parse method.
    • Chrome can parse it "2011-11-11 11:11:11".[8],[9]
    • Opera [10]
    • Notable exceptions that DO NOT parse it:
      • Firefox8 [11]
      • IE8 returns NaN[12]. However it does support the format it outputs from toString ("Thu Dec 1 16:10:18 EST 2011")[13]
        • also returns NaN for "2011-11-11T11:11:11"[14] - thus unclear that lack of space support is any kind of meaningful result.
      • IE9 returns NaN [15]
      • IE10 returns NaN [16]
      • Safari returns NaN for:
        data:text/html,<!doctype html><script>alert(Date.parse("2011-11-11 11:11:11"))</script>

date-space-time issues questions

gratuitous departure from ISO8601

"...seems like a bit of a gratuitous departure from ISO8601"

It's not gratuitous because there are very specific reasons for it:

  • it does help readability, incrementally
  • we're only adopting something that's been in use for a while, that is, it's been a mod on ISO8601 in general by others.

date-space-time discussion

Opinions / discussion:

  • +1 Marat Tanalin per [17].
  • +1 Tantek - I think this will improve readability, writability, usability, and thus overall data quality for information expressed in the date-and-time microsyntax.
  • +1 kennyluck per [18]. "I think this [ISO8601-with-space] is the most i18n-wise human-readable format."[19]
  • +1 mkanat per [20]
  • +1 zewt "it's a natural, human format, where *T* really isn't" [21]
  • ...

reducing DRY violations overview

We know from experience with past methods of duplicated invisible (meta)data, and more recently, development/use/experience with visible microformats, that when we are able to re-use the visible data, published *once*, by humans for humans, we get more accurate data over time, than when we have at times asked for *duplicating* the data in a different (more machine readable) format (or location).

This experience yielded the microformats adoption of the DRY principle - Don't Repeat Yourself - in application to (meta)dataformat designs and techniques.


The <time> element currently encourages DRY violations in most of its use cases (duplication of datetime information inside the 'datetime' attribute in addition to the visible content of the element). This duplication can result in inaccurate data (e.g. [22]).

This is not a new problem, we've had much the same DRY problem in microformats representations of dates and times, originally with (excessive and in many cases inaccessible) use of the <abbr> element.

Subsequently (through years of debate, experimentation, iteration) we've largely addressed both most of the DRY violations (or greatly mitigated their impact) and resolved accessibility related <abbr> problems with the introduction and successful adoption of the Value Class Pattern (developed in parallel with the time element, and not surprisingly with some newer improvements).

microformats.org/wiki/value-class-pattern#Date_and_time_values

We'd like to see the lessons learned (and improvements made as a result of the value class pattern) adopted in HTML5 as well, for much the same reasons, to make the HTML5 <time> element the best and most long term accurate way to represent all date and time information in microformats (or microdata for that matter).

Accordingly, please consider the following <time> syntax processing improvements for better DRY (and mitigation) and thus more accurate data over time.


composite nested time elements

A time element should permit child time elements which may contain only partial date time information which can then be composed into more complete date time information.

This is intended as a cleaner way to provide functionality equivalent to the microformats