Toby Inkster > RDF-Query-Functions-Buzzword-DateTime-0.002 > RDF::Query::Functions::Buzzword::DateTime

Download:
RDF-Query-Functions-Buzzword-DateTime-0.002.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.002   Source  

NAME ^

RDF::Query::Functions::Buzzword::DateTime - plugin for buzzword.org.uk datetime functions

SYNOPSIS ^

  use RDF::TrineX::Functions -shortcuts;
  use RDF::Query;
  
  my $data = rdf_parse(<<'TURTLE', type=>'turtle', base=>$baseuri);
  @prefix foaf: <http://xmlns.com/foaf/0.1/> .
  @prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  
  <http://tobyinkster.co.uk/#i>
    foaf:birthday "1980-06-01"^^<http://www.w3.org/2001/XMLSchema#date> .
  TURTLE
  
  my $query = RDF::Query->new(<<'SPARQL');
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX util: <http://buzzword.org.uk/2011/functions/util#>
  PREFIX dt:   <http://buzzword.org.uk/2011/functions/datetime#>
  PREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>
  SELECT
    (dt:now() AS ?now)
    (dt:today() AS ?today)
    ?bday
    (dt:format_duration(dt:difference(dt:now(), ?bday), "%Y years, %m months") AS ?age)
    (dt:add(?bday, "P10Y"^^xsd:duration) AS ?tenthbday)
    (dt:strtotime("yesterday morning"@en) AS ?yesterdaymorning)
    (dt:strftime(?bday, "%a, %d %b %Y"@en) AS ?fmtbday)
    (dt:strtodate("1/6/1980"@en-gb) AS ?guessbday)
  WHERE
  {
    ?person foaf:birthday ?bday .
  }
  SPARQL

  print $query->execute($data)->as_xml;

DESCRIPTION ^

This is a plugin for RDF::Query providing a number of extension functions for dates and times.

SEE ALSO ^

RDF::Query, RDF::Query::Functions::Buzzword::Util.

DateTime.

http://www.perlrdf.org/.

AUTHOR ^

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT ^

Copyright 2011-2012 Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: