perfSONAR_PS::Time - A module that provides methods for the a simple time


perfSONAR_PS-Base documentation  | view source Contained in the perfSONAR_PS-Base distribution.

Index


NAME

Top

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.

new ($package, $type, $arg1, $arg2) This allocates a perfSONAR_PS::Time element. The type parameter can be one of 'range', 'duration' or 'point'. If the type is 'point', then $arg1 is the time parameter as a unix timestamp. If the type is 'range', then $arg1 is the startTime and $arg2 is the endTime. If the type is 'duration', then $arg1 is the startTime and $arg2 is the duration. =cut 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;
}

getType ($self) This function returns what type 'point', 'range' or 'duration' that this Time element is. =cut sub getType { my ($self) = @_;

	return $self->{TYPE};
}

getTime ($self) This function is valid for Time elements of type 'point' and simply returns the point in time that this element describes. =cut sub getTime { my ($self) = @_;

	return $self->{TIME};
}

getStartTime ($self) This function is valid for Time elements of type 'range' or 'duration' and returns the starting point of the time range. =cut sub getStartTime { my ($self) = @_; if ($self->{TYPE} eq "point") { return $self->{TIME}; } else { return $self->{STARTTIME}; } }

getEndTime ($self) This function is valid for Time elements of type 'range' or 'duration' and returns the ending point of the time range. =cut 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};
	}
}

getDuration ($self) This function is valid for Time elements of type 'duration' and returns the duration of the time range. =cut 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

VERSION

Top

$Id$

AUTHOR

Top

Aaron Brown, aaron@internet2.edu

LICENSE

Top

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

Top


perfSONAR_PS-Base documentation  | view source Contained in the perfSONAR_PS-Base distribution.