# # Platon/Template/Plugin/Interval.pm # # Developed by Lubomir Host 'rajo' # Copyright (c) 2004 Platon SDG, http://platon.sk/ # Licensed under terms of GNU General Public License. # All rights reserved. # # Changelog: # 18/04/2004 - created # # $Platon: $ package Platon::Template::Plugin::Interval; use strict; use Carp; use Time::HiRes qw(gettimeofday tv_interval); use Template::Plugin; use Template::Exception; use base qw( Template::Plugin ); use vars qw( $VERSION $DEBUG ); $VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/); $DEBUG = 0 unless defined $DEBUG; sub new { #{{{ my $class = shift; my $context = shift; my $self = ref $class ? $class : bless { _CONTEXT => $context, _STH => [ ], }, $class; $self->{start_time} = shift; my $precision = shift; $self->{precision} = defined ($precision) ? $precision : 1E3; bless $self, $class; return $self; } # }}} sub interval { # {{{ my ($self) = @_; my $precision = $self->{precision}; my $curr_time = Time::HiRes::gettimeofday; return (int($precision * ($curr_time - $self->{start_time})) / $precision); } # }}} 1; __END__ =head1 NAME interval - <<>> =head1 SYNOPSIS use Platon::Template::Plugin::Interval; my $xxx = new Platon::Template::Plugin::Interval; =head1 DESCRIPTION The interval module allows you ... <<>> =head2 EXPORT <>> =head1 SEE ALSO =head1 AUTHORS Lubomir Host 'rajo', =cut # vim: ts=4 # vim600: fdm=marker fdl=0 fdc=3