1package timehelper;
2
3#**************************************************************
4#
5#  Licensed to the Apache Software Foundation (ASF) under one
6#  or more contributor license agreements.  See the NOTICE file
7#  distributed with this work for additional information
8#  regarding copyright ownership.  The ASF licenses this file
9#  to you under the Apache License, Version 2.0 (the
10#  "License"); you may not use this file except in compliance
11#  with the License.  You may obtain a copy of the License at
12#
13#    http://www.apache.org/licenses/LICENSE-2.0
14#
15#  Unless required by applicable law or agreed to in writing,
16#  software distributed under the License is distributed on an
17#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18#  KIND, either express or implied.  See the License for the
19#  specific language governing permissions and limitations
20#  under the License.
21#
22#**************************************************************
23
24
25
26use POSIX qw(strftime);
27use POSIX qw(time difftime);
28# use POSIX qw(localtime);
29use strict;
30# use Time::localtime;
31use loghelper;
32
33BEGIN {
34    use Exporter   ();
35    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
36
37    $VERSION     = 1.00;
38    # if using RCS/CVS, this may be preferred
39    $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
40    @ISA         = qw(Exporter);
41    @EXPORT      = qw(&getTime &endTime &printTime &waitAMinute );
42    %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
43    # your exported package globals go here,
44    # as well as any optionally exported functions
45    @EXPORT_OK   = ( ); # qw($Var1 %Hashit &func3);
46}
47
48
49# ------------------------------------------------------------------------------
50# our $starttime;
51sub getTime()
52{
53    my $nValue;
54    # $nValue = localtime->sec();
55    # $nValue += 60 * localtime->min();
56    # $nValue += 3600 * localtime->hour();
57    $nValue = time();
58    return $nValue;
59}
60# sub startTime()
61# {
62#     $starttime = getTime();
63# }
64sub endTime($)
65{
66    my $starttime = shift;
67
68    my $endtime = getTime();
69    my $nTime = difftime($endtime, $starttime);
70    # my $nTime = $endtime - $starttime;
71    # if ($nTime < 0)
72    # {
73    #     $nTime += 24 * 3600; # add 24 hours
74    # }
75    return $nTime;
76}
77sub printTime($)
78{
79    my $nTime = shift;
80    print( "Time: " . $nTime . " seconds.\n\n");
81}
82
83
84# sub waitAMinute()
85# {
86#     # _waitInSeconds(20);
87#     # _waitInSeconds(20);
88#     my $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
89#     print $now_string . "\n";
90#     # print getCurrentDateString() . "\n";
91#     sleep(60);
92# }
93#
94
951;
96