Fix 1 day offset for enuemrateDates

This commit is contained in:
Samuel Pua
2019-08-26 16:41:22 +08:00
parent 447f8ee5b7
commit 0705e660c6
2 changed files with 1 additions and 5 deletions

Binary file not shown.

View File

@@ -99,12 +99,10 @@ func getDir(path string, filter string) ([]string, []time.Time) {
name = path + "/" + file.Name() name = path + "/" + file.Name()
names = append(names, name) names = append(names, name)
dates = append(dates, workingDate) dates = append(dates, workingDate)
log.Printf("%v found\n", workingDate)
} }
} }
} }
log.Printf("%s: %v\n", path, dates)
return names, dates return names, dates
} }
@@ -123,16 +121,14 @@ func backupToday(timeToday time.Time, config Config, host Host) {
func findBackupDate(dates []time.Time, findDate time.Time) int { func findBackupDate(dates []time.Time, findDate time.Time) int {
for i, date := range(dates) { for i, date := range(dates) {
if date == findDate { if date == findDate {
log.Printf("%v found", date)
return i return i
} }
} }
log.Printf("%v not found", findDate)
return 0 return 0
} }
func enumerateDates(dates []time.Time, currDate time.Time, searchDayNum int) bool { func enumerateDates(dates []time.Time, currDate time.Time, searchDayNum int) bool {
for i:=1; i<=searchDayNum; i++ { for i:=1; i<searchDayNum; i++ {
for _, date := range(dates) { for _, date := range(dates) {
if currDate.Add(-time.Hour * time.Duration(24 * i)) == date { if currDate.Add(-time.Hour * time.Duration(24 * i)) == date {
log.Printf("Existing backup exists at %v\n", date) log.Printf("Existing backup exists at %v\n", date)