Browse files

more fixes

  • Loading branch information...
1 parent 8ee1dbb commit 340acfdfcfd8c985531df2032d894b3f2b7ca45b @utkarsh2012 committed Aug 3, 2010
Showing with 14 additions and 13 deletions.
  1. +5 −2 README.rdoc
  2. +9 −11 lib/helpers.rb
View
7 README.rdoc
@@ -7,9 +7,12 @@ A Backup Tool built on Ruby
time should be passed in 24hrs format.
+For example, if you need to backup a folder ruby on your Desktop, everyday at 11:00PM for 5 days then:
-* For example, if you need to backup a folder ruby on your Desktop, everyday at 11:00PM for 5 days then:
- ruby backitup.rb "/Users/utkarsh/Desktop/ruby" "23:00" "5"
+* ruby backitup.rb "/Users/utkarsh/Desktop/ruby" "23:00" "5"
+
+If backup should be on ruby folder everyday at 12:30AM for 2 days then:
+* ruby backitup.rb "/Users/utkarsh/Desktop/ruby" "00:30" "2"
==TODO
View
20 lib/helpers.rb
@@ -35,26 +35,24 @@ def checkTime(inputTime, folderPath, duration)
inputTimeForSleep = inputTime.split(':')
diffHour = (inputTimeForSleep[0].to_i - hourSleep.to_i).abs
diffMin = (inputTimeForSleep[1].to_i - minutesSleep.to_i).abs
- if(diffHour == 24)
- diffHour = 0
- end
- if(diffMin == 60)
- diffMin = 0
- end
totalSeconds = diffHour*60*60 + diffMin*60 #seconds is not considered, so the wakeup won't be on the exact second
-
sleep(totalSeconds)
#Check the differnce of current time and input time and sleep for the difference - one time only END
- puts "in checkTime"
- while(Date.today != killDate)
- puts "in while"
+ while(Date.today < killDate)
hour = Time.now.hour.to_s
minutes = Time.now.min.to_s
+
+ #if the value of min or hr is 1 or 2..9,then append 0. So, it becomes 01, 02..09
if(minutes.length == 1)
- minutes = "0" + minutes
+ minutes = "0" + minutes
+ end
+ if(hour.length == 1)
+ hour = "0" + hour
end
+
+ #set current time format
currentTime = hour + ":" + minutes
#Call the create zip method once a day

0 comments on commit 340acfd

Please sign in to comment.