Skip to content

Commit

Permalink
fix: calculate correct next fiat deposit day
Browse files Browse the repository at this point in the history
  • Loading branch information
Primexz committed Jun 24, 2024
1 parent f2f3002 commit 9154ccf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 11 additions & 3 deletions bot/calculations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 0 additions & 4 deletions bot/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9154ccf

Please sign in to comment.