Skip to content

Instantly share code, notes, and snippets.

@jmahony
Created July 14, 2015 08:03
Show Gist options
  • Save jmahony/e03ad7a5bbe9822e6b3e to your computer and use it in GitHub Desktop.
Save jmahony/e03ad7a5bbe9822e6b3e to your computer and use it in GitHub Desktop.
Print dates
package main
import (
"fmt"
"time"
)
var format = "02/01/2006"
var incrementInDays = 3
var amountOfDates = 5
func main() {
PrintDateEveryNDaysFromToday(incrementInDays, amountOfDates)
}
func PrintDateEveryNDaysFromToday(incrementInDays, amountOfDates int) {
PrintDateEveryNDays(incrementInDays, amountOfDates, time.Now())
}
func PrintDateEveryNDays(incrementInDays, amountOfDates int, from time.Time) {
for i := 0; i < amountOfDates; i++ {
fmt.Println(from.Format(format))
from = from.AddDate(0, 0, incrementInDays)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment