HTML::...ration(3pm)
π HTML::Microformats::Datatype::Duration β bestie edition π
okay so you found the docs for HTML::Microformats::Datatype::Duration, a Perl module from the User Contributed Perl Documentation collection, and honestly? it's giving "floating periods of time" and we're obsessed. π
β¨ NAME β¨
HTML::Microformats::Datatype::Duration β floating periods of time π°οΈβ¨
πΈ SYNOPSIS πΈ
my $duration = HTML::Microformats::Datatype::Duration->new($d);
print "$duration\n";
literally that's it, that's the whole vibe check. π¦
π DESCRIPTION π
π Constructors π
$d = HTML::Microformats::Datatype::Duration->new($duration)β makes you a brand newHTML::Microformats::Datatype::Durationobject, no cap.
$duration is a DateTime::Duration object. periodt.
$d = HTML::Microformats::Datatype::Duration->parse($string, $elem, $context)β also makes you a shiny newHTML::Microformats::Datatype::Durationobject, but from parsing. slay.
$string is a duration written in ISO 8601 format, like for example: 'P1Y' or 'PT2H29M58.682S'. $elem is the XML::LibXML::Element that's being parsed. $context is the document context.
The standard way of representing durations in Microformats is as an ISO 8601 string, iykyk:
<abbr class="duration" title="P4DT4H">4 and a half days</abbr>
but wait, there's more π This constructor also supports a bunch of experimental microformat duration patterns. ISO-31 class names are supported:
<div class="duration">
<span claa="d">4</span> and
<abbr title="12" class="h">a half</abbr> days.
</div>
(yes bestie, that claa is in the original, we do not edit, we only report π)
As are metric/SI measures (in seconds):
<span class="duration">124 s</span>
<span class="duration">124</span> seconds
Or using an hMeasure microformat with no 'item' property, the 'type' property either absent or a case-insensitive match of 'duration' and a unit property of 's'/'sec'/'seconds', 'min'/'minutes', 'h'/'hours' or 'd'/'days'. For example:
<span class="duration hmeasure">
<b class="unit">Days</b>: <span class="num">4.5</span>
</span>
π Public Methods π
$d->durationβ hands you back aDateTime::Durationobject. π«Ά$d->to_stringβ hands you back an ISO 8601 formatted string that represents the duration. β¨$d->datatypeβ returns the RDF datatype URI that represents the data type of this literal. π
π§ Functions π§
compare($a, $b)β compares durations$aand$b. The return values are exactly as per'cmp'(go peek at perlfunc if you need a refresher). π
β οΈ real talk bestie: there is not always a consistent answer when comparing durations. 30 days is longer than a month in February, but shorter than a month in January. Durations are compared as if they were applied to the current datetime (i.e. now).
This function is not exported by default. π
Can also be used as a method:
$a->compare($b);
$c = add($a, $b)β adds two durations together. math but make it cute π
This function is not exported by default.
Can also be used as a method:
$c = $a->add($b);
$c = subtract($a, $b)β subtracts duration$bfrom$a. π
This function is not exported by default.
Can also be used as a method:
$c = $a->subtract($b);
π BUGS π
please report any bugs to <http://rt.cpan.org/>. we're listening, bestie π«Ά
β SEE ALSO β
HTML::Microformats, HTML::Microformats::Datatype, DateTime::Duration. the holy trinity of "go read these next" π
π AUTHOR π
Toby Inkster <tobyink@cpan.org>. iconic. β¨
π COPYRIGHT AND LICENCE π
Copyright 2008-2012 Toby Inkster
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π DISCLAIMER OF WARRANTIES π
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
fr fr, no warranty, we said what we said. π€
and that's the whole page, bestie π
this was HTML::...ration(3pm) from perl v5.32.1, dated 2021-09-12 β go forth and parse those durations, main character. π¦π
π¦ where this page comes from
- debian bookworm: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-microformats-perl 0.105-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms