| perfSONAR_PS-Base documentation | Contained in the perfSONAR_PS-Base distribution. |
perfSONAR_PS::Time - A module that provides methods for the a simple time element that can represent either single points in time or time ranges as unix timestamps.
$Id$
Aaron Brown, aaron@internet2.edu
You should have received a copy of the Internet2 Intellectual Property Framework along with this software. If not, see <http://www.internet2.edu/membership/ip.html>
Copyright (c) 2004-2008, Internet2 and the University of Delaware
All rights reserved.
| perfSONAR_PS-Base documentation | Contained in the perfSONAR_PS-Base distribution. |
package perfSONAR_PS::Time; use strict; use warnings; use Log::Log4perl qw(get_logger); use Data::Dumper; use fields 'TYPE', 'STARTTIME', 'ENDTIME', 'DURATION', 'TIME'; our $VERSION = 0.09;
sub new { my ($package, $type, $arg1, $arg2) = @_; my $logger = get_logger("perfSONAR_PS::Time"); my $self = fields::new($package); if ($type eq "range") { $self->{TYPE} = "range"; $self->{STARTTIME} = $arg1; $self->{ENDTIME} = $arg2; $self->{DURATION} = $arg2 - $arg1; } elsif ($type eq "duration") { $self->{TYPE} = "duration"; $self->{STARTTIME} = $arg1; $self->{DURATION} = $arg2; } elsif ($type eq "point") { $self->{TYPE} = "point"; $self->{TIME} = $arg1; } else { $logger->error("Invalid type: $type"); return; } return $self; }
sub getType { my ($self) = @_; return $self->{TYPE}; }
sub getTime { my ($self) = @_; return $self->{TIME}; }
sub getStartTime { my ($self) = @_; if ($self->{TYPE} eq "point") { return $self->{TIME}; } else { return $self->{STARTTIME}; } }
sub getEndTime { my ($self) = @_; if ($self->{TYPE} eq "duration") { return $self->{STARTTIME} + $self->{DURATION}; } elsif ($self->{TYPE} eq "range") { return $self->{ENDTIME}; } else { return $self->{TIME}; } }
sub getDuration { my ($self) = @_; return $self->{DURATION}; } 1; __END__ To join the 'perfSONAR-PS' mailing list, please visit: https://mail.internet2.edu/wws/info/i2-perfsonar The perfSONAR-PS subversion repository is located at: https://svn.internet2.edu/svn/perfSONAR-PS Questions and comments can be directed to the author, or the mailing list. Bugs, feature requests, and improvements can be directed here: https://bugs.internet2.edu/jira/browse/PSPS
# vim: expandtab shiftwidth=4 tabstop=4