5

It's easy to markup a recipe's cooking or preparation time if it's for a specific time range:

Prep time: <time datetime="PT30M" itemprop="prepTime">30 min</time>
Cook time: <time datetime="PT1H" itemprop="cookTime">1 hour</time>

However, many recipes use estimated durations instead:

Prep time: 10-30 minutes
Cook time: 1 - 1½ hours

What's the best way of marking this information up in a way that'll be picked up by Google? From what I can tell, the ISO 8601 duration format doesn't seem to support "fuzzy" durations/duration ranges.

It's tempting to interpolate the time range so the machine-readable value sits halfway between the human-readable min/max values:

Prep time: <time datetime="PT20M" itemprop="prepTime">10-30 minutes</time>

Humans see:           10-30 minutes
Google/machines see:  20 minutes

That feels hacky and forced, though, and also feels like I'm feeding search engines incorrect data with specifics for the sake of SEO.

1 Answers1

1

Short answer: I don’t think the time element as currently specified provides any good way to specify “fuzzy” durations.

Longer answer

This is by design a known issue/limitation in the current definition of the time element in the HTML spec. There’s been discussion about it, and some proposals for extending the scope of time to address that use case; see https://wiki.whatwg.org/wiki/Time_element#Fuzzy_dates

The proposal that’s had the most traction is to add a certainty attribute to time that would allow you to do something like this:

Prep time: <time datetime="PT20M" certainty="10M">10-30 minutes</time>

Along with that certainty-attribute idea, there’s also been discussion of updating the specs for actual time formats to include a way to use ? or ~ characters to specify approximations; see http://www.loc.gov/standards/datetime/pre-submission.html#uncertain

Anyway, there’s not yet been agreement about any of the proposed solutions, so gist of it remains that there’s unfortunately not yet any standard way to express a fuzzy duration—and I think also not really even any very good workarounds other than the one mentioned in the question.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • Bugger. :( *sigh* Alright, thanks, mate... very informative answer. Guess I'll have to improvise, heh. Cheers! –  Aug 27 '15 at 06:36
  • 3
    Cheers. If you feel strongly about the need for this, you could consider e-mailing `whatwg.org@whatwg.org` to see if you might be able to rally some other people interested in moving forward with getting `certainty` into the HTML spec. Or file a bug report at https://www.w3.org/Bugs/Public/enter_bug.cgi?product=WHATWG&component=HTML. (We’ll hopefully soon have a way you can raise issues at against the HTML spec through a github issue tracker, but we’re not there yet.) – sideshowbarker Aug 27 '15 at 06:43
  • ISO/W3 standards are holy law for me, I'd be honoured. –  Aug 27 '15 at 06:46
  • @Alhadis You can also extend the HTML microdata vocabulary, for example, https://github.com/guest271314/Definition , https://github.com/guest271314/Excerpt – guest271314 May 07 '16 at 17:41