module Parsefiles::Utils::ClassMethods
Public Instance Methods
date_in_range(date,start_date,end_date)
click to toggle source
# File lib/parsefiles/utils.rb, line 24 def date_in_range(date,start_date,end_date) start = strDate_to_unix_timestamp(start_date) finish = strDate_to_unix_timestamp(end_date) + 86399 range = start..finish range === date end
strDate_to_unix_timestamp(strDate)
click to toggle source
# File lib/parsefiles/utils.rb, line 14 def strDate_to_unix_timestamp(strDate) Date.strptime(strDate, '%m-%d-%Y').to_time.to_i end
unix_ts(file)
click to toggle source
# File lib/parsefiles/utils.rb, line 10 def unix_ts(file) File.mtime(file).to_i end
validate_date_format(strDate)
click to toggle source
# File lib/parsefiles/utils.rb, line 18 def validate_date_format(strDate) Date.strptime(strDate,'%m-%d-%Y') rescue ArgumentError raise "Invalid date format. Correct format : m-d-y." end