Cukes C0 Coverage Information - Simploco - RCov

library/generic/datetime_library.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
library/generic/datetime_library.rb 79 30
91.14%
76.67%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

2 =begin
3 *Name           : DateTimeLibrary
4 *Description    : module that define methods for all datetime related manipulations
5 *Author         : Chandra sekaran
6 *Creation Date  : 23/08/2014
7 *Updation Date  :
8 =end
9 
10 module CUKES
11   module DateTimeLibrary
12 
13     # Description      : returns the current system time (datetime format)
14     # Author           : Chandra sekaran
15     #
16     def get_current_datetime
17       Time.now
18     rescue Exception => ex
19       $log.error("Error in getting current time : #{ex}")
20       exit
21     end
22 
23     # Description     : returns the formatted system time (datetime format)
24     # Author          : Chandra sekaran
25     # Arguments       :
26     #   date_time     : datetime value that has to be formatted
27     #
28     def get_formatted_datetime(date_time)
29       date_time.strftime(DATETIME_FORMAT)
30     rescue Exception => ex
31       $log.error("Error in getting formatted time : #{ex}")
32       #exit
33     end
34 
35     # Description     : returns the difference between two dates in Hours:Minutes:Seconds string
36     # Author          : Chandra sekaran
37     # Arguments       :
38     #   start_date    : datetime value for start time
39     #   end_date      : datetime value for end time
40     #
41     def get_datetime_diff(start_time, end_time)
42       num_difference = end_time.to_i - start_time.to_i
43       num_seconds    =  num_difference % 60                   # get seconds
44       num_difference = (num_difference - num_seconds) / 60
45       num_minutes    =  num_difference % 60                   # get minutes
46       num_difference = (num_difference - num_minutes) / 60
47       num_hours      =  num_difference % 24                   # get hours
48       num_difference = (num_difference - num_hours)   / 24
49       num_days       =  num_difference % 7                    # get days
50       # num_weeks      = (num_difference - num_days)    /  7
51 
52       if num_days > 0
53         return "#{num_days}:#{num_hours}:#{num_minutes}:#{num_seconds}"
54       else
55         return "#{num_hours}:#{num_minutes}:#{num_seconds}"
56       end
57     rescue Exception => ex
58       $log.error("Error in getting datetime difference : #{ex}")
59       #exit
60     end
61 
62     # Description       : converts nanoseconds into DD:HH:MM:SS time format
63     # Author            : Chandra sekaran
64     # Argument          :
65     #   num_nanoseconds : datetime value for start time
66     # Return Argument   : time in DD:HH:MM:SS as string
67     #
68     def format_nonoseconds_to_time(num_nanoseconds)
69       hours = num_nanoseconds/3.6E+12
70       minutes = hours*60%60
71       seconds = (hours*3600%60).round
72       days = hours.to_i/24
73       "#{days.to_i}:#{(hours.to_i%24).to_i}:#{minutes.to_i}:#{seconds}"   # returns time in DD:HH:MM:SS format
74     rescue Exception => ex
75       $log.error("Error in converting nanoseconds (#{num_nanoseconds}) to time : #{ex}")
76       exit
77     end
78 
79   end
80 end

Generated on 2015-05-08 10:40:30 +0530 with SimpleCov-RCov 0.2.3