[uf-discuss] Re: Precise Expansion Patterns

Benjamin Hawkes-Lewis bhawkeslewis at googlemail.com
Tue Dec 18 02:08:53 PST 2007


Michael MD wrote:
>> This would be acceptable:
>> <span class="duration"><span class="seconds">3</span> seconds</span>
>>
>> Or if we wanted to use the hMeasurement approach:
>> <span class="duration" title="3s">three seconds</span>
>> <span class="duration" title="2min 3s">two minutes, three
>>                                         seconds</span>
>> <span class="duration" title="2y 35h">two years, 35 hours</span>
>> <span class="duration" title="3s">three seconds</span>
>>
> 
> this kind of thing would:
> 
> 1. add complexity to parsers

Doubtless, but the questions we need to ask are:

1. Can it be done?

2. Is it worth it?

> 2. require people to be very precise in the choice of allowed strings 
> ... eg: "year"  or "y" , "second" or "seconds" otherwise dates and times 
> may very quickly degenerate into something not much better than garbled 
> freeform text dates.

Yes, like /any/ exact syntax including standardized class names and ISO 
8601, it requires people to be precise.

> It would also mean a lot more rules for authors to remember which could 
> result in a lot of invalid markup being published.

That's a good argument for keeping the names of recognized units 
consistent and verbose: perhaps always "seconds" not year or m.

> If dates/times are no longer machine-readable I would see no longer see 
> much practical use for any of this!

Well, strings conforming to any unambiguous syntax parsed with an 
algorithm we define are machine-readable.

> I am very wary of straying too far from ISO for dates and times
> (or at least something that can easily be parsed by 
> javascript/php/perl/ruby/whatever built-in date functions or commonly 
> used date libraries)

JavaScript can parse date times, but has no native support for parsing 
ISO-formatted ones:

http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Date:parse

http://delete.me.uk/2005/03/iso8601.html

PHP and Ruby have functionality for parsing non-ISO date times:

http://uk.php.net/manual/en/function.strtotime.php

http://www.ruby-doc.org/core/classes/Time.html

Perl has no built-in functionality for parsing date times at all 
(although naturally you can find such functionality on CPAN):

http://perldoc.perl.org/perlfaq4.html#How-can-I-take-a-string-and-turn-it-into-epoch-seconds%3f

But in any case Manu's examples featured measurements, durations 
specifically, not dates or times. AFAIK none of these languages have 
in-built support for parsing durations or other measurements at all.

Does anyone have any evidence on what libraries capable of parsing 
durations or other measurements are "commonly used"?

--
Benjamin Hawkes-Lewis


More information about the microformats-discuss mailing list