diff --git a/bot/calculations.go b/bot/calculations.go index 8bad00f..2ecb427 100644 --- a/bot/calculations.go +++ b/bot/calculations.go @@ -7,10 +7,18 @@ import ( ) func computeNextFiatDepositDay() time.Time { - date := addMonthsToTime(1, time.Now()) + now := time.Now() - //get the first day of the month - return date.AddDate(0, 0, -date.Day()+1) + year := now.Year() + month := now.Month() + 1 + + if month > 12 { + month = 1 + year++ + } + + firstOfNextMonth := time.Date(year, month, 1, 0, 0, 0, 0, time.Local) + return firstOfNextMonth } func (b *Bot) calculateTimeOfNextOrder() { diff --git a/bot/time.go b/bot/time.go index 6b8a42a..f7c598e 100644 --- a/bot/time.go +++ b/bot/time.go @@ -5,10 +5,6 @@ import ( "time" ) -func addMonthsToTime(months int, time time.Time) time.Time { - return time.AddDate(0, months, 0) -} - func fmtDuration(d time.Duration) string { hour := int(d.Hours()) minute := int(d.Minutes()) % 60