IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 15, 2010, 12:34:14 PM (16 years ago)
Author:
rhenders
Message:

Some time utility methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czartool/MySQLDb.pm

    r29376 r29436  
    9898###########################################################################
    9999#
     100# Finds the difference of two times
     101#
     102###########################################################################
     103sub diffTimes {
     104    my ($self, $time1, $time2) = @_;
     105
     106      my $query = $self->{_db}->prepare(<<SQL);
     107         SELECT TIMEDIFF('$time1','$time2');
     108SQL
     109
     110    $query->execute;
     111    return scalar $query->fetchrow_array();
     112}
     113
     114###########################################################################
     115#
     116# Finds the difference of two times in seconds
     117#
     118###########################################################################
     119sub diffTimesInSecs {
     120    my ($self, $time1, $time2) = @_;
     121
     122      my $query = $self->{_db}->prepare(<<SQL);
     123         SELECT TIME_TO_SEC(TIMEDIFF('$time1','$time2'));
     124SQL
     125
     126    $query->execute;
     127    return scalar $query->fetchrow_array();
     128}
     129
     130###########################################################################
     131#
     132# Returns whether the first interval is larger than the second
     133#
     134###########################################################################
     135sub isIntervalGreaterThan {
     136    my ($self, $interval1, $interval2) = @_;
     137
     138      my $query = $self->{_db}->prepare(<<SQL);
     139          SELECT INTERVAL('$interval1', '$interval2');
     140SQL
     141    $query->execute;
     142
     143return scalar $query->fetchrow_array();
     144}
     145
     146###########################################################################
     147#
    100148# Subtracts the provided interval from the provided time
    101149#
Note: See TracChangeset for help on using the changeset viewer.